2024-25 Sem-II IoTL Lab Manual copy
2024-25 Sem-II IoTL Lab Manual copy
LAB MANUAL
ACADEMIC YEAR: 2024-2025
DEPT: ARTIFICIAL INTELLIGENCE & DATA SCIENCE
CLASS: S.E. SEMESTER: II
SUBJECT: 217531- INTERNET OF THINGS LABORATORY
CO-PO Mapping
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
CO1 2 1 3 - - - - - - - - -
CO2 - 2 3 - - - - - - - - -
CO3 - - 3 2 - - - - - - - 3
AVG 2 1.5 3 2 - - - - - - - 3
P:F-LTL-UG / 03 /R0
Sr. PROBLEM STATEMENTS
No.
Group A
1. Study of Raspberry-Pi/ Beagle board/ Arduino and other microcontroller ( History &
Elevation)
2. Study of different operating systems for Raspberry-Pi /Beagle board/Arduino.
Understanding the process of OS installation
3. Study of different GATES (AND, OR, XOR), Sensors and basic binary operations.
6. Create a program that illuminates the green LED if the counter is less than 100,
illuminates the yellow LED if the counter is between 101 and 200 and illuminates the
red LED if the counter is greater than 200
7. Create a program so that when the user enters ‘b’ the green light blinks, ‘g’ the green
light is illuminated ‘y’ the yellow light is illuminated and ‘r’ the red light is
illuminated
8. Write a program that asks the user for a number and outputs the number squared that
is entered.
9. Write a program to control the color of the LED by turning 3 different
potentiometers. One will be read for the value of Red, one for the value of Green, and
one for the value of Blue.
10. Write a program read the temperature sensor and send the values to the serial monitor
on the computer.
11. Write a program so it displays the temperature in Fahrenheit as well as the maximum
and minimum temperatures it has seen.
12. Write a program to show the temperature and shows a graph of the recent
measurements.
13. Understanding the connectivity of Raspberry-Pi /Beagle board circuit / Arduino with
IR sensor. Write an application to detect obstacle and notify user using LEDs.
Group C
14. Write an application to control the operation of hardware simulated traffic signals.
(Mini project)
15. Write an application for stopwatch or countdown timer. (Mini project)
P:F-LTL-UG / 03 /R0 2
GROUP A
P:F-LTL-UG / 03 /R0 3
Assignment No. 1
Aim Study of Raspberry-Pi/ Beagle board/ Arduino and other microcontrollers.
Objective To understand the history, evolution, and applications of various
microcontrollers, specifically Raspberry Pi, Beagle Board, and Arduino.
Outcome 1.Students will gain a comprehensive understanding of the history and
evolution of Raspberry Pi, Beagle Board, and Arduino.
2.Students will be able to compare and contrast the features and applications
of these microcontrollers.
3.Students will develop presentation skills and the ability to communicate
technical information effectively.
Materials Needed 1.Raspberry Pi (any model) OR Beagle Board (any model) OR Arduino (e.g.,
Arduino Uno)
2.Documentation and datasheets for each microcontroller
3.Internet access for research
4.Presentation software (e.g., PowerPoint, Google Slides)
Procedure Research and Gather Information:
• Raspberry Pi:
Investigate the history of Raspberry Pi, including its inception in 2012
by the Raspberry Pi Foundation.
Explore its evolution through various models (e.g., Raspberry Pi 1, 2,
3, 4).
Identify key features such as GPIO pins, USB ports, HDMI output,
and its use in education and projects.
• Beagle Board:
Research the Beagle Board's introduction in 2008 and its purpose as
an open-source hardware platform.
Examine different versions (e.g., BeagleBone, BeagleBoard-xM) and
their specifications.
Discuss its applications in robotics, IoT, and embedded systems.
• Arduino:
Study the Arduino platform's launch in 2005 and its role in making
electronics accessible to beginners.
Review various Arduino boards (e.g., Arduino Uno, Mega, Nano) and
their features.
Highlight its use in DIY projects, prototyping, and education.
P:F-LTL-UG / 03 /R0 4
Applications in IoT:
• Raspberry Pi: Used for home automation, media centers, and as a web
server.
• Beagle Board: Employed in robotics, industrial automation, and sensor
networks.
• Arduino:Commonly used in sensor-based projects,
wearable technology, and simple automation tasks.
Prepare a Presentation:
• Compile the research findings into a presentation format.
• Include visuals such as images of each microcontroller, diagrams of their
architecture, and examples of projects.
• Prepare to present the findings to the class, highlighting the unique
features and applications of each microcontroller.
Documentation • Prepare a report summarizing the research findings, comparative
analysis, and applications discussed.
• Include references to all sources used for research, such as websites,
articles, and datasheets.
2. Beagle Board
• Official BeagleBoard Documentation:
https://www.beagleboard.org/projects/documentation
This site provides comprehensive information on various BeagleBoard
models, including setup guides and tutorials.
3. Arduino
• Official Arduino Documentation: https://www.arduino.cc/
• Additional Resources: https://wokwi.com/arduino
P:F-LTL-UG / 03 /R0 5
Conclusion In this experiment, I explored the fundamental aspects of three prominent
microcontroller platforms: Raspberry Pi, Beagle Board, and Arduino.
Through comprehensive research and analysis, I gained insights into their
historical development, technical specifications, and diverse applications in
the field of Internet of Things (IoT) and embedded systems.
• Raspberry Pi:
• Beagle Board:
• Arduino:
P:F-LTL-UG / 03 /R0 6
Assignment No. 2
Aim Study of different operating systems for Raspberry-Pi /Beagle-board /
Arduino. Understanding the process of OS installation
Objective • To explore various operating systems compatible with Raspberry Pi,
Beagle Board, and Arduino.
• To understand the installation process of different operating systems
on these platforms.
• To learn about the features and functionalities of each operating
system.
• To gain hands-on experience in setting up and configuring an
operating system on a microcontroller or single-board computer.
Outcome Upon completion of this lab, students will be able to:
• Identify and differentiate between various operating systems suitable
for Raspberry Pi, Beagle Board, and Arduino.
• Successfully install an operating system on a Raspberry Pi or Beagle
Board.
• Understand the basic configuration and setup of the installed
operating system.
• Access and utilize the features of the operating system for
development purposes.
Materials Needed • Raspberry Pi (any model, e.g., Raspberry Pi 4)
• Beagle Board (e.g., BeagleBone Black)
• Arduino board (e.g., Arduino Uno, Arduino Nano)
• MicroSD card (at least 8GB for Raspberry Pi and Beagle Board)
• USB power supply for Raspberry Pi/Beagle Board
• USB cable for Arduino
• Computer with internet access
• HDMI cable (for Raspberry Pi/Beagle Board)
• Monitor or display
• Keyboard and mouse (for Raspberry Pi/Beagle Board)
Procedure 1. Research Operating Systems
Raspberry Pi: Explore Raspbian (now Raspberry Pi OS), Ubuntu
Mate, and other distributions.
Beagle Board: Investigate Debian, Ubuntu, and Angstrom.
Arduino: Understand that Arduino typically runs a simple firmware
rather than a full OS.
2. Download OS Images
Visit the official websites to download the latest OS images:
Raspberry Pi OS: Raspberry Pi Downloads
Beagle Board: BeagleBoard Downloads
Arduino: No OS installation is required, but download the
Arduino IDE from Arduino Software.
3. Prepare the MicroSD Card
P:F-LTL-UG / 03 /R0 7
Insert the MicroSD card into your computer.
Use Etcher or Win32 Disk Imager to flash the downloaded OS image
onto the MicroSD card:
Open the flashing software.
Select the OS image file.
Choose the MicroSD card as the target.
Click "Flash" to start the process.
4. Install the Operating System
For Raspberry Pi:
Insert the flashed MicroSD card into the Raspberry Pi.
Connect the monitor, keyboard, and mouse.
Power on the Raspberry Pi.
Follow the on-screen instructions to complete the setup (e.g.,
setting up Wi-Fi, updating software).
For Beagle Board:
Insert the flashed MicroSD card into the Beagle Board.
Connect the monitor, keyboard, and mouse.
Power on the Beagle Board.
Follow the on-screen instructions to complete the setup.
5. Explore the Operating System
Familiarize yourself with the desktop environment, terminal
commands, and package management.
For Raspberry Pi, explore the Raspberry Pi Configuration tool.
For Beagle Board, explore the Debian or Ubuntu desktop
environment.
6. Document the Process
Take notes on the installation steps, any challenges faced, and how
they were resolved.
Documentation Include datasheets for the Raspberry Pi, Beagle Board, and Arduino in your
and Datasheets report. These can typically be found on the official websites:
for Raspberry Pi Datasheet: Raspberry Pi Documentation
Microcontrollers Beagle Board Datasheet: BeagleBoard Documentation
Arduino Datasheet: Arduino Documentation
P:F-LTL-UG / 03 /R0 8
Conclusion In this lab, we gained valuable insights into the various operating systems
available for Raspberry Pi, Beagle Board, and Arduino. We learned the
installation processes, explored the features of each operating system, and
developed practical skills in configuring and utilizing these platforms for
their projects. The hands-on experience provided a deeper understanding
of how different operating systems can enhance the functionality of
microcontrollers and single-board computers, paving the way for future
exploration in the field of embedded systems and IoT applications.
P:F-LTL-UG / 03 /R0 9
Assignment No. 3
Aim Study of different GATES (AND, OR, XOR), Sensors and basic binary
operations
Objective To understand the functionality and applications of basic logic gates
(AND, OR) and derived gates (XOR, XNOR).
To explore universal gates (NAND, NOR) and their significance in
digital circuits.
To learn about various sensors and their applications in conjunction
with logic gates.
To perform basic binary operations using logic gates.
P:F-LTL-UG / 03 /R0 10
Description 1. Logic Gates
Logic gates are fundamental building blocks of digital circuits. They are used
to perform logical operations based on one or more binary inputs, producing
a single output.
1.1 AND Gate
• Symbol: .
• Truth Table:
A B Output
0 0 0
0 1 0
1 0 0
1 1 1
1.2 OR Gate
• Symbol: +
• Truth Table:
A B Output
0 0 0
0 1 1
1 0 1
P:F-LTL-UG / 03 /R0 11
1 1 1
A B Output
0 0 0
0 1 1
1 0 1
1 1 0
A B Output
0 0 1
0 1 1
1 0 1
1 1 0
P:F-LTL-UG / 03 /R0 12
• Truth Table:
A B Output
0 0 1
0 1 0
1 0 0
1 1 0
A Output
0 1
1 0
P:F-LTL-UG / 03 /R0 13
A B Output
0 0 0
0 1 1
1 0 1
1 1 0
2. Sensors
P:F-LTL-UG / 03 /R0 14
Sensors are devices that detect and measure physical phenomena and convert
them into a readable electrical signal. Below are the sensors included in the
report:
2.1 Temperature Sensor
• Example: LM35
• Working Principle: LM35 is an analog temperature sensor that
provides an output voltage linearly proportional to the centigrade
temperature.
P:F-LTL-UG / 03 /R0 15
• Applications: Temperature control systems, weather stations, HVAC
systems.
P:F-LTL-UG / 03 /R0 16
3. Basic Binary Operations
Binary arithmetic operations are fundamental to digital systems, and they
form the basis for all complex digital computations. The basic operations
include:
3.1 Binary Addition
• Example:
• 1+1=101 + 1 = 10 (carry over)
• 1+0=11 + 0 = 1
• 0+0=00 + 0 = 0
3.2 Binary Subtraction
• Example:
• 1−1=01 - 1 = 0
• 1−0=11 - 0 = 1
• 0−1=10 - 1 = 1 (borrow)
3.3 Binary Multiplication
• Example:
• 1×1=11 \times 1 = 1
• 1×0=01 \times 0 = 0
• 0×0=00 \times 0 = 0
3.4 Binary Division
• Example:
• 10÷2=510 \div 2 = 5 (binary calculation)
These operations are implemented in digital circuits using combinations of
P:F-LTL-UG / 03 /R0 17
AND, OR, XOR, and NOT gates.
Documentation
Documentation
and Datasheets
for
Microcontrollers
Conclusion
P:F-LTL-UG / 03 /R0 18
Assignment No. 4
Aim Study of Connectivity and configuration of Raspberry-Pi /Beagle
board/Arduino circuit with basic peripherals like LEDS. Understanding
GPIO and its use in the program.
Objective
Outcome
Materials Needed
Procedure
Documentation
Documentation
and Datasheets
for
Microcontrollers
Conclusion
P:F-LTL-UG / 03 /R0 19
GROUP B
P:F-LTL-UG / 03 /R0 20
Assignment No. 5
Aim Write a program using Arduino to control LED (One or more ON/OFF). Or
Blinking
Objective To understand the basic principles of controlling LEDs using
Arduino.
To learn how to write and upload code to an Arduino board.
To gain hands-on experience with circuit design and implementation.
Outcome Upon completion of this assignment, students will be able to:
Control LEDs using Arduino.
Write and upload Arduino code to perform specific tasks (ON/OFF or
blinking).
Understand the basic components of an electronic circuit involving
LEDs.
Software Arduino IDE (Integrated Development Environment)
Requirements
Hardware Arduino board (e.g., Arduino Uno)
Requirements One or more LEDs (e.g., Red, Green, Blue)
Resistors (220Ω or 330Ω for each LED)
Breadboard
Jumper wires
Power supply (if not using USB)
Procedure 1. Connect the longer leg (anode) of each LED to one end of a resistor.
2. Connect the other end of the resistor to a digital pin on the Arduino
(e.g., Pin 9 for LED1, Pin 10 for LED2).
3. Connect the shorter leg (cathode) of each LED to the ground (GND)
pin on the Arduino.
4. Ensure that the Arduino is powered either through USB or an
external power supply.
Code // Define pin numbers for the LEDs
const int led1 = 9; // LED 1 connected to digital pin 9
const int led2 = 10; // LED 2 connected to digital pin 10
void setup() {
// Initialize the digital pins as outputs
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop() {
// Turn LED 1 ON and LED 2 OFF
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
P:F-LTL-UG / 03 /R0 21
delay(1000); // Wait for 1 second
P:F-LTL-UG / 03 /R0 22
Assignment No. 6
Aim Create a program that illuminates the green LED if the counter is less than 100,
illuminates the yellow LED if the counter is between 101 and 200 and
illuminates the red LED if the counter is greater than 200
Objective To understand the basic principles of controlling LEDs using
Arduino.
To learn how to write and upload code to an Arduino board.
To gain hands-on experience with circuit design and implementation.
Outcome Upon completion of this assignment, students will be able to:
Control LEDs using Arduino.
Write and upload Arduino code to perform specific tasks (ON/OFF or
blinking).
Understand the basic components of an electronic circuit involving
LEDs.
Software Arduino IDE (Integrated Development Environment)
Requirements
Hardware Arduino board (e.g., Arduino Uno)
Requirements 3 LEDs (Green, Yellow, Red)
3 Resistors (220Ω or 330Ω for each LED)
Breadboard
Jumper wires
Procedure 1. Green LED:
1.1 Connect the anode (longer leg) of the Green LED to digital pin 9
through a resistor (220Ω or 330Ω).
1.2 Connect the cathode (shorter leg) of the Green LED directly to
the ground (GND) pin on the Arduino.
2. Yellow LED:
2.1 Connect the anode of the Yellow LED to digital pin 10 through a
resistor.
2.2 Connect the cathode of the Yellow LED directly to the ground.
3. Red LED:
3.1 Connect the anode of the Red LED to digital pin 11 through a
resistor.
3.2 Connect the cathode of the Red LED directly to the ground.
Code // Define pin numbers for the LEDs
const int greenLED = 11; // Green LED connected to digital pin 11
const int yellowLED = 9; // Yellow LED connected to digital pin 9
const int redLED = 6; // Red LED connected to digital pin 6
// Counter variable
int counter = 0;
P:F-LTL-UG / 03 /R0 23
void setup() {
// Initialize the digital pins as outputs
pinMode(greenLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(redLED, OUTPUT);
// Start the Serial communication
Serial.begin(9600); // Set the baud rate to 9600
}
void loop() {
// Increment the counter
counter++;
// Check the value of the counter and illuminate the appropriate LED
if (counter < 100) {
digitalWrite(greenLED, HIGH); // Turn on Green LED
digitalWrite(yellowLED, LOW); // Turn off Yellow LED
digitalWrite(redLED, LOW); // Turn off Red LED
}
else if (counter >= 100 && counter <= 200) {
digitalWrite(greenLED, LOW); // Turn off Green LED
digitalWrite(yellowLED, HIGH); // Turn on Yellow LED
digitalWrite(redLED, LOW); // Turn off Red LED
}
else if (counter >200 && counter <=300) {
digitalWrite(greenLED, LOW); // Turn off Green LED
digitalWrite(yellowLED, LOW); // Turn off Yellow LED
digitalWrite(redLED, HIGH); // Turn on Red LED
}
else {
counter = 0; // Resetting counter variable
}
P:F-LTL-UG / 03 /R0 24
Simulation
Output
P:F-LTL-UG / 03 /R0 25
Assignment No. 7
Aim Create a program so that when the user enters ‘b’ the green light blinks, ‘g’ the
green light is illuminated ‘y’ the yellow light is illuminated and ‘r’ the red light
is illuminated
Objective To understand the basic principles of controlling LEDs using
Arduino.
To learn how to write and upload code to an Arduino board.
To gain hands-on experience with circuit design and implementation.
Outcome Upon completion of this assignment, students will be able to:
Control LEDs using Arduino.
Write and upload Arduino code to perform specific tasks
Understand the basic components of an electronic circuit involving
LEDs.
// Counter variable
int counter = 0;
void setup() {
P:F-LTL-UG / 03 /R0 26
// Initialize the digital pins as outputs
pinMode(greenLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(redLED, OUTPUT);
// Start the Serial communication
Serial.begin(9600); // Set the baud rate to 9600
Serial.println("Enter 'b' to blink green LED, 'g' for green, 'y' for yellow, 'r'
for red.");
}
void loop() {
// Check if data is available to read
if (Serial.available() > 0) {
char input = Serial.read(); // Read the input character
default:
P:F-LTL-UG / 03 /R0 27
// Turn off all LEDs if an invalid character is entered
digitalWrite(greenLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(redLED, LOW);
break;
}
}
}
Simulation
Output
P:F-LTL-UG / 03 /R0 28
Assignment No. 8
Aim Write a program that asks the user for a number and outputs the number squared
that is entered.
Objective To understand how to interface an Arduino with a serial monitor.
To learn how to read user input from the serial port.
To perform basic arithmetic operations using Arduino.
To display the output back to the user through the serial monitor.
Outcome Upon completion of this assignment, students will be able to:
Write and upload a program to an Arduino board.
Use the serial monitor for input and output operations.
Understand basic programming concepts such as variables, data
types, and arithmetic operations.
void loop() {
P:F-LTL-UG / 03 /R0 29
// Check if data is available to read
if (Serial.available() > 0) {
// Read the input from the serial monitor
String input = Serial.readStringUntil('\n');
Conclusion In this lab, we successfully created a simple Arduino program that interacts
with the user through the serial monitor. By entering a number, the user can
see the squared value of that number displayed back to them. This exercise
not only reinforces basic programming concepts but also demonstrates how
to use Arduino for simple input and output operations, laying the
groundwork for more complex Internet of Things applications.
P:F-LTL-UG / 03 /R0 30
Assignment 9
No.
Aim Write a program to control the color of the LED by turning 3 different potentiometers.
One will be read for the value of Red, one for the value of Green, and one for the
value of Blue
Objective To understand how to interface potentiometers with an Arduino.
To learn how to control an RGB LED using PWM (Pulse Width
Modulation).
To explore the concept of analog input and output in Arduino.
To develop skills in reading analog values and mapping them to PWM
signals.
Outcome Upon completion of this assignment, students will be able to:
Interface multiple potentiometers with an Arduino.
Control the brightness of an RGB LED using PWM signals.
Understand how to read and process analog input values.
void setup() {
// Set the RGB LED pins as output
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
// Read the values from the potentiometers
int redValue = analogRead(potRedPin);
int greenValue = analogRead(potGreenPin);
int blueValue = analogRead(potBluePin);
P:F-LTL-UG / 03 /R0 32
Simulation
Output
Conclusion In this lab, we successfully created a program that allows them to control the color
of an RGB LED using three potentiometers. By adjusting the potentiometers, we
can manipulate the intensity of each color channel (Red, Green, and Blue),
resulting in a wide range of colors being displayed by the RGB LED. This exercise
enhances understanding of analog input and output, as well as the practical
application of PWM in controlling LED brightness, which is fundamental in
various Internet of Things projects.
P:F-LTL-UG / 03 /R0 33
Assignment No. 10
Aim Write a program read the temperature sensor and send the values to the serial
monitor on the computer.
Objective To understand how to interface a temperature sensor with an
Arduino.
To learn how to read analog values from a temperature sensor.
To display the temperature readings on the serial monitor.
To familiarize with the concept of serial communication in Arduino.
Outcome Upon completion of this assignment, students will be able to:
Interface a temperature sensor with an Arduino.
Read and process analog input values from the sensor.
Display real-time temperature readings on the serial monitor.
void setup() {
// Initialize serial communication at 9600 bits per second
Serial.begin(9600);
}
void loop() {
// Read the analog value from the temperature sensor
int sensorValue = analogRead(tempPin);
void setup() {
P:F-LTL-UG / 03 /R0 35
Serial.begin(9600); // Initialize serial communication
dht.begin(); // Initialize the DHT sensor
}
void loop() {
// Wait a few seconds between measurements
delay(2000);
// Check if any reads failed and exit early (to try again).
if (isnan(temperatureC) || isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
P:F-LTL-UG / 03 /R0 36
By Using DHT22
P:F-LTL-UG / 03 /R0 37
Conclusion In this lab, we successfully created a program that reads temperature sensor
values and displays them on the serial monitor. By interfacing with either an
LM35, TMP36, or DHT11/DHT22 sensor, we learned how to convert analog
readings into temperature values and communicate these readings via serial
communication. This exercise enhances understanding of sensor integration
and data visualization, which are essential skills in the field of Internet of
Things and embedded systems.
Assignment No. 11
Aim Write a program so it displays the temperature in Fahrenheit as well as the
maximum and minimum temperatures it has seen.
Objective To understand how to interface a temperature sensor with an
Arduino.
To learn how to read analog values from a temperature sensor.
To convert temperature readings from Celsius to Fahrenheit.
To keep track of the maximum and minimum temperature readings.
To display the temperature readings along with the maximum and
P:F-LTL-UG / 03 /R0 38
minimum values on the serial monitor.
void setup() {
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Read the analog value from the TMP36 sensor
int sensorValue = analogRead(tempPin);
P:F-LTL-UG / 03 /R0 40
// Wait a few seconds before the next reading
delay(2000);
}
void setup() {
Serial.begin(9600); // Initialize serial communication
dht.begin(); // Initialize the DHT sensor
}
void loop() {
// Wait a few seconds between measurements
delay(2000);
// Check if any reads failed and exit early (to try again).
if (isnan(temperatureC)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
P:F-LTL-UG / 03 /R0 41
}
P:F-LTL-UG / 03 /R0 42
By Using DHT22
Conclusion In this lab, we successfully created a program that reads temperature values
in Fahrenheit from both TMP36 (or TMP37) or DHT22 sensors, while also
tracking the maximum and minimum temperatures recorded. This exercise
enhances understanding of sensor integration, data conversion, and real-time
data monitoring, which are essential skills in the field of Internet of Things
and embedded systems.
P:F-LTL-UG / 03 /R0 43
Assignment No. 12
Aim Write a program to show the temperature and shows a graph of the recent
measurements.
Objective To read temperature and humidity values from a DHT22 sensor.
To visualize the temperature readings in real-time using the Serial
Plotter in the Arduino IDE.
Outcome Upon completion of this assignment, students will be able to:
Interface a DHT22 sensor with an Arduino.
Read and process digital input values from the sensor.
Use the Serial Plotter to visualize temperature data.
void setup() {
Serial.begin(9600); // Initialize serial communication
dht.begin(); // Initialize the DHT sensor
}
void loop() {
// Wait a few seconds between measurements
delay(2000);
// Check if any reads failed and exit early (to try again).
if (isnan(temperatureC)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
P:F-LTL-UG / 03 /R0 45
Simulation
Output
P:F-LTL-UG / 03 /R0 46
Output
P:F-LTL-UG / 03 /R0 47
Assignment No. 13
Aim Understanding the connectivity of Raspberry-Pi /Beagle board circuit / Arduino
with IR sensor. Write an application to detect obstacle and notify user using
LEDs.
Objective To learn how to interface an IR sensor with an Arduino.
To understand how to read digital signals from the IR sensor.
To implement a simple obstacle detection application that activates
LEDs based on sensor readings.
To gain hands-on experience in basic circuit design and programming
with Arduino.
Outcome Upon completion of this assignment, students will be able to:
Interface an IR sensor with an Arduino.
Read and process digital input values from the IR sensor.
Control LEDs based on sensor readings to indicate the presence of
obstacles.
Software • Arduino IDE (version 1.8.0 or later)
Requirements
Hardware Arduino board (e.g., Arduino Uno, Arduino Nano)
Requirements IR sensor module (e.g., TSOP38238 or similar)
2 LEDs (one for obstacle detected, one for no obstacle)
2 resistors (220Ω for each LED)
Breadboard and jumper wires
USB cable to connect the Arduino to the computer
Procedure 1. Setup the Arduino Environment:
1.1. Install the Arduino IDE on your computer if it is not already installed.
1.2. Connect the Arduino board to your computer using the USB cable.
2. Wiring the Circuit:
2.1. Connect the IR sensor to the Arduino:
2.1.1. Connect the VCC pin of the IR sensor to the 5V pin on the
Arduino.
2.1.2. Connect the GND pin of the IR sensor to the GND pin on the
Arduino.
2.1.3. Connect the output pin of the IR sensor to a digital pin on the
Arduino (e.g., pin 7).
2.2. Connect the LEDs:
2.2.1. Connect the anode (long leg) of the first LED (Obstacle
Detected) to a digital pin on the Arduino (e.g., pin 8) through a
220Ω resistor.
2.2.2. Connect the anode of the second LED (No Obstacle) to another
digital pin on the Arduino (e.g., pin 9) through a 220Ω resistor.
2.2.3. Connect the cathodes (short legs) of both LEDs to GND.
3. Launch the Arduino IDE on your computer.
4. In the Arduino IDE, create a new sketch (File > New).
5. Write the code provided in the "Code" section below.
P:F-LTL-UG / 03 /R0 48
6. Select the correct board and port from the Tools menu.
7. Click on the upload button (right arrow icon) to upload the program to the
Arduino.
8. Test the Program:
8.1. After uploading, place an object in front of the IR sensor to test the
obstacle detection.
8.2. Observe the LEDs to see if they light up correctly based on the
presence of an obstacle.
Code // Define pin numbers
const int irSensorPin = 2; // Pin connected to the IR sensor output
const int ledPin1 = 9; // Pin for LED1 (No Obstacle )
const int ledPin2 = 10; // Pin for LED2 (Obstacle detected)
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
void loop() {
// Read the value from the IR sensor
int sensorValue = digitalRead(irSensorPin);
P:F-LTL-UG / 03 /R0 49
Simulation
Output
https://circuitdigest.com/microcontroller-projects/interfacing-ir-sensor-module-with-arduino
Output
P:F-LTL-UG / 03 /R0 50
Conclusion In this lab, we successfully interfaced a DHT22 temperature and humidity
sensor with an Arduino to read and display temperature measurements. By
utilizing the Serial Plotter feature in the Arduino IDE, we were able to
visualize real-time temperature data in a graphical format, enhancing their
understanding of data monitoring and visualization techniques.
P:F-LTL-UG / 03 /R0 51
We used following Simulation web resources
https://wokwi.com/projects/new/arduino-uno
https://www.tinkercad.com/
Special thanks to Miss. Bhumi for output image of Assignment No.12 and 13.
P:F-LTL-UG / 03 /R0 52