VASIREDDY VENKATADRI INSTITUTE OF TECHNOLOGY
(AUTONOMOUS)
Accredited by NBA (B.Tech program), Approved by AICTE, Permanently Affiliated to
JNTUK,NAAC Accredited with ‘A’ Grade, ISO 9001:2015 Certified
Nambur (V), Pedakakani (M), Guntur (Dt.), Andhra Pradesh – 522 508, www.vvitguntur.com
DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING
Fundamentals of
Internet of Things
(SKILL ORIENTED COURSE-I)
Manual
(STUDENT COPY)
NAME OF STUDENT:
REGD. NUMBER :
ACADAMIC YEAR :
REGULATION : R-
Dept. of E.E.E. VVIT
List of Experiments
S. No Name of the Experiment Page. No
1 Blinking LED using arduino
2 Interfacing DHT11 humidity sensor with Arduino.
3 Intruder detection using PIR sensor using Arduino
4 Traffic Light Simulator using Arduino.
5 Water flow sensor with an Arduino board.
6 Ultrasonic sensor using Arduino board
7 LED Blinking with Raspberry Pi and Python Program
8 Traffic Light Simulator using Raspberry Pi.
9 PIR Sensor using Raspberry Pi using LED
Lab Incharge
Dept. of E.E.E. VVIT
Expt: 1
AIM: Blinking LED
Components Required:
1. Arduino controller board,
2. USB connector,
3. Bread board, LED,
4. 1.4Kohm resistor,
5. Connecting wires,
6. Arduino IDE
Connection Procedure:
1. Connect the LED to the Arduino using the
Bread board and the connecting wires.
2. Connect the Arduino board to the PC using
the USB connector;
3. Select the board type and port.
4. Write the sketch in the editor, verify and
upload.
5. Connect the positive terminal of the LED
to digital pin 12 and the negative terminal
to the ground pin (GND) of Arduino
Board.
Programme: Sketch
void setup()
{
pinMode (12, OUTPUT); // set the pin mode
}
void loop ()
{
digitalWrite (12, HIGH); // Turn on the LED
delay (1000);
digitalWrite (12, LOW); //Turn of the LED
delay (1000);
}
Output/Results:
Experiment No . 2
Aim. Interfacing DHT11 humidity sensor with Arduino.
Apparatus:
S.No Component Quantity
1 Arduino uno 1Nos
2 Bread Board 1Nos
3 16 x 2 LCD display 1Nos
4 Male to male, male to female connectors
5 Software Arduino IDE 1Nos
6 10 k ohm variable resistor pot 1Nos
7 DHT11 temperature and humidity sensor 1Nos
8 Usb communication cable of Arduino uno 1Nos
Connection Diagram:
Procedure:
1. The four data Pins D4 to D7 are connected to the four pins (2 to 5) of the arduino.
2. Rs (register select) and E (Enable) pins are connected to the pin12 and pin11 of the
arduino.
3. VSS pin of the LCD is connected to the ground while VDD is connected to the power
supply.
4. V EE of LCD is connected to the potentiometer in order to vary the brightness of the
LCD.
5. RW pin is connected to ground.
6. Download DHT11 sensor library from github and save it in the Arduino libraries and
then include it in the code
7. Connect the dht11 wiring as shown in the circuit diagra
CODE:
#include <LiquidCrystal.h>
#include "DHT.h"
#define DHTPIN 8
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
lcd.begin(16, 2);
dht.begin();
lcd.print("Temp: Humidity:");
}
void loop()
{
delay(500);
lcd.setCursor(0, 1);
float h = dht.readHumidity();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(f))
{
lcd.print("ERROR");
return;
}
lcd.print(f);
lcd.setCursor(7,1);
lcd.print(h);
}
Results:
Experiment No . 3
Aim. Intruder detection using PIR sensor using Arduino
Apparatus:
S.No Component Quantity
1. Arduino uno 1Nos
2. LED 1Nos
3. Bread Board 1Nos
4. Male to male, male to female connectors
5. Software Arduino IDE
6. PIR sensor 1Nos
7. Usb communication cable of Arduino uno 1Nos
Working of PIR Sensor:
PIR sensor is a special type sensor which is usually used for security purposes. It detects
the objects by reading the Infrared radiations emitted by the objects. Any object whose
temperature is above absolute zero, emits radiation. This radiation is not visible to
human eyes. The PIR sensor is designed to detect this Infrared radiation.
The PIR sensor has two modes. You can switch between these modes by interchanging
the jumper behind the PIR sensor as shown in the images below.
Procedure:
1. Interfacing PIR sensor with Arduino
Vcc
Vcc
Gnd
1. PIR to Arduino
• Connect the Vcc of PIR to 5V on Arduino
• Connect the GND of PIR to GND on Arduino
• Connect the OUTPUT pin of PIR to Digital pin D3 on Arduino
2. Buzzer to Arduino
• Connect one pin of buzzer to digital pin D8 on Arduino
• Connect other pin of buzzer to GND on Arduino
3. LED to Arduino
• Connect the LED positive to Digital pin D13 on Arduino through a resistor.
• Connect the LED negative to GND on Arduino.
Arduino Code:
int Buzz= 8; // Define Bizzer pin
int LED= 13; // Define LED pin
int PIR= 3; // Define PIR pin
int val= 0; // Initializing the value as zero at the beginning
void setup()
{
pinMode(Buzz, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(PIR, INPUT);
Serial.begin(9600);
}
void loop()
{
val = digitalRead(PIR); // The value read from PIR pin
if(val == HIGH)
{
digitalWrite(LED, HIGH); // Turn LED ON
digitalWrite(Buzz, HIGH); // T
Serial.println("Movement Detected"); // Print this text in Serial Monitor
}
else
{
digitalWrite(LED, LOW);
digitalWrite(Buzz, LOW);
Serial.println("Movement not Detected");
}
}
Results:
Experiment No . 4
Arduino Traffic Light Simulator.
AIM: Simulate a traffic light using an Arduino and LED’s.
Components:
S.No Component Quantity
1. Arduino uno 1Nos
2. LED (Red, Yellow & Green) 3Nos
3. Bread Board 1Nos
4. Male to male, male to female connectors
5. Software Arduino IDE
6. USB communication cable of Arduino uno 1Nos
7. 100ohm resistor 3Nos
Procedure:
Step 1: Supply power to the breadboard.
Step 2: Adding the LEDs.
Step 3: Completing the circuit.
Step 4: Take another jumper wire, put it on the same row that you have an LED on. This is
where the wires will go:
Green LED: Port 2, Digital PWM section
Yellow LED, Port 3, Digital PWM section
Red LED, Port 4, Digital PWM section
Connection Diagram:
Arduino Traffic Light Code
// variables
int GREEN = 2;
int YELLOW = 3;
int RED = 4;
int DELAY_GREEN = 5000;
int DELAY_YELLOW = 2000;
int DELAY_RED = 5000;
// basic functions
void setup()
{
pinMode(GREEN, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(RED, OUTPUT);
}
void loop()
{
green_light();
delay(DELAY_GREEN);
yellow_light();
delay(DELAY_YELLOW);
red_light();
delay(DELAY_RED);
}
void green_light()
{
digitalWrite(GREEN, HIGH);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, LOW);
}
void yellow_light()
{
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, HIGH);
digitalWrite(RED, LOW);
}
void red_light()
{
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, HIGH);
}
Output/Results:
Experiment No . 5
Water flow sensor with an Arduino board.
AIM: use one water flow sensor with an Arduino board.
Components:
1. Arduino uno
2. Water flow sensor
3. 3 breadboard cables
Water flow Sensor:
The water flow sensor consists of a plastic valve body, a water rotor and a hall-effect sensor.
When the water flows through the rotor, rotor rolls and the speed of it changes with a different rate
of flow. The hall-effect sensor outputs the corresponding pulse signal.
This type of sensor can be found on different diameters, water pressure (MPa) and flow rate
(L/m) ranges. Make sure to select one that will cover your needs. The sensor that I have it has
20mm diameter, <1.75Mpa water pressure and ~30 L/m flow rate range.
In this, the serial monitor for printing the water flow rate in liters per hour and the total of liters
flowed since starting.
Press the connect button below to start the serial communication. Connect this sensor with your
water tap, or just blow on it.
Circuit Diagram:
Arduino Code:
byte statusLed = 13;
byte sensorInterrupt = 0;
byte sensorPin = 2;
float calibrationFactor = 4.5;
volatile byte pulseCount;
float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
unsigned long oldTime;
void setup()
{
Serial.begin(9600);
pinMode(statusLed, OUTPUT);
digitalWrite(statusLed, HIGH);
pinMode(sensorPin, INPUT);
digitalWrite(sensorPin, HIGH);
pulseCount = 0;
flowRate = 0.0;
flowMilliLitres = 0;
totalMilliLitres = 0;
oldTime = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
void loop()
{
if((millis() - oldTime) > 1000)
{
detachInterrupt(sensorInterrupt);
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
oldTime = millis();
flowMilliLitres = (flowRate / 60) * 1000;
totalMilliLitres += flowMilliLitres;
unsigned int frac;
Serial.print("Flow rate: ");
Serial.print(int(flowRate));
Serial.print("L/min");
Serial.print("\t");
Serial.print("Output Liquid Quantity: ");
Serial.print(totalMilliLitres);
Serial.println("mL");
Serial.print("\t"); // Print tab space
Serial.print(totalMilliLitres/1000);
Serial.print("L");
pulseCount = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
}
void pulseCounter()
{
pulseCount++;
}
Result/Output:
Experiment No . 6
Ultrasonic Sensor with an Arduino board.
AIM: Measure distance using Ultrasonic sensor with an Arduino board.
Components:
1. Arduino uno
2. Ultrasonic Sensor HC-SR04
3. Male to female Jumper Wires
4. breadboard
Ultrasonic Sensor HC-SR04:
Ultrasonic Sensor HC-SR04 is a sensor that can measure distance. It emits
an ultrasound at 40 000 Hz (40kHz) which travels through the air and if there is an object or
obstacle on its path It will bounce back to the module. Considering the travel time and the
speed of the sound you can calculate the distance.
The configuration pin of HC-SR04 is VCC (1), TRIG (2), ECHO (3), and GND (4).
The supply voltage of VCC is +5V and you can attach TRIG and ECHO pin to any Digital
I/O in your Arduino Board.
Connection Diagram:
The connection of Arduino and Ultrasonic Sensor HC-SR04
1. Connect the circuit as shown in the picture.
2. Open Arduino IDE Software and write down the code.
3. Choose Arduino board (in this case Arduino Uno), by
selecting Tools > Board > Arduino/Geniuno Uno
4. Choose COM Port (usually it appears only one existing port),
Tools > Port > COM.. (If there are more than one ports, try it one by one)
5. Sketch > Upload
6. To display the measurement data in Serial Monitor
Arduino Code:
// defines pins numbers
const int trigPin = 9;
const int echoPin = 10;
// defines variables
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
}
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
}
Results:
Experiment No.7: LED Blinking
AIM: Blinking of LED Using Rasbperry Pi.
List of components:
a. 1 - Raspberry Pi device with a 5 V power supply.
b. 1 - Bread Board
c. 1 - Male to Female jumper cable
d. 1 – LED
Connection Diagram:
Connection Procedure:
1. Firstly, connect the GPIO pin ‘8’ to the bread board through jumper cable.
2. Now take LED and put it on the bread board. Connect the plus terminal of LED to the Jumper
cable coming from the GPIO Pin “8”.
3. Now take another jumper cable, connect it to the GPIO pin “Ground” and another terminal of
this wire to minus terminal of the LED.
4. Now write the python program for blinking LED every 1 second.
5. Now run the program and observe output in Blinking of LED.
Python Code:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(8, GPIO.OUT)
while True:
GPIO.output(8, True)
time.sleep(1)
GPIO.output(8, False)
time.sleep(1)
Output/Result:
Experiment No . 8
Traffic Light Simulator.
AIM: Simulate a traffic light using an Raspberry Pi and LED’s.
Components:
S.No Component Quantity
1. Raspberry Pi 1Nos
2. LED (Red, Yellow & Green) 3Nos
3. Bread Board 1Nos
4. Male to female connectors 4Nos
5. 100ohm resistor 3Nos
Connection Diagram:
Procedure:
1. To get started, you’ll need to place all the components on the breadboard and connect
them to the appropriate GPIO pins on the Raspberry Pi.
2. An LED requires 1 ground pin and 1 GPIO pin, with a current limiting resistor.
3. Each component requires its own individual GPIO pin, but components can share a
ground pin.
4. Place the components on the breadboard and connect them to the Raspberry Pi GPIO
pins, according to the following diagram:
5. Note that the row along the long side of the breadboard is connected to a ground pin on
the Raspberry Pi, so all the components in that row (which is used as a ground rail) are
hence connected to ground.
Python code:
from gpiozero import LED
from time import sleep
red=LED(22)
blue=LED(27)
green=LED(17)
while True:
red. on()
sleep (1)
blue. on()
sleep (1)
green. on()
sleep (1)
red.off()
sleep (1)
blue. off()
sleep (1)
green. off()
sleep(1)
Output/Results:
Experiment No . 9
Interface a PIR Motion Sensor With Raspberry Pi
AIM: To Interface a PIR Motion Sensor With Raspberry Pi GPIO.
Components:
S.No Component Quantity
1. Raspberry Pi 1Nos
2. PIR Sensor 1Nos
3. Bread Board 1Nos
4. Male to female and Male to male connectors 4Nos
5. LED 1Nos
Connection Diagram:
Here, we are using a PIR motion sensor. PIR stands for passive infrared. This motion sensor
consists of a fresnel lens, an infrared detector, and supporting detection circuitry. The lens on the
sensor focuses any infrared radiation present around it toward the infrared detector. Our bodies
generate infrared heat, and as a result, this heat is picked up by the motion sensor. The sensor
outputs a 5V signal for a period of one minute as soon as it detects the presence of a person. It
offers a tentative range of detection of about 6–7 meters and is highly sensitive. When the PIR
motion sensor detects a person, it outputs a 5V signal to the Raspberry Pi through its GPIO and
define what the Raspberry Pi should do as it detects an intruder through the Python coding. Here
we are just printing "Intruder detected".
Procedure:
1. Connect the PIR sensor's pin labelled VCC to the 5V pin on the Raspberry Pi. This provides
power to the PIR sensor.
2. Connect the one labelled GND to a ground pin on the Pi (also labelled GND). This
completes the circuit.
3. Connect the one labelled OUT to any numbered GPIO pin on the Pi.
Python Code:
Import RPi.GPIO as GPIO
import time
GPIO.setmode (GPIO. BOARD)
GPIO.setup(11, GPIO. IN) #Read output from
GPIO.setup(3, GPIO.OUT) #LED output pin
while True:
i=GPIO.input (11)
If i==0: #When output from motion sensor
print ("No intruders", i)
GPIO.output(3, 0) #Turn OFF LED
time.sleep(0.1)
elif i==1:
print ("Intruder detected",I) #When output from motion .
GPIO output (3, 1) #Turn ON LED
time.sleep (0.1)
Output/Results:
Output/Results: