0% found this document useful (0 votes)
92 views34 pages

IoT Manual

The document describes experiments interfacing Arduino with different wireless communication modules like Zigbee, GSM and Bluetooth. The experiments cover basics of Arduino programming, sending and receiving data over different wireless mediums and designing IoT based systems.

Uploaded by

Nehru Model
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views34 pages

IoT Manual

The document describes experiments interfacing Arduino with different wireless communication modules like Zigbee, GSM and Bluetooth. The experiments cover basics of Arduino programming, sending and receiving data over different wireless mediums and designing IoT based systems.

Uploaded by

Nehru Model
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

LABORATORY RECORD BOOK

Name: ………………………………………. Certified that this is the Bonafide Record of work


done in the “OCS 352 IoT Concepts and Applications Laboratory” by the above student
having Register number……………………………………………………. Year / Semester
III/6th Branch Food Technology during the Academic year 2023-2024.

Staff In-charge: HOD

Submitted for Anna University Practical Examination held on…………………………………..


At NEHRU INSTITUTE OF TECHNOLOGY, Coimbatore.

REGISTER
NUMBER

Internal Examiner: External Examiner:


Date: Date:
VISION OF INSTITUTION

 To be leading Institution in Academic excellence, Multidisciplinary Research,


Innovation, Entrepreneurship and Industry Relation in order to mould true citizens
of the country.
MISSION OF INSTITUTION

● To create innovative and vibrant young leaders in Engineering and Technology field for
building India as a knowledge power by improving the teaching-learning process

● To enhance employability, entrepreneurship and to improve the research competence to


address Societal needs.

● To generate engineering graduates who use knowledge as a powerful tool to drive


societal transformation and inculcate in them ethical and moral values.

VISION OF DEPARTMENT

 To be a leading institution in producing technically competitive food technologists


and researchers in order to meet up food security and sustainability of the nation.
MISSION OF THE DEPARTMENT

 To enhance the student’s ability for improving research proficiency in new product
development through advanced processing technologies for meeting customer
demands.

 To be recognized as a leading and distinctive educational institution in creating


young leaders entrepreneurs in food sector who can contribute for technological
advancements.

 Produce technically well versed and socially responsive professionals who would
take up the national, international positions in government and private sectors of
food technology.
 To support industry and entrepreneurship by promoting basic, applied and adaptive
research through faculty engagement in the areas of Food technology and allied
disciplines
LIST OF EXPERIMENTS

SI.NO EXPERIMENT

01 INTRODUCTION TO ARDUINO PLATFORM AND PROGRAMMING

02 INTERFACING ARDUINO TO ZIGBEE MODULE

03 INTERFACING ARDUINO TO GSM MODULE

04 INTERFACING ARDUINO TO BLUETOOTH MODULE

05 INTRODUCTION TO RASPBERRY PI PLATFORM AND PYTHON


PROGRAMMING

06 INTERFACING SENSORS TO RASPBERRY PI

07 COMMUNICATION BETWEEN ARDUINO AND RASPBERRY PI USING


ANY WIRELESS MEDIUM

08 SETUP A CLUOD PLATFORM TO LOG THE DATA

09 LOG DATA USING RASPBERRY PI AND UPLOAD TO THE CLOUD


PLATFORM

10 DESIGN AN IOT BASED SYSTEM


EXPERIMENT NO- 1
INTRODUCTION TO ARDUINO PLATFORM AND PROGRAMMING
AIM :
To Test Adruino Ide Using Of To Arduino Platform And Programming.
APPARTUS REQUIRED :
1. Arduino board (e.g., Arduino Uno)
2. Ultrasonic sensor
3. Breadboard and jumper wires
4. Downloading cable
PROCEDURE :
1. Write your code using the Arduino programming language. The code consists of two main
functions: setup() (for initialization) and loop() (for the main program execution).
2. There are various Arduino boards with different specifications and features, but they all share
a common architecture.
3. Connect your Arduino board to your computer using a USB cable.Select the correct board and
port in the Arduino IDE.Click the "Upload" button to upload the code to the Arduino.

PROGRAM:
a) PUSH BUTTON USING ARDUINO

#include <Arduino.h>
#define buttonPin 2
void setup() {
// Initialize the button pin as an input
pinMode(buttonPin, INPUT);
// Initialize serial communication
Serial.begin(9600);
Serial.println("Active-High Push Button Status:");
}

void loop() {
/*Read the status of the button*/
boolbuttonState = digitalRead(buttonPin);

// Check for valid button state


if (buttonState == HIGH || buttonState == LOW) {
// Print the button status
if (buttonState == LOW) {
Serial.println("Button is pressed (Active-High)");
} else {
Serial.println("Button is not pressed");
}
} else {
// Handle invalid button state
Serial.println("Error: Invalid button state");
}

delay(1000);
}
CONNECTION :
OUTPUT :

b) RGB led using arduino

#include <Arduino.h>

/*RGB LED pins (Common Cathode)*/


#define Red_Pin 9
#define Green_Pin 10
#define Blue_Pin 11
/*Delay (in milliseconds)*/
#define COLOR_CHANGE_DELAY 1000

void setup() {
/*Initialize the RGB LED pins as outputs*/
pinMode(Red_Pin, OUTPUT);
pinMode(Green_Pin, OUTPUT);
pinMode(Blue_Pin, OUTPUT);
}

void loop() {
/*Turn on Red, turn off Green and Blue*/
digitalWrite(Red_Pin, HIGH);
digitalWrite(Green_Pin, LOW);
digitalWrite(Blue_Pin, LOW);
delay(COLOR_CHANGE_DELAY);

/*Turn off Red, turn on Green, turn off Blue*/


digitalWrite(Red_Pin, LOW);
digitalWrite(Green_Pin, HIGH);
digitalWrite(Blue_Pin, LOW);
delay(COLOR_CHANGE_DELAY);

/*Turn off Red, turn off Green, turn on Blue*/


digitalWrite(Red_Pin, LOW);
digitalWrite(Green_Pin, LOW);
digitalWrite(Blue_Pin, HIGH);
delay(COLOR_CHANGE_DELAY);

/*Turn ON Red,Green,Blue*/
digitalWrite(Red_Pin, HIGH);
digitalWrite(Green_Pin, HIGH);
digitalWrite(Blue_Pin, HIGH);
delay(COLOR_CHANGE_DELAY);
}
CONNECTION& OUTPUT :

RESULT :
The Tested Was Successfully Completed with ultrasonic sensor .
EXPERIMENT NO- 2
INTERFACING ARDUINO TO ZIGBEE MODULE
AIM :
TO TEST ADRUINO IDE USING zigbee .
APPARTUS REQUIRED:
1. Arduino board
2. Buzzer
3. Jumper wires
4. Bluetooth sensor
5. Zigbee sensor

PROCEDURE :
1.Connect your Arduino board to your computer using a USB cable.Select the correct board and
port in the Arduino IDE.Click the "Upload" button to upload the code to the Arduino.
2. Test the Bluetooth communication between devices, ensuring a stable connection and data
transfer. Bluetooth is suitable for short-range applications like wearables, smart home devices,
and local sensor networks.
3. Consider the power requirements of each communication method, especially for battery-
operated IoT devices.
PROGRAM :
Zigbee :
#include <SoftwareSerial.h>
SoftwareSerialxbee(2, 3); // RX, TX
void setup() {
Serial.begin(9600);
xbee.begin(9600); // Set the baud rate to match your XBee module
}
void loop() {
if (Serial.available()) {
String dataToSend = Serial.readString();
xbee.println(dataToSend); // Send the data to XBee
}
if (xbee.available()) {
String receivedData = "";
while (xbee.available()) {
char c = xbee.read();
receivedData += c;
}
Serial.println("Received: " + receivedData);
}
}

RESULT:
The Tested Was Successfully Completed.
EXPERIMENT NO- 3
INTERFACING ARDUINO TO GSM MODULE
AIM :
TO TEST ADRUINO IDE USING GSM.
APPARTUS REQUIRED :
1. Arduino board
2. Buzzer
3. Jumper wires
4. Bluetooth sensor
5. Zigbee sensor
6. GSM

PROCEDURE :
1.Connect your Arduino board to your computer using a USB cable.Select the correct board and
port in the Arduino IDE.Click the "Upload" button to upload the code to the Arduino.
2. Test the Bluetooth communication between devices, ensuring a stable connection and data
transfer. Bluetooth is suitable for short-range applications like wearables, smart home devices,
and local sensor networks.
3. Consider the power requirements of each communication method, especially for battery-
operated IoT devices.
PROGRAM :
GSM :
#include <SoftwareSerial.h>
#include <DFRobot_DHT11.h>
DFRobot_DHT11 DHT;
#define DHT11_PIN 8
#define DEBUG true
SoftwareSerialGSM_Serial(2, 3); // Pin 2 and 3 act as RX and TX. Connect them to TX and RX
of ESP8266
/*user Credential*/
String Host_URL = "console.thingzmate.com";
String Sub_URL_POST="/api/v1/device-types/thingzmate-basic-kit/devices/demo-1/http-
uplink";
String Sub_URL_GET="/api/v1/device-types/thingzmate-basic-kit/devices/demo-1/http-
downlink";
String PORT = "80";
String Bearer_Key= "Bearer 4e3dac123dbf812530fe0af613ff4aab";
/*Variables*/
intsendVal;
String response = "";
booldataStarted=0,RECV=0;
String jsonData="";
void setup() {
Serial.begin(9600);
GSM_Serial.begin(9600);
Serial.println("Thinzkit_Basic_GSM");
GSM_Module_init();
}
void loop() {
/*Uplink*/
Sending_data_to_the_cloud();
delay(10000);
/*Downlink*/
receiveDataFromCloud();
delay(10000); // Delay before making the next request
}
/*HTTP POST Function*/
voidSending_data_to_the_cloud(){
RECV=0;
GSM_Data("AT+CIPMUX=1", 1000, DEBUG);
delay(2000);
GSM_Data("AT+CSTT=\"airtelgprs.com\"", 1000, DEBUG); // Connect to WiFi network
delay(3000);
GSM_Data("AT+CIICR", 1000, DEBUG); // Connect to WiFi network
delay(3000);
GSM_Data("AT+CIFSR", 1000, DEBUG); // Connect to WiFi network
delay(3000);
GSM_Data("AT+CIPSPRT=0", 1000, DEBUG); // Connect to WiFi network
delay(3000);
Sensor_Data();
delay(200);
String sendData = "POST "+Sub_URL_POST+" HTTP/1.1\r\nHost: " + Host_URL + "\r\
nAuthorization: "+Bearer_Key+"\r\nContent-Type: application/json\r\nContent-Length: " +
String(jsonData.length()) + "\r\n\r\n" + jsonData;
GSM_Data("AT+CIPSTART=0,\"TCP\",\"" + Host_URL + "\"," + PORT, 1000, DEBUG);
delay(2000);
GSM_Data("AT+CIPSEND=0," + String(sendData.length()), 1000, DEBUG);
delay(2000);
GSM_Serial.print(sendData);
GSM_Serial.print((char)26);
for(inti=0;i<10000;i++);
GSM_Data("AT+CIPCLOSE=0", 4000, DEBUG);
}
/*HTTP GET Function*/
voidreceiveDataFromCloud() {
RECV=1;
String send_Data = "GET "+Sub_URL_GET+" HTTP/1.1\r\nHost:" + Host_URL + "\r\
nAuthorization: "+Bearer_Key+"\r\n\r\n";
GSM_Data("AT+CIPSTART=0,\"TCP\",\"" + Host_URL + "\"," + PORT, 1000, DEBUG);
delay(3000);
GSM_Data("AT+CIPSEND=0," + String(send_Data.length()), 1000, DEBUG);
delay(2000);
GSM_Serial.print(send_Data);
GSM_Serial.print((char)26);
for(inti=0;i<20000;i++);
GSM_Data("AT+CIPCLOSE=0", 8000, DEBUG);
delay(2000);
}
/*We can write our downlink action in this function*/
voidDownlinkaction(){
if(response=="01"){Serial.println("LED_ON");}
if(response=="02"){Serial.println("LED_OFF");}
}
/**/
voidGSM_Module_init()
{
GSM_Data("AT", 1000, DEBUG); // Reset the ESP8266 module
delay(3000);
GSM_Data("AT+CPIN?", 1000, DEBUG); // Set the ESP mode as station mode
delay(3000);
GSM_Data("AT+CREG?", 1000, DEBUG); // Connect to WiFi network
delay(3000);
GSM_Data("AT+CGATT?", 1000, DEBUG); // Connect to WiFi network
delay(3000);
GSM_Data("AT+CIPSHUT", 1000, DEBUG); // Connect to WiFi network
delay(3000);
GSM_Data("AT+CIPSTATUS", 1000, DEBUG); // Connect to WiFi network
delay(3000);
}

String GSM_Data(String command, constint timeout, boolean debug) {


if (debug) {
Serial.print("AT Command ==> ");
Serial.println(command);
}
GSM_Serial.println(command);
longint time = millis();
while ((time + timeout) >millis()) {
while (GSM_Serial.available()) {
char c = GSM_Serial.read();
if (debug) {
Serial.write(c);
}
if (c == '{' && RECV==1) {
// Start capturing data
dataStarted = true;
response = "";
}

if (dataStarted == true && c != '{' && c != '}' ) {


// Start capturing data
response += c;
}
if(c == '}'&&dataStarted == true){
dataStarted = false;
Serial.println("Received LED Status Data: " + response);
Downlinkaction();
response = "";
}
}
}
if (debug) {
Serial.print(response);
}
return response;
}

voidSensor_Data(){
DHT.read(DHT11_PIN);
Serial.print("temp:");
Serial.print(DHT.temperature);
Serial.print(" humi:");
Serial.println(DHT.humidity);
jsonData = "{\"Temperature\":" + String(DHT.temperature) + ",\"Humidity\":" +
String(DHT.humidity) + "}";

RESULT:
The Tested Was Successfully Completed.
EXPERIMENT NO- 4
INTERFACING ARDUINO TO BLUETOOTH MODULE
AIM :
TO TEST ADRUINO IDE USING BLUETOOTH.
APPARTUS REQUIRED :
1. Arduino board
2. Buzzer
3. Jumper wires
4. Bluetooth sensor
5. Zigbee sensor
6. GSM

PROCEDURE :
1.Connect your Arduino board to your computer using a USB cable.Select the correct board and
port in the Arduino IDE.Click the "Upload" button to upload the code to the Arduino.
2. Test the Bluetooth communication between devices, ensuring a stable connection and data
transfer. Bluetooth is suitable for short-range applications like wearables, smart home devices,
and local sensor networks.
3. Consider the power requirements of each communication method, especially for battery-
operated IoT devices.
PROGRAM :
Bluetooth :
#include <SoftwareSerial.h>
#define LED_pin 13
SoftwareSerialbluetooth(2, 3); // RX, TX
float data=25.98;
charcharArray[10];
void setup() {
Serial.begin(9600); // Initialize the serial monitor
bluetooth.begin(9600); // Initialize the Bluetooth communication
pinMode(LED_pin,OUTPUT);
}
void loop() {
// Check if data is available from Bluetooth module
if (bluetooth.available()) {
charreceivedChar = bluetooth.read(); // Read the character received via Bluetooth
Serial.print("Received: ");
Serial.println(receivedChar);
// Example: Send a response back to the Bluetooth module
if (receivedChar == '1') {
digitalWrite(LED_pin, HIGH);
Serial.print("LED_ON");
}
else if(receivedChar == '0')
{
digitalWrite(LED_pin, LOW);
Serial.print("LED_OFF");
}
else if(receivedChar == '2'){
dtostrf(data, 6, 2, charArray); // float to char convertion
bluetooth.write(charArray);
delay(100);
}
}
}

RESULT:
The Tested Was Successfully Completed.
EXPERIMENT NO- 5
INTRODUCTION TO RASPBERRY PI PLATFORM AND PYTHON PROGRAMMING
AIM:
LED sensor with a Raspberry Pi with thonny python ide of the Raspberry Pi and then
writing a Python script to read data from the sensor.
APPARTUS REQUIRED :
1. Raspberry pi board
2. Blinking LED
3. power supply
4. cables
5. Internet Connectivity
PROCEDURE :
1. Using thonny python ide and create code in python format.
2. Connect the VCC pin of 5V on the Arduino.Connect the GND pin of the IR sensor to the
GND on the Arduino.
3. Connect the OUT pin of the LED sensor to a digital pin on the Arduino (e.g., D2).
Connect the positive (longer) leg of the LED to a digital pin through a 220-ohm resistor
(e.g., D13) Connect the negative (shorter) leg of the LED to GND.

PROGRAM :
import machine as Gpio
importutime as TM

# Define the RGB LED pins (common cathode)


Red_Pin = Gpio.Pin(15, Gpio.Pin.OUT)

defset_rgb_color(red, green, blue):


Red_Pin.value(red)
# Main loop
while True:
# Red
set_rgb_color(1, 0, 0)
TM.sleep(1)
set_rgb_color(0, 0, 0)
TM.sleep(1)
OUTPUT :

RESULT:
Thus Tested Was Successfully Completed.
EXPERIMENT NO- 6
INTERFACING SENSOR TO RASPBERRY PI
AIM :
Interfacing the DHT11 sensor with a Raspberry Pi involves connecting the sensor to the GPIO
pins of the Raspberry Pi .
APPARTUS REQUIRED :
1. Raspberry pi board
2. Blinking LED
3. power supply
4. cables
5. Internet Connectivity
PROCEDURE :
1. Connect the VCC pin of the DHT11 to the 5V pin on the Raspberry Pi.Connect the data
pin of the DHT11 to a GPIO pin on the Raspberry Pi (e.g., GPIO 17).Connect the ground
(GND) pin of the DHT11 to the GND pin on the Raspberry Pi.
2. Save the Python script with a .py extension (e.g., DHT 11_sensor.py).
3. Open a terminal and navigate to the directory containing the script.
PROGRAM :
importdht
import machine as gpio
importutime as TM

# Define the DHT11 sensor pin (change to your GPIO pin)


dht11_pin = gpio.Pin(15)

# Create a unique variable name to store DHT11 data


dht11_data = dht.DHT11(dht11_pin)

# Function to read and print DHT11 sensor data


def read_dht11_data():
for _ in range(3): # Retry 3 times
try:
dht11_data.measure() # Measure temperature and humidity
temperature = dht11_data.temperature()
humidity = dht11_data.humidity()
print("Temperature: {:.2f}°C".format(temperature))
print("Humidity: {:.2f}%".format(humidity))
return # If successful, exit the loop
exceptOSError as e:
print("Error reading DHT11:", e)
TM.sleep(2) # Add a delay before retrying

# Main loop
while True:
read_dht11_data()
TM.sleep(2) # Add a delay between readings

OUTPUT:

RESULT:
Thus Tested Was Successfully Completed.
EXPERIMENT NO- 7
COMMUNICATION BETWEEN ARDUINO AND RASPBERRY PI USING ANY
WIRELESS MEDIUM
AIM :
To write and execute the program to Communicate between Arduino and Raspberry PI
using any wireless medium (Bluetooth)

APPARTUS REQUIRED :
1. Thonny IDE
2. Raspberry Pi Pico Development Board
3. Arduino Uno Development Board
4. Jumper Wires
5. Micro USB Cable
6. Bluetooth Module

CONNECTIONS PROCEDURE:

Arduino UNO Pin Arduino development Board Bluetooth Module


2 - Tx
3 - Rx
- GND GND
- 5V 5V

PROGRAM:

MASTER ARDUINO:

#include<SoftwareSerial.h>
SoftwareSerialmySerial(2,3
); //rx,tx void setup() {

mySerial.begin(9600);
}
void loop() {
mySerial.w
rite('A');
delay(1000
);
mySerial.w
rite('B');
delay(1000
);

CONNECTIONS PROCEDURE:

Raspberry Pi Pico Pin Raspberry Pi Pico Bluetooth


development Board Module

GP16 LED -
VCC - +5V
GND - GND
GP1 - Tx
GP0 - Rx

SLAVE
RASPBERRY PI PICO
from machine import
Pin, UART uart =
UART(0, 9600)

led = Pin(16, Pin.OUT)


while True:
if uart.any() > 0:
data =
uart.read
()
print(dat
a)

if "A" in data:
led.value(1)
print('LED on
\n')
uart.write('LE
D on \n')

elif "B" in data:


led.value(0)
print('LED off
\n')
uart.write('LE
D off \n') To
connect the
communicatio
n between
Arduino and
raspberry pi
using wireless
medium with
protocol of the
communicatio
n.

RESULT :
Thus Tested Was Successfully Completed.
EXPERIMENT NO- 8
SETUP A CLOUD PLATFORM TO LOG THE DATA
AIM :
To setup a cloud platform to log the data.
APPARTUS REQUIRED :
1. ARDUINO IDE
2. NODE MCU
3. IR SENSOR
4. Bread board
STEP BY STEP PROCEDURE:
1. Using an IR (Infrared) sensor with a platform like ThingSpeak involves connecting the IR
sensor to a microcontroller, reading the sensor data, and then sending that data to
ThingSpeak for visualization and analysis.
2. Install the necessary libraries for the IR sensor. For example, if you are using a common IR
sensor like the TSOP382, you might need the "IRremote" library.
PROGRAM :
#include <IRremote.h>
#include <ESP8266WiFi.h>
#include <ThingSpeak.h>

const char *ssid = "silicon systems";


const char *password = "Silicon@2017";
const char *apiKey = "QWD5TTQ08RBGQFVH";

constint IR_PIN = 2; // Change this to the pin connected to your IR sensor

IRrecvirrecv(IR_PIN);
decode_results results;

void setup() {
Serial.begin(9600);

irrecv.enableIRIn(); // Start the IR receiver


WiFi.begin(ssid, password);

ThingSpeak.begin(client); // Initialize ThingSpeak


}

void loop() {
if (irrecv.decode(&results)) {
// Read and send the data to ThingSpeak
intirValue = results.value;
Serial.print("IR Value: ");
Serial.println(irValue);

// Send data to ThingSpeak


ThingSpeak.writeField(YOUR_CHANNEL_ID, 1, irValue, apiKey);

irrecv.resume(); // Receive the next value


delay(10000); // Delay to avoid sending data too frequently
}
// Other loop logic can be added here
}

OUTPUT :

RESULT :
Thus Tested Was Successfully Completed.
EXPERIMENT NO- 9
LOG DATA USING RASPBERRY PI AND UPLOAD TO THE CLOUD
PLATFORM
AIM :
To test the log data using raspberry pi and upload to the cloud platform.
APPARTUS REQUIRED:
1. RASPBERRY PI
2. NODE MCU
3. IR SENSOR
4. Bread board
PROCEDURE :

1. Connect the IR sensor to the Arduino.


2. The connections may vary based on your specific IR sensor model, but typically, it
involves connecting the sensor's signal pin to a digital pin on the Arduino and
power/ground pins appropriately.
3. Install the necessary libraries for the IR sensor.
4. For example, if you are using a common IR sensor like the TSOP382, you might need the
"IRremote" library.
PROGRAM :
import machine
importutime
importurequests
import network

IR_SENSOR_PIN = 2 # GPIO pin for the IR sensor


API_KEY = "ZSX5SRTSRJ61XVU6"
THINGSPEAK_URL = "https://api.thingspeak.com/update?api_key={}".format(API_KEY)
WIFI_SSID = "@ms.Balaji"
WIFI_PASSWORD = "@msbalaji"

ir_sensor = machine.Pin(IR_SENSOR_PIN, machine.Pin.IN)


wlan = network.WLAN(network.STA_IF)

defconnect_to_wifi():
wlan.active(True)
if not wlan.isconnected():
print("Connecting to WiFi...")
wlan.connect(WIFI_SSID, WIFI_PASSWORD)
while not wlan.isconnected():
pass
print("Connected to WiFi")

defread_ir_sensor():
returnir_sensor.value()

defsend_to_thingspeak(data):
# Send data to ThingSpeak
url = "{}&field1={}".format(THINGSPEAK_URL, data)
response = urequests.get(url)
print("ThingSpeak response:", response.text)

# Connect to WiFi
connect_to_wifi()

while True:
ir_data = read_ir_sensor()
print("IR Sensor Data:", ir_data)
# Send data to ThingSpeak via HTTP
send_to_thingspeak(ir_data)

utime.sleep(15) # Wait for 15 seconds before the next reading

OUTPUT :

RESULT:
Thus Tested Was Successfully Completed.
EXPERIMENT NO- 10
DESIGN AN IOT BASED SYSTEM
AIM :
To design a Smart Home Automation IOT-based system

APPARTUS REQUIRED
1. Thonny IDE
2. Raspberry Pi Pico Development Board
3. Jumper Wires
4. Micro USB Cable
5. LED or Relay

PROCEDURE

CONNECTIONS PROCEDURE :

Raspberry Pi Raspberry Pi Pico


Pico pin Development Board

GP16 LED 1
PROGRAM:
import
time
import
network
import
BlynkLi
b
from machine
import Pin
led=Pin(16,
Pin.OUT)

wlan =
network.WLAN(
)
wlan.active(True
)
wlan.connect("Wifi_Username","Wifi_Pa
ssword") BLYNK_AUTH = 'Your_Token'

# connect the
network wait
= 10
while wait > 0:
if wlan.status() < 0 or
wlan.status() >= 3: break
wait -= 1
print('waiting for
connection...')
time.sleep(1)

# Handle
connection error
if wlan.status() !=
3:
raise RuntimeError('network
connection failed') else:
print('connec
ted')
ip=wlan.ifco
nfig()[0]
print('IP: ',
ip)

"Connection
to Blynk" #
Initialize
Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)

# Register virtual pin


handler
@blynk.on("V0")
#virtual pin V0
def v0_write_handler(value): #read
the value if int(value[0]) == 1:
led.value(1) #turn
the led on else
led.value(0) #turn
the led off while True:
blynk.run()

RESULT:
Thus Tested Was Successfully Completed.

You might also like