IoT Manual
IoT Manual
REGISTER
NUMBER
● 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
VISION OF DEPARTMENT
To enhance the student’s ability for improving research proficiency in new product
development through advanced processing technologies for meeting customer
demands.
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
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);
delay(1000);
}
CONNECTION :
OUTPUT :
#include <Arduino.h>
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 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);
}
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
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
# 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:
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:
GP16 LED -
VCC - +5V
GND - GND
GP1 - Tx
GP0 - Rx
SLAVE
RASPBERRY PI PICO
from machine import
Pin, UART uart =
UART(0, 9600)
if "A" in data:
led.value(1)
print('LED on
\n')
uart.write('LE
D on \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>
IRrecvirrecv(IR_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
void loop() {
if (irrecv.decode(&results)) {
// Read and send the data to ThingSpeak
intirValue = results.value;
Serial.print("IR Value: ");
Serial.println(irValue);
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 :
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)
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 :
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)
RESULT:
Thus Tested Was Successfully Completed.