047 Iotdeepanshi
047 Iotdeepanshi
(Affiliated to)
MCA, 3rd semester under my supervision during the academic year 2023-2025.
acted as pillars to help my way throughout the execution of lab exercises that has
I feel great sense of gratitude for Ms. Suman Singh under whose guidance and
I would also like to express my thanks to all lab assistants for giving me
opportunity to work under their esteemed guidance. This project would not have
subjects.
The Internet of Things (IoT) toolkit contains various components that enable the creation
of interconnected devices.
1. Jumper Wires
Types:
• Male-to-Male
• Male-to-Female
• Female-to-Female
Usage: They help transfer signals and power between components without the need for
soldering. In IoT projects, jumper wires connect sensors to microcontrollers like Arduino
or Raspberry Pi.
2. Breadboard
Structure:
• Consists of many small holes into which electronic components can be inserted.
• The holes are electrically connected in rows and columns.
Usage: Breadboards are commonly used in IoT projects for testing and prototyping
circuits involving sensors, actuators, and microcontrollers. You can easily rearrange and
modify your circuit by plugging in or removing components.
04750404423 1 Deepanshi
3. Sensors
Function: Sensors detect and measure physical conditions (e.g., temperature, humidity,
light, motion) and convert them into electrical signals.
Types:
4. Actuators
Function: Actuators are devices that receive signals from the microcontroller and perform
a physical action, such as moving, heating, or emitting light.
Types:
• Servo Motors: Provide precise control of angular or linear position, velocity, and
acceleration. Used in robotics and smart home applications like automatic doors.
• DC Motors: Convert electrical energy into mechanical movement. Common in IoT
systems for creating moving parts or fans.
• LEDs: Emit light when powered. Used in IoT systems for indicators or smart
lighting.
• Buzzers: Produce sound or alarm when activated. Used in alarm systems.
04750404423 2 Deepanshi
• Relay Modules: Act as electrical switches, allowing IoT devices to control higher
power devices like home appliances.
04750404423 3 Deepanshi
EXPERIMENT 2
AIM: To understand the Arduino Board architecture and Raspberry Pi pin diagram and
architecture.
Arduino UNO
04750404423 4 Deepanshi
3. Power LED Indicator- The ON status of LED shows the power is activated. When the
power is OFF, the LED will not light up.
4. Digital I/O pins- The digital pins have the value HIGH or LOW. The pins numbered
from D0 to D13 are digital pins.
5. TX and RX LED's- The successful flow of data is represented by the lighting of these
LED's.
6. AREF- The Analog Reference (AREF) pin is used to feed a reference voltage to the
Arduino UNO board from the external power supply.
7. Reset button- It is used to add a Reset button to the connection.
8. USB- It allows the board to connect to the computer. It is essential for the
programming of the Arduino UNO board.
9. Crystal Oscillator- The Crystal oscillator has a frequency of 16MHz, which makes the
Arduino UNO a powerful board.
10. Voltage Regulator- The voltage regulator converts the input voltage to 5V.
11. GND- Ground pins. The ground pin acts as a pin with zero voltage.
12. Vin- It is the input voltage.
13. Analog Pins- The pins numbered from A0 to A5 are analog pins. The function of Analog
pins is to read the analog sensor used in the connection. It can also act as GPIO
(General Purpose Input Output) pins.
Raspberry Pi
04750404423 5 Deepanshi
Raspberry Pi mainly consists of the following blocks:
04750404423 6 Deepanshi
AIM:
EXPERIMENT 3
To understand the basic of Arduino IDE programming and Install IDE of Arduino.
For Windows:
• Open the Arduino IDE from your applications menu or desktop shortcut
04750404423 7 Deepanshi
• Connect your Arduino board to your computer via USB
• Select your board type from Tools > Board
• Select the correct port from Tools > Port
• Open an example sketch: File > Examples > 01. Basics > Blink
• Click the Upload button (right arrow icon) to compile and upload the sketch to
your board
Important Concepts:
a) Sketch structure:
b) Common functions:
• pinMode(): Sets a pin as input or output
• digitalWrite(): Writes a HIGH or LOW value to a digital pin
• digitalRead(): Reads the value from a digital pin
• analogRead(): Reads the value from an analog pin • analogWrite(): Writes an
analog value to a pin
d) Control structures:
04750404423 8 Deepanshi
AIM:
EXPERIMENT 4
Write steps to write program in Arduino and add libraries in Arduino and setup of
Arduino IDE for programming.
• void setup(): This function runs once when the board is powered on or reset.
It is used to initialize settings (e.g., pin modes).
• void loop(): This function runs continuously and contains the main logic of the
program.
04750404423 9 Deepanshi
• In the editor window, write your code. For example, to blink an LED, the code
would look like:
void setup() {
pinMode(13, OUTPUT); // Set pin 13 as an output
} void
loop() {
digitalWrite(13, HIGH); // Turn the LED on
delay(1000); // Wait for 1 second
digitalWrite(13, LOW); // Turn the LED off
delay(1000); // Wait for 1 second }
• After writing the code, click the Verify button (✓) at the top of the Arduino IDE.
This checks for any syntax errors in the code.
• Once the code is verified, click the Upload button (→) to upload the code to the
Arduino board. The board will run the program immediately after the upload.
• In the Arduino IDE, go to Sketch > Include Library > Manage Libraries...
• In the Library Manager window, use the search bar to find the library you need
(e.g., "Adafruit Sensor").
• Once you find the desired library, click Install. After installation, the library will
be available for use in your sketches.
• To use the library in your program, include it at the beginning of your code with
the #include statement. For example:
04750404423 10 Deepanshi
AIM:
#include <Adafruit_Sensor.h>
EXPERIMENT 5
Write a Program using Arduino for Blink LED.
Materials Required:
Steps:
1. Circuit Setup:
o Connect the longer leg (anode) of the LED to digital pin 13 on the Arduino.
o Connect the shorter leg (cathode) to one end of a resistor.
o Connect the other end of the resistor to the GND pin on the Arduino.
2. Program to Blink the LED:
Open the Arduino IDE and write the following program:
void setup() {
// Initialize digital pin 13 as an output
pinMode(13, OUTPUT);
}
void loop() {
// Turn the LED on (HIGH voltage)
digitalWrite(13, HIGH);
delay(1000); // Wait for 1 second
// Turn the LED off (LOW voltage)
digitalWrite(13, LOW);
delay(1000); // Wait for 1 second
}
04750404423 11 Deepanshi
EXPERIMENT 6
AIM: To Demonstrate Autodesk Tinkercad Simulation Platform.
Autodesk Tinkercad is a free online 3D design and modeling tool that is widely used for
creating 3D models, circuits, and simulations. Tinkercad offers an easy-to-use interface
and is particularly useful for beginners and educators to prototype electronics and
develop Arduino projects without the need for physical components.
1. Circuit Design: Allows users to create and simulate electronic circuits using virtual
components like resistors, LEDs, sensors, and microcontrollers.
2. Arduino Simulation: Users can write and test Arduino code in a simulated
environment, providing instant feedback without needing physical hardware.
3. 3D Design: Users can create 3D models and print them with 3D printers or use
them in other applications.
4. User-Friendly Interface: Intuitive drag-and-drop functionality makes it easy for
beginners to get started with electronics and 3D design.
04750404423 12 Deepanshi
AIM:
04750404423 13 Deepanshi
1. Accessing Tinkercad:
a. Adding Components:
o In the components panel on the right, search for and drag the following
components onto the work area:
• Arduino Uno
• LED
• Resistor (220Ω)
• Breadboard (optional for organization) • Jumper Wires
b. Connecting Components:
o Connect the components as follows:
• Connect the long leg (anode) of the LED to digital pin 13 of the
Arduino.
• Connect the short leg (cathode) of the LED to one end of the resistor.
• Connect the other end of the resistor to the GND of the Arduino. c.
Wiring Example: o The circuit should resemble a basic LED blink
circuit.
04750404423 14 Deepanshi
2. Write Arduino Code:
o Use the following code to blink the LED:
EXPERIMENT 7
AIM: Controlling the Light Emitting Diode (LED) with a push button.
Materials Required:
Circuit Setup:
a. Connect the LED:
04750404423 15 Deepanshi
o Connect the longer leg (anode) of the LED to digital pin 9 on the Arduino.
o Connect the shorter leg (cathode) of the LED to one end of the 220Ω
resistor.
o Connect the other end of the resistor to the GND pin on the Arduino.
b. Connect the Push Button:
o Place the push button on the breadboard.
o Connect one terminal of the push button to digital pin 7 on the Arduino. o
Connect the other terminal of the push button to the GND pin on the
Arduino.
o (Optional) Connect a 10kΩ resistor from the same terminal (connected to
pin 7) to the +5V rail to create a pull-up configuration. This keeps the pin
HIGH when the button is not pressed.
// Pin Definitions
const int ledPin = 2; // LED connected to digital pin 9 const
int buttonPin = 3; // Push button connected to digital pin 7
void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as output
pinMode(buttonPin, INPUT); // Set the button pin as input
} void
loop() {
buttonState = digitalRead(buttonPin); // Read the state of the push
button
04750404423 16 Deepanshi
EXPERIMENT 8
AIM: Measure the Distance Using Ultrasonic Sensor and Make Led Blink Using Arduino
Materials Required:
Circuit Setup:
Circuit Diagram:
04750404423 17 Deepanshi
o Anode → Digital Pin 13
#include <LiquidCrystal.h>
const int trigPin =
11; const int echoPin =
10;
long duration; int distance;
bool measured = false; int
maxReferenceHeight = 500; int
referenceHeight; int
maxHeight = 220; int
minHeight = 30;
const int rsPin = 2;
const int enablePin = 3;
const int data_4 = 4;
const int data_5 = 5;
const int data_6 = 6;
const int data_7 = 7;
04750404423 18 Deepanshi
int distanceMeasured(){
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH); // Calculating the distance
distance = duration*0.034/2; Serial.print("Distance: ");
Serial.println(distance);
return distance;
}
void printDistanceToLCD(int distance){
lcd.setCursor(0, 1);
lcd.print("Height : ");
lcd.print(distance); lcd.print("
cm");
} void lcdInitialAlert(){
lcd.clear(); lcd.setCursor(0,
0); lcd.print("Ready To
Measure"); delay(2000);
}
EXPERIMENT 9
AIM: Sense The Available Networks Using Arduino
To sense the available Wi-Fi networks using an Arduino, you can use an ESP8266 or
ESP32 microcontroller, which are Arduino-compatible and have built-in Wi-Fi
capabilities.
04750404423 19 Deepanshi
Hardware Required:
Steps:
3. Go to Tools > Board > Boards Manager and search for ESP8266 or ESP32, then
click Install.
4. Connect ESP8266/ESP32 to your computer.
void setup() {
Serial.begin(115200); // Start Serial communication for output
WiFi.mode(WIFI_STA); // Set WiFi mode to station (client)
WiFi.disconnect(); // Disconnect from any previous Wi-Fi delay(100);
if (numberOfNetworks == 0) {
Serial.println("No networks found.");
} else {
Serial.println("Networks found: "); for
(int i = 0; i < numberOfNetworks; i++) {
// Print SSID and signal strength
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (Signal strength: ");
Serial.print(WiFi.RSSI(i));
Serial.println(" dBm)"); delay(10);
}
}
}
void loop() {
04750404423 20 Deepanshi
}
• Select the correct board and port: Go to Tools > Board and choose the
appropriate ESP8266/ESP32 board, and select the correct port under Tools >
Port.
• Upload the sketch to the board.
• Open the Serial Monitor from Tools > Serial Monitor in Arduino IDE. Set the
baud rate to 115200 to see the available Wi-Fi networks along with their signal
strength.
EXPERIMENT 10
Aim: Write a program to blink multiple LEDs using: •
Without breadboard
• With breadboard.
Hardware Required:
04750404423 21 Deepanshi
• Arduino Uno or similar.
• Multiple LEDs (e.g., 3 LEDs).
• Resistors (220Ω or 330Ω) for each LED.
• Jumper wires.
Connections:
• LED Anode (+): Connect each LED's anode to a digital pin on the Arduino (e.g.,
pins 9, 10, 11).
• LED Cathode (-): Connect the cathode to a resistor, and the other end of the resistor
to GND.
Code:
04750404423 22 Deepanshi
With a Breadboard
Hardware Required:
Connections:
Code:
04750404423 23 Deepanshi
delay(500); // Wait for 500ms
digitalWrite(led1, LOW); // Turn LED 1 off
04750404423 24 Deepanshi
AIM:
EXPERIMENT 11
Interface DHT11 Sensor for temperature and humidity monitoring.
Hardware Required:
Circuit Connections:
1. Connect the VCC pin of the DHT11 to the 5V pin on the Arduino.
2. Connect the GND pin of the DHT11 to the GND of the Arduino.
3. Connect the Data pin of the DHT11 to digital pin 2 of the Arduino.
4. (Optional) Place a 10kΩ pull-up resistor between the Data pin and VCC to stabilize
the signal.
Code:
To use the DHT11, you need to install the DHT sensor library. Follow these steps:
#include "DHT.h"
void setup() {
Serial.begin(9600); dht.begin();
} void
loop() { //
Wait a few
seconds
04750404423 25 Deepanshi
between
measurements
delay(2000);
EXPERIMENT 12
Write a program to blink an LED based on input from a PIR motion sensor.
Hardware Required:
04750404423 26 Deepanshi
AIM:
• LED
• Resistor (220Ω or 330Ω)
• Jumper wires
• Breadboard (optional)
Circuit Connections:
1. PIR sensor:
o Connect the VCC pin of the PIR sensor to the 5V pin on the Arduino. o
Connect the GND pin of the PIR sensor to the GND of the Arduino.
o Connect the OUT pin of the PIR sensor to digital pin 2 of the Arduino.
2. LED:
o Connect the anode (+) of the LED to digital pin 13 of the Arduino. o
Connect the cathode (-) of the LED to a 220Ω resistor, and the other
end of the resistor to GND.
Code:
int pirPin = 2; // PIR sensor output pin connected to digital pin 2 int
ledPin = 13; // LED pin connected to digital pin 13
void setup()
{
pinMode(pirPin, INPUT); // Set PIR pin as input
pinMode(ledPin, OUTPUT); // Set LED pin as output
Serial.begin(9600); // Start the serial communication
} void
loop() {
int pirState = digitalRead(pirPin); // Read the state of the PIR sensor
04750404423 27 Deepanshi
}
delay(1000); // Wait for 1 second before checking the sensor again }
04750404423 28 Deepanshi
AIM:
EXPERIMENT 13
Interface Three LEDs with an Ultrasonic Sensor to display proximity-based actions.
Hardware Required:
Circuit Connections:
1. Ultrasonic Sensor:
o VCC to 5V on Arduino o GND to GND on Arduino
o Trig to digital pin 9 on Arduino o Echo to
digital pin 8 on Arduino
2. LEDs:
o Green LED:
▪ Anode (+) to digital pin 3
▪ Cathode (-) to GND (via a 220Ω resistor) o Yellow
LED:
▪ Anode (+) to digital pin 4
▪ Cathode (-) to GND (via a 220Ω resistor) o Red LED:
▪ Anode (+) to digital pin 5
▪ Cathode (-) to GND (via a 220Ω resistor)
Working Logic:
• Green LED: Lights up if the object is far (e.g., distance > 100 cm).
• Yellow LED: Lights up if the object is at a moderate distance (e.g., between 50 cm
and 100 cm).
• Red LED: Lights up if the object is close (e.g., distance < 50 cm). Code:
04750404423 29 Deepanshi
LED pin const int redLED = 5; // Red LED pin long duration; int
distance;
void setup() {
pinMode(trigPin, OUTPUT); // Set trigPin as output
pinMode(echoPin, INPUT); // Set echoPin as input pinMode(greenLED,
OUTPUT); // Set green LED as output pinMode(yellowLED, OUTPUT);//
Set yellow LED as output pinMode(redLED, OUTPUT); // Set red LED
as output Serial.begin(9600); // Start the serial
communication
}
void loop() { // Clear the
trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Send a 10 microsecond pulse to trigger the sensor
digitalWrite(trigPin, HIGH); delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Proximity-based actions
if (distance > 100) {
digitalWrite(greenLED, HIGH); // Object is far
digitalWrite(yellowLED, LOW); digitalWrite(redLED,
LOW);
}
else if (distance <= 100 && distance > 50) {
digitalWrite(greenLED, LOW);
digitalWrite(yellowLED, HIGH); // Object is moderately close
digitalWrite(redLED, LOW);
}
else if (distance <= 50) {
digitalWrite(greenLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(redLED, HIGH); // Object is very close
}
delay(500); // Wait for 500ms before the next measurement
}
04750404423 30 Deepanshi
EXPERIMENT 14
AIM: Write down the steps to demonstrate the setup of Blynk app using Node MCU
(ESP8266).
Here’re the following steps to demonstrate the setup of Blynk app using Node MCU -: a)
04750404423 31 Deepanshi
b) Login and Create an Account if you don’t have one.
04750404423 32 Deepanshi
d) A template ID and Template name will be generated
04750404423 33 Deepanshi
f) Now create a Web dashboard from tab & Add widget from widget box by drag & drop
g) Now go to Setting of Widget added and set the datastream to that and save
h) Final Layout
04750404423 34 Deepanshi
04750404423 35 Deepanshi
EXPERIMENT 15
AIM: Write a program for controlling LED on/off using Blynk app.
Here’s a simple Arduino program that demonstrates how to control an LED using the
Blynk app and NodeMCU (ESP8266). The program will allow you to toggle an LED on or
off from your smartphone through the Blynk app.
Hardware Required:
• NodeMCU (ESP8266)
• LED
• Resistor (220Ω)
• Breadboard and jumper wires (optional)
Circuit Connections:
1. LED:
o Anode (long leg) connected to D2 (GPIO4) on NodeMCU.
o Cathode (short leg) connected to GND via a 220Ω resistor.
Steps:
Code:
04750404423 36 Deepanshi
}
else
{ digitalWrite(D1, LOW);
}
}
How to Test:
04750404423 37 Deepanshi