Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Ex.no:7.

INTERFACING ARDUINO AND RASPBERRY PI USING WIRELESS

DATE: MEDIUM

AIM:

To interfacing Arduino and raspberry pi using wireless medium

APPARATUS REQUIRED:

• RASPBERRY PI 3model B+
• ARDUINO UNO
• ESP8266(wifi module)
• JUMPER WIRES

SOFTWARE REQUIRED:

• THONNY ID
• ARDUINO SOFTWARE

THEORY:

RASPBERRY PI:

It is a series of small single board computers development in UK by rapsberry pi foundation


in association with Broadcom.
PINOUT DIAGRAM FOR RASPBERRY PI:

ESP8266(WIFI MODULE):

The ESP8266 is a low-cost Wi-Fi microcontroller chip produced by Espressif Systems. It is


commonly used in IoT (Internet of Things) projects due to its affordability and built-in Wi-Fi
capabilities. The ESP8266 can be programmed using the Arduino IDE or other development
platforms, making it a popular choice for DIY electronics enthusiasts and developers.

PINOUT DIAGRAM FOR ESP8266:


EXPERIMENTAL PROCEDURE:

Procedure:

1.connect pin TX of esp8266 to TX of Arduino Uno.

2.connect pin RX of esp8266 to RX of Arduino Uno.

3.type and compile the program in Arduino software. Here we can check the serial function
using softwareserial. H

4.now define the port and board in tools option.


5.now the comments are serially (view in serial monitor) provided in Arduino software.

6.Then move to thonny IDE and type the python program and run it.

7.Now here the comment which type in Arduino is send to esp8266 and in module(Through
wireless) the comment is send to raspberry

PROGRAM TO SEND DATA FROM ARDUINO TO WIFI MODULE:

Void setup()

Serial.begin(9600);

Void loop()

Serial.write(“jones\n”);

Delay(1800);

#include <ESP8266WiFi.h>

Const char* ssid = “OPPO A16”;

Const char* password = “naresh02”;

Const char* host = “192.168.120.49”; // Raspberry Pi IP address


Const int port = 8080;

Char message;

Void setup() {

Serial.begin(9600);

Delay(10);

// Connect to Wi-Fi network

Serial.println();

Serial.print(“Connecting to “);

Serial.println(ssid);

WiFi.begin(ssid, password);

While (WiFi.status() != WL_CONNECTED) {

Delay(500);

Serial.print(“.”);

Serial.println(“”);

Serial.println(“WiFi connected”);

Serial.println(“IP address: “);

Serial.println(WiFi.localIP());

Serial.end();

}
Void loop()

Serial.println(“Sending data to Raspberry Pi”);

WiFiClient client;

If (!client.connect(host, port))

Serial.println(“Connection failed”);

Delay(5000);

Return;

String s=Serial.readString();

Client.println(“jones”);

Client.stop();

Delay(5000); // Wait for 5 seconds before sending data again

PROGRAM TO SEND DATA FROM ESP8266 TO RASPBERRY PI:

Import socket

HOST=’192.168.120.49’#Raspberry ip address

PORT=8080

With socket. Socket(socket.AF_INET, socket. SOCK_STREAM) as s:

s. blind((HOST, PORT))

s.listen()
print(‘waiting for connection… ‘)

conn, addr=s.accept()

with conn:

print(‘connected by’, addr)

while true:

data=conn.recv(1024)

if not data:

break

print(‘Received data:’ +data.decode())

RESULT:

Thus, the study on interfacing ARDUINO and RASPBERRY PI USING WIRELESS


medium(ESP8266) was Conducted and executed successfully.

You might also like