What is Raspberry Pi?

The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python.

Diagram of Raspberry Pi 3:

Recipe

What you need:

Raspberry Pi 3

a Mouse

a microSD card

HDMI cable

a mon

Install Raspbian (NOOBS)

Unzip the file to put them all into a microSD card.

Then plug the microSD card into Raspberry Pi.

Plug A Mouse (USB) and then plug the HDMI into a Mon.

Connect your Pi to internet

Raspberry Pi Software Configuration Tool

1
sudo raspi-config

Update Raspberry Pi

1
sudo apt-get update

Install Python3 and IDLE3

1
2
sudo apt update
sudo apt install python3 idle3

TCP Server and Client

Check IP on Pi

1
ifconfig

Check IP on Macbook

1
ipconfig getifaddr en0

Disable iptables

1
sudo iptables -L -nv

Sample Codes From Here

More about socket

On 1 Side:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#server.py
import socket

s = socket.socket()
host = '' #ip of raspberry pi
port = 5005
s.bind((host, port))

s.listen(5)
while True:
c, addr = s.accept()
print ('Got connection from',addr)
output = 'Thank you for connecting'
c.sendall(output.encode('utf-8'))
c.close()

On another side:

1
2
3
4
5
6
7
8
9
#client.py
import socket.socket()

s = socket.socket()
host = '' #ip of raspberry pi
port = 5005
s.connect((host, port))
print(s.recv(1024))

Another Solutions

Another Solutions