Lab Manual Iot 6th
Lab Manual Iot 6th
Research
Laboratory Manual
Year: 2023-2024
1
INDEX
2
Experiment No: 1 Date: / /
TITLE: Introduction to Arduino Board, Arduino IDE and Cables.
OBJECTIVES:
After studying this practical student will able to learn about basics of Arduino IDE and different types of
Arduino board and its usage.
THEORY:
Introduction to Arduino:
3
• Analog Reference pin (orange)
• Digital Ground (light green)
• Digital Pins 2-13 (green)
• Digital Pins 0-1/Serial In/Out - TX/RX (dark green) - These pins cannot be used for digital i/o
(digitalRead and digitalWrite) if you are also using serial communication.
• Reset Button - S1 (dark blue)
• In-circuit Serial Programmer (blue-green)
• Analog In Pins 0-5 (light blue)
• Power and Ground Pins (power: orange, grounds: light orange)
• External Power Supply In (9-12VDC) - X1 (pink)
• Toggles External Power and USB Power SV1 (purple)
• USB (used for uploading sketches to the board and for serial communication between theboard and
the computer; can be used to power the board) (yellow)
Arduino IDE:
The Arduino Integrated Development Environment - or Arduino Software (IDE) - contains a text
editor for writing code, a message area, a text console, a toolbar with buttons for common
functions and a series of menus. It connects to the Arduino and Genuino hardware to upload
programs and communicate with them.
Writing Sketches
1. File
2. Edit
3. Sketch
4. Tools
5. Help
Sketchbook
Tabs, Multiple Files, and Compilation
Uploading
Libraries
Third-Party Hardware
Serial Monitor
Preferences
Language Support
Boards
Writing Sketches:
Programs written using Arduino Software (IDE) are called sketches. These sketches are written
in the text editor and are saved with the file extension .ino. The editor has features for
cutting/pasting and for searching/ replacing text. The message area gives feedback while saving
and exporting and also displays errors. The console displays text output by the Arduino
4
Software (IDE), including complete error messages and other information. The bottom right
hand corner of the window displays the configured board and serial port. The toolbar buttons
allow you to verify and upload programs, create, open, and save sketches, and open the serial
monitor.
Sketchbook:
The Arduino Software (IDE) uses the concept of a sketchbook: a standard place to store your
programs (or sketches). The sketches in your sketchbook can be opened from the File
>Sketchbook menu or from the Open button on the toolbar. The first time you run the Arduino
software, it will automatically create a directory for your sketchbook. You can view or change
the location of the sketchbook location from with the Preferences dialog. Beginning with
version 1.0, files are saved with a.ino file extension. Previous versions use the.pde extension.
You may still open.pde named files in version 1.0 and later, the software will automatically
rename the extension to .ino.
Allows you to manage sketches with more than one file (each of which appears in its own
tab). These can be normal Arduino code files (no visible extension), C files (.c extension),
C++ files (.cpp), or header files (.h).
Uploading:
Before uploading your sketch, you need to select the correct items from the Tools > Board and
Tools > Port menus. The boards are described below. On the Mac, the serial port is probably
something like /dev/tty. usbmodem241 (for an Uno or Mega2560 or Leonardo) or
/dev/tty.usbserial-1B1 (for a Duemilanove or earlier USB board), or /dev/tty. USA19QW1b1P1.1
(for a serial board connected with a Keyspan USB-to-Serial adapter). On Windows, it's probably
COM1 or COM2 (for a serial board) or COM4, COM5, COM7, or higher (for a USB board) –
to find out, you look for USB serial device in the ports section of the Windows Device Manager.
On Linux, it should be /dev/ttyACMx , /dev/ttyUSBx or similar. Once you've selected the
correct serial port and board, press the upload button in the toolbar or select the Upload item
from the File menu. Current Arduino boards will reset automatically and begin the upload. With
older boards (pre- Diecimila) that lack auto-reset, you'll need to press the reset button on the
board just before starting the upload. On most boards, you'll see the RX and TX LEDs blink as
the sketch is uploaded. The Arduino Software (IDE) will display a message when the upload is
5
complete, or show an error. When you upload a sketch, you're using the Arduino boot loader, a
small program that has been loaded on to the microcontroller on your board. It allows you to
upload code without using any additional hardware. The boot loader is active for a few seconds
when the board resets; then it starts whichever sketch was most recently uploaded to the
microcontroller. The boot loader will blink the on-board (pin 13) LED when it starts (i.e., when
the board resets).
Libraries:
Libraries provide extra functionality for use in sketches, e.g., working with hardware or
manipulating data. To use a library in a sketch, select it from the Sketch > Import Library menu.
This will insert one or more #include statements at the top of the sketch and compile the library
with your sketch. Because libraries are uploaded to the board with your sketch, they increase the
amount of space it takes up. If a sketch no longer needs a library, simply delete its #include
statements from the top of your code.
There is a list of libraries in the reference. Some libraries are included with the Arduino software.
Others can be downloaded from a variety of sources or through the Library Manager. Starting
with version 1.0.5 of the IDE, you do can import a library from a zip file and use it in an open
sketch. See these instructions for installing a third-party library.
Third-Party Hardware:
Support for third-party hardware can be added to the hardware directory of your sketch book
directory. Platforms installed there may include board definitions (which appear in the board
menu), core libraries, boot loaders, and programmer definitions. To install, create the hardware
directory, then unzip the third- party platform into its own sub-directory. (Don't use "arduino" as
the sub-directory name or you'll override the built-in Arduino platform.) To uninstall, simply
delete its directory.
Serial Monitor
Displays serial data being sent from the Arduino board. To senddata to the board, enter text and
click on the "send" button or press enter. Choose the baud rate from the drop-down that matches
the rate passed to Serial.begin in your sketch. Note that onWindows, Mac or Linux, the Arduino
or Genuino board will reset when you connect with the serial monitor.
6
Preferences:
Some preferences can be set in the preferences dialog (found under the Arduino menu on the
Mac,or File on Windows and Linux). The rest can be found in the preferences file, whose
location is shown in the preference dialog.
Language Support:
Since version 1.0.1, the Arduino Software (IDE) has been translated into 30+ different
languages.By default, the IDE loads in the language selected by your operating system.
(Note: on Windows and possibly Linux, this is determined by the locale setting which controls
currency and date formats, not by the language the operating system is displayed in.) If you would
like to change the language manually, start the Arduino Software (IDE) and open the Preferences
window. Next to the Editor Language there is a dropdown menu of currently supported
languages. Select your preferred language from the menu, and restart the software to use the
selected language. If your operating system language is not supported, the Arduino Software
(IDE) will default to English.
Boards:
The board selection has two effects: it sets the parameters (e.g., CPU speed and baud rate) used
when compiling and uploading sketches; and sets and the file and fuse settings used by the burn
boot loader command. Some of the board definitions differ only in the latter, so even if you've
been uploading successfully with a particular selection, you'll want to check it before burning the
boot loader.
- Arduino/Genuino Uno: An ATmega328 running at 16 MHz with auto-reset, 6 Analog In, 14
Digital I/O and 6 PWM.
- Arduino Mega: An ATmega1280 running at 16 MHz with auto-reset, 16 Analog In, 54 Digital
I/O and 15 PWM.
- Arduino Micro: An ATmega32u4 running at 16 MHz with auto-reset, 12 Analog In, 20 Digital
I/O and 7 PWM.
Arduino Cables:
Arduino is great but sometimes connecting interesting things to it can be a pain. Here are some
things that may make it easier for you. Here are some of the cables and pins that are available,
and below we'll show you how to use them for many different applications.
7
Standard issue USB 2.0 cables. This is the most common A to B Male/Male type peripheral cable.
Compatible with most Arduino boards such as Arduino Mega, Romeo, ArduinoDuemilanove.
Often used for printers and other peripherals. While still a little bulky in shape for small
embedded systems, this is a standard cable found everywhere. Use this cable with Arduino UNO
and others, but not for Arduino Leonardo based boards.May come in White or Black.
EXERCISE:
EVALUATION:
Problem
Understanding Timely
Analysis & Mock Total
Level Completion
Solution (2) (10)
(3) (2)
(3)
8
Experiment No: 2 Date: / /
TITLE: To interface LED / Buzzer with Arduino Uno and write a program to turn ON LED for 1 sec
after every 2 seconds.
OBJECTIVES:
After studying this practical student will able to learn about use of Arduino IDE & Arduino Board and
implement the program of LED.
THEORY:
Hardware Required:
Arduino or Genuino Board
LED
220-ohm resistor
Circuit:
To build the circuit, connect one end of the resistor to Arduino pin 13. Connect the long leg of the LED
(the positive leg, called the anode) to the other end of the resistor. Connect the short leg of the LED
(the negative leg, called the cathode) to the Arduino GND, as shown in the diagram and the schematic
below.
Most Arduino boards already have an LED attached to pin 13 on the board itself. If you run this example
with no hardware attached, you should see that LED blinks.
The value of the resistor in series with the LED may be of a different value than 220 ohm; the LED will
lit up also with values up to 1K ohm.
9
Code:
After you build the circuit plug your Arduino or Genuino board into your computer, start the
Arduino Software (IDE) and enter the code below. You may also load it from the menu
File/Examples/01.Basics/Blink. The first thing you do is to initialize pin 13 as an output pin
with the Line.
pinMode(13, OUTPUT);
In the main loop, you turn the LED on with the line:
digitalWrite(13, HIGH);
This supplies 5 volts to pin 13. That creates a voltage difference across the pins of the
LED, and lights it up. Then you turn it off with the line:
digitalWrite(13, LOW);
That takes pin 13 back to 0 volts, and turns the LED off. In between the on and the off, you
want enough time for a person to see the change, so the delay () commands tell the board
to do nothing for 1000 milliseconds, or one second. When you use the delay () command,
nothing else happens for that amount of time.
// the setup function runs once when you press reset or power the board
void setup ()
{ // initialize digital pin 13 as
an output. pinMode(13, OUTPUT);
}
10
delay (1000); // wait for a second
}
EXERCISE:
EVALUATION:
Problem
Understanding Timely
Analysis & Mock Total
Level Completion
Solution (2) (10)
(3) (2)
(3)
11
Experiment No: 3 Date: / /
TITLE: To interface Push button with Arduino Uno and write a program to turn ON LED when push
button is pressed or at sensor detection.
OBJECTIVES:
After studying this practical student will able to learn about use of Arduino Uno Board and implement
the program of LED using PUSH button.
Circuit:
Code:
int buttonState=0;
void setup()
{
12
pinMode(11, OUTPUT);
pinMode(4, INPUT);
}
void loop ()
{
// read the state of the pushbutton buttonState=digitalRead(4);
delay (5);
}
13
EXERCISE:
(1) Compare both the result i.e., before & after the PUSH button pressed, check the result of LED.
EVALUATION:
Problem
Understanding Timely
Analysis & Mock Total
Level Completion
Solution (2) (10)
(3) (2)
(3)
14
Experiment No: 4 Date: / /
TITLE: To interface Temp and Humidity module with Arduino Uno and note the result.
OBJECTIVES:
After studying this practical able to understand about use of Arduino UNO and use of Temperature
and Humidity Sensor and notify the results.
THEORY:
In this tutorial we will learn how to use a DHT11 Temperature and Humidity Sensor.
It’s accurate enough for most projects that need to keep track of humidity and temperature readings.
Again, we will be using a Library specifically designed for these sensors that will make our code short
and easy to write.
Components
- 1 * Arduino Uno board
- 1 * USB cable
15
#include <math.h>
doubleThermister(intRawADC)
{double Temp;
void setup ()
Serial.begin(9600);
void loop ()
delay (500);
16
}
EXERCISE:
EVALUATION:
Problem
Understanding Timely
Analysis & Mock Total
Level Completion
Solution (2) (10)
(3) (2)
(3)
17
Experiment No: 5 Date: / /
TITLE: To Perform Experiment using Arduino Uno to measure the distance of any object
using Ultrasonic Sensor.
OBJECTIVES:
After performing this practical able to understand about the use of Ultrasonic Sensor which can
be used for different purposes but as of now will use it to measure the distance of any object
and notice the result.
THEORY:
Code:
/
*
Ping))) Sensor
This sketch reads a PING))) ultrasonic rangefinder and returns the distance to the closest
object in range. To do this, it sends a pulse to the sensor to initiate a reading, and then listens
for a pulse to return. The length of the returning pulse is proportional to the distance of the
object from the sensor.
The circuit:
* +V connection of the PING))) attached to +5V
* GND connection attached to ground
* SIG connection attached to digital pin 7 */
18
int inches = 0;
int cm = 0;
19
}
20
EXERCISE:
(1) Compare the result as discussed in above diagrams and note the performance.
EVALUATION:
Problem
Understanding Timely
Analysis & Mock Total
Level Completion
Solution (2) (10)
(3) (2)
(3)
21
Experiment No: 6 Date: / /
TITLE: To Perform Light Sensor (Photoresistor) using Arduino Uno.
OBJECTIVES:
Understand about Light sensor and implement it with Arduino Uno.
THEORY:
Circuit of Potentiometer:
Code:
int sensorValue = 0;
void setup ()
{
pinMode(A0, INPUT);
pinMode(13, OUTPUT);
}
void loop ()
{
22
sensorValue = analogRead(A0);
23
Circuit of Photo register:
Code:
int sensorValue = 0;
void setup ()
{
pinMode(A0, INPUT);
pinMode(9, OUTPUT);
Serial.begin(9600);
}
void loop ()
{
// read the value from the sensor
sensorValue = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorValue);
24
// map the sensor reading to a range for the LED
analogWrite(9, map(sensorValue, 0, 1023, 0, 255));
delay(100); // Wait for 100 millisecond(s)
}
EXERCISE:
(1) Compare the Result after the Simulation.
EVALUATION:
Problem
Understanding Timely
Analysis & Mock Total
Level Completion
Solution (2) (10)
(3) (2)
(3)
25
Experiment No: 7 Date: / /
TITLE: To Perform Flame Sensor using Arduino.
OBJECTIVES: Learn about the Flame sensor and how it notify the result when some
unwanted events going to occur.
THEORY:
Circuit:
Code:
#include <Adafruit_NeoPixel.h>
// To add the NeoPixel library, which opens up a new set of commands we for
controlling ourNeoPixel ring.
#define PIN 9
#define NUMPIXELS 24
26
int currentColor = 0;
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB +
NEO_KHZ800);
void setup ()
{
pixels.begin(); // This initializes the
NeoPixel lib
pixels.setBrightness(100);
pixels.show();
}
void loop {
uint32_t red = pixels.Color(255, 0, 0); //red
uint32_t orange = pixels.Color(255, 100, 10); //orange
uint32_t yellow = pixels.Color(255, 255, 0); //yellow
uint32_t green = pixels.Color(0, 255, 0);//green
uint32_t dkgreen = pixels.Color(0, 115, 0);//dark green
uint32_t cyan = pixels.Color(0, 255, 255); //cyan
uint32_t blue = pixels.Color(0, 0, 255); //blue
uint32_t magenta = pixels.Color(255, 0, 255); //magenta
uint32_t purple = pixels.Color(50, 0, 50); //purple
//put the colors in an array
uint32_t colors [9] = {red, orange, yellow, green, dkgreen, cyan, blue, magenta, purple};
EXERCISE:
(1) Compare the result as per above criteria and notify the result.
EVALUATION:
Problem
Understanding Timely
Analysis & Mock Total
Level Completion
Solution (2) (10)
(3) (2)
(3)
28
Experiment No: 8 Date: / /
TITLE: To Perform LASER module using Arduino.
OBJECTIVES: Learn about the LASER module and notify the result.
THEORY:
The laser diode works on the principle that every atom in its excited state can emit photons if electrons at higher
energy level are provided with an external source of energy. There are basically three phenomena by which an atom
can emit light energy and that are Absorption, Spontaneous Emission & Stimulated emission.
Components
- 1 * Arduino Uno board
- 1 * USB cable
- 1 * Laser module
Principle
Experimental Procedures: -
29
Step 2: Program
Code:
void setup ()
{
pinMode(13, OUTPUT);
}
void loop () {
digitalWrite(13, HIGH);
delay (1000);
digitalWrite(13, LOW);
delay (1000);
}
EXERCISE:
(1) Execute the code with different parameters and note the result.
EVALUATION:
Problem
Understanding Timely
Analysis & Mock Total
Level Completion
Solution (2) (10)
(3) (2)
(3)
30
Experiment No: 9 Date: / /
TITLE: An Introduction to Raspberry Pi.
OBJECTIVES: Understand the need of Raspberry Pi and usage of it to implement the different application
based on IOT.
THEORY:
Introduction
Raspberry Pi is a series of low-cost single-board computers which comes with built-in features such as
WIFI and Bluetooth and some USB and HDMI ports. We can connect a display, USB keyboard and
mouse to the system.
These mini-computers are highly flexible in the areas where they can be used such as embedded system,
weather reports and small security system. It is highly recommended for beginners to explore this
excellent device to be able to do projects like WIFI Hacker, AD-Blocker and a working server that has
some practical relevance!!
31
A and model B.
The Raspberry Pi is a popular choice when developing IoT products. It offers a complete Linux server
with a tiny platform at an incredibly low price. Actually, the Raspberry Pi is so well-known to IoT that
the company has featured several Internet of Things projects on their site. Here you will find projects
and community support for a range of IoT activities. Take for example, the World’s First Cloud Texting
Enable d Espresso Machine – powered by Raspberry Pi.
Partnered with the Zipwhip cloud texting application, the Raspberry Pi connects to an espresso machine
and allows people to text a message to it that automatically turns it on and starts brewing beverages.
In the subsequent year A+ and B+ models were released. Again in 2015, Raspberry Pi2 model B was
released and a immediate year Raspberry Pi3 model B was released in the market.
Raspberry Pi can be plugged into a TV, computer monitor, and it uses a standard keyboard and mouse.
It is user friendly as can be handled by all the age groups. It does everything you would expect a desktop
computer to do like word-processing, browsing the internet spreadsheets, playing games to playing high-
definition videos. It is used in many applications like in a wide array of digital maker projects, music
machines, parent detectors to the weather station and tweeting birdhouses with infrared cameras.
All models feature on a broadcom system on a chip (SOC), which includes chip graphics processing unit
GPU (a Video Core IV), an ARM compatible and CPU. The CPU speed ranges from 700 MHz to
1.2 GHz for the Pi 3 and on-board memory range from 256 MB to 1 GB RAM. An operating system is
32
stored in the secured digital SD cards and program memory in either the MicroSDHC or SDHC sizes.
Most boards have one to four USB slots, composite video output, HDMI and a 3.5 mm phone jack for
audio. Some models have WiFi and Bluetooth.
The Raspberry Pi Foundation provides Arch Linux ARM and Debian distributions for download, and
promotes Python as the main programming language, with support for BBC BASIC, Java, C, Perl,Ruby,
PHP, Squeak Smalltalk, C++, etc.
33
Smart Home automation
IOT is transforming the way devices operate at home. Using IOT several home devices are automated and they
can interact among themselves and with humans. Sensors are often used for automation in home appliances.
Some home automation IOT projects for engineering students are automation using hand gestures, smart
garage door, facial recognition door, smart alarm clock and automated blinds.
Industrial IoT
Automation has been extensively used in all the industries to reduce the manual errors in the production process.
Using IOT devices, industries will be able to control and monitor various equipment, machinery, processes and
other applications with less or no human intervention. Automation helps in reducing the errors and improving the
efficiency of production. Thus, many industries are trying to adapt IOT system into their operations. Some
industries also offer IOT training to their employees to get knowledge on how to handle IOT systems and
devices. Some of the industrial automation IOT projects for final year students are vehicle simulation, smart
parking system, smart building project, biometrics and smartsecurity model.
IOT can help to perform any desired action like controlling a device or monitoring from a remote location. This
technology makes equipment and machinery more digitized and connected. This technology is preferred even by
the government to achieve better energy efficiency, a cleaner city and higher productivity. A few IOT projects
for smart cities are baggage tracker, smart trash collector, smart energy meter reading and smart liquid level
34
monitoring.
EXERCISE:
EVALUATION:
Problem
Understanding Timely
Analysis & Mock Total
Level Completion
Solution (2) (10)
(3) (2)
(3)
35
Experiment No: 10 Date: / /
TITLE: An Installation of Raspberry Pi.
OBJECTIVES: Understand the installation and configuration of Raspberry Pi to implement the different
applications of IOT.
THEORY:
The procedure is divided into three sections as per the relevance of the project and need. The
subsections are as follows:
1. Installing Raspbian on Raspberry Pi 3
2. Using SSH(Secure Shell) remote access and VNC remote access
3. GPIO Programming
Prerequisites
Few prerequisites are:
1. A functional Raspberry Pi
2. A micro-SD card of 8 GB or more and a Card Reader
3. USB keyboard and mouse
4. A working computer
5. Stable power supply to power the machine
6. Internet
A step by step procedure of process which tells you how to get started with Raspberry Pi is in this Link:
https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up
1. Head over to below link to download the Full Version of Raspbian OS (This should be around 2.4
GB).
2. Download the ZIP file by clicking on Download ZIP to start the
download. https://www.raspberrypi.org/software/
Windows
macOS
Ubuntu
36
2. Install the Imager to your system.
Password: raspberry
5. Once you are connected to Raspberry Pi via SSH, follow the procedure below in shell. These
settings help you to connect to the device via SSH and VNC.
1. Type sudo raspi-config in shell
2. A menu will appear, goto Interfacing Options (Option Number 5)
3. Choose SSH and choose "Enable Option"
4. Choose VNC option and enable this as well.
5. Goto Finish.
6. Close Putty and open VNC viewer. Enter the IP address of Raspberry Pi in the top search
option andpress enter.
7. And you are done!
GPIO Programming
38
The most common functions of GPIO pins include:
Being configurable in software to be input or output
Being enabled or disabled
Setting the value of digital output.
Reading the value of digital output.
Generating an interrupt when the input changes the value
These pins are used with digital data which is typically referred to as High voltage and Low voltage.
GPIO programming is usually done with Python using RPi.GPIO which can be installed via terminal.
39
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio
The best way to learn Raspberry Pi and IoT is via small projects and by having fun. We recommend you
to check out this https://projects.raspberrypi.org/en/projects?hardware%5B%5D=raspberry-pi
to browse some fabulous projects to start with. Choose any of them and have fun. (^_^)
Foot Note
For Linux and macOS, connecting is even easier. Just use Advanced IP Scanner/Nmap or any tool you
wish to scan for Raspberry Pi and use the following command.
ssh pi@<IP>
We also recommend you to check out https://elec-club-iitb.github.io/tutorials/r_pi/
article from Electronics Club IIT-B for some extra insights.
Raspberry Pi has a limitless scope with the projects and stuff you can do with it, ranging from Robotics
to Ethical Hacking. The purpose of this article is to get you started with Raspberry Pi so that you can
explore this fantastic little tool under the guidance of the Electronics Club.
EXERCISE:
(1) Installation of Raspberry Pi by yourself and complete the configuration to develop and deploy any
application.
EVALUATION:
Problem
Understanding Timely
Analysis & Mock Total
Level Completion
Solution (2) (10)
(3) (2)
(3)
40