IOT_LabManual Solution
IOT_LabManual Solution
22012250410322
Experiment: 08
Aim: Preform installation and setup of the Arduino.
Introduction:
Arduino is an open-source electronics platform based on easy-to-use hardware and software.
Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter
message and turn it into an output - activating a motor, turning on an LED, publishing
something online. You can tell your board what to do by sending a set of instructions to the
microcontroller on the board. To do so you need to use the Arduino programming language
(based on Wiring) and the Arduino Software (IDE) based on Processing. Arduino also
simplifies the process of working with microcontrollers.
Architecture of Arduino:
As shown in the above figure, labelled components of the Arduino board are explained as
follows:
1) USB: Arduino board can be powered by using the USB cable from your computer.
All you need to do is connect the USB cable to the USB connection. It can be used for
both power and communication with the IDE.
1|Page
Internet of Things Enrollment No:
22012250410322
2) Barrel Jack: It is used for power supply. Arduino boards can be powered directly
from the AC mains power supply by connecting it to the Barrel Jack.
3) Voltage Regulator: It regulates and stabilizes the input and output voltages. The
function of the voltage regulator is to control the voltage given to the Arduino board
and stabilize the DC voltages used by the processor and other elements.
4) Crystal Oscillator: It keeps track of time and regulates processor frequency. The
crystal oscillator helps Arduino in dealing with time issues. How does Arduino
calculate time? The answer is, by using the crystal oscillator. The number printed on
top of the Arduino crystal is 16.000H9H. It tells us that the frequency is 16 MHz.
5) Reset Pin: It can be used to reset the Arduino Uno.
6) 3.3V Pin: It can be used as a 3.3V output.
7) 5V Pin: It can be used as a 5V output.
8) GND Pin: It can be used to ground the circuit.
9) Vin Pin: It can be used to supply power to the board.
10) Analog Pins (A0-A5): It can be used to read analog signals to the board.
11) Microcontroller (ATMega328): The processing and logical unit of the board.
12) ICSP Pin: A programming header on the board also called SPI.
13) Power Indicator LED: It indicates the power status of the board.
14) RX and TX LEDs: It receive (RX) and transmit (TX) LEDs, blink when sending or
receiving serial data respectively.
15) Digital I/O Pins: 14 pins capable of reading and outputting digital signals; 6 of these
pins are also capable of PWM.
16) AREF Pins: It can be used to set an external reference voltage as the upper limit for
the analog pins.
17) Reset button: It can be used to reset the board.
2|Page
Internet of Things Enrollment No:
22012250410322
At the download page, click on the “Installer” option for the easiest installation then
Save the .exe file to your disk drive.
Open the .exe file.
Click the button to agree to the licensing agreement.
Decide which components to put in, then click “Next”.
Select which folder to put in the program to, then click “Install”.
Wait for the program to complete installing, then click “Close”.
2. Launch the Arduino IDE
After your Arduino IDE software is downloaded, unzip the folder. To do so, double-click on
the Arduino shortcut on your Desktop. The IDE will open up and you’ll see the code editor.
3. If needed, install the drivers
If you used the Installer, it'll install drivers automatically as soon as you connect your board.
4. Connect the board to your computer via the USB cable
To power up your board, connect your Arduino board with the pc via USB cable. The green
color power LED should glow on the board.
5. Select your board
Next, make sure the software is ready up for your particular Arduino board. Go to the
“Tools” computer menu from the menu bar. Select the “Board” option and another menu will
appear, where you'll select your Arduino model from the list.
3|Page
Internet of Things Enrollment No:
22012250410322
4|Page
Internet of Things Enrollment No:
22012250410322
Here are the few things to keep in mind while writing the code:
Code is case sensitive
All the statements must end with a semicolon
Comments follow a // or begin with /* and end with */
Void loop() and void setup() are two mandatory functions. The setup section of the
code is simply run once when the Arduino board is first turned on or reset. Once the
setup is complete, the loop runs over and over. It keeps on running until the board
continues to stay powered.
The status bar shows that the program is compiled or uploaded.
Program notification area shows error(s) within the code if any.
8. Upload the program
Now it is time to upload your first sketch(code). Confirm the Arduino is plugged in, and the
green light is on - therefore the correct board and port is chosen. Select Upload from the
Sketch drop-down menu.
5|Page
Internet of Things Enrollment No:
22012250410322
After a few seconds, you will get this screen, with the message "Done uploading."
6|Page
Internet of Things Enrollment No:
22012250410322
Experiment: 09
Aim: Identify, understand, and document the various electronic
components and modules commonly used in Arduino-based projects.
Typical
Category Component/Module Function
Applications
Weather
Measure temperature
Input Devices Temperature Sensors stations, HVAC
(e.g., DHT11, LM35)
systems
1|Page
Internet of Things Enrollment No:
22012250410322
Touch panels,
Detect touch inputs
Touch Sensors interactive
(e.g., TTP223)
devices
Weight
Detect force/pressure
Force/Pressure Sensors measurement,
(e.g., FSR, BMP180)
barometers
Status
Visual indicators (e.g., indicators,
Output Devices LEDs
RGB LEDs) decorative
lighting
Robotics,
Create motion (e.g., DC,
Motors motorized
Servo, Stepper motors)
systems
2|Page
Internet of Things Enrollment No:
22012250410322
Display text/graphics
Dashboards,
Displays (e.g., LCD, OLED,
user interfaces
TFT)
Wireless
Remote
Communication Bluetooth Modules communication (e.g.,
control, IoT
HC-05, HC-06)
Radio frequency
Wireless sensor
RF Modules communication (e.g.,
networks
nRF24L01)
Long-range
Agriculture,
LoRa Modules communication (e.g.,
smart cities
SX1278)
3|Page
Internet of Things Enrollment No:
22012250410322
LED
Passive protection,
Resistors Control current/voltage
Components pull-up/down
circuits
Smoothing
Store/filter electrical
Capacitors power supplies,
energy
timing circuits
Protection
Allow current flow in
Diodes circuits,
one direction
rectifiers
Signal
Act as
Transistors processing,
switches/amplifiers
motor control
4|Page
Internet of Things Enrollment No:
22012250410322
Security
User input (e.g., matrix
Keypads systems,
keypads)
calculators
Game
Detect motion/button
Joystick Modules controllers,
presses
robotic arms
5|Page
Internet of Things Enrollment No:
22012250410322
Experiment: 10
Aim: Perform installation and setup of the Raspberry Pi.
Introduction:
Raspberry Pi, developed by Raspberry Pi Foundation in association with Broadcom, is a
series of small single-board computers and perhaps the most inspiring computer available
today.
It is originally designed for education, inspired by the 1981 BBC Micro. Creator Eben
Upton's goal was to create a low-cost device that would improve programming skills and
hardware understanding at the pre-university level. The Raspberry Pi is slower than a modern
laptop or desktop but is still a complete Linux computer and can provide all the expected
abilities that implies, at a low-power consumption level.
In 2012, the company launched the Raspberry Pi and the current generations of regular
Raspberry Pi boards are Zero, 1, 2, 3, and 4. Latest one is 4B. Raspberry Pi OS (previously
called Raspbian) is official supported operating system.
Setup:
1|Page
Internet of Things Enrollment No:
22012250410322
Sr
Items Minimum recommended specification & notes
No.
Minimum size 4Gb; class 4 (the class indicates how fast
the card is).
1 SD card
We recommend using branded SD cards as they are
more reliable.
HDMI to HDMI lead (for HD TVs and monitors with
HDMI input). OR HDMI to DVI lead (for monitors with
HDMI to HDMI
2a DVI input).
/ DVI lead
Leads and adapters are available for few pounds -- there
is no need to buy expensive ones!
A standard RCA composite video lead to connect to your
2b RCA video lead
analogue display if you are not using the HDMI output.
Any standard USB keyboard and mouse should work.
Keyboard and Keyboards or mice that take a lot of power from the
3
mouse USB ports, however, may need a powered USB hub.
This may include some wireless devices.
Ethernet
Networking is optional, although it makes updating and
4 (network) cable
getting new software for your Raspberry Pi much easier.
[optional]
A good quality, micro USB power supply that can
provide at least 700mA at 5V is essential.
Many mobile phone chargers are suitable—check the
label on the plug.
If your supply provides less than 5V then your
5 Power adapter
Raspberry Pi may not work at all, or it may behave
erratically. Be wary of very cheap chargers: some are not
what they claim to be.
It does not matter if your supply is rated at more than
700mA.
6 Audio lead If you are using HDMI then you will get digital audio
[optional] via this.
If you are using the analogue RCA connection, stereo
audio is available from the 3.5mm jack next to the RCA
2|Page
Internet of Things Enrollment No:
22012250410322
connector
3|Page
Internet of Things Enrollment No:
22012250410322
b) In the folder you made in step 3(b), run the file named Win32DiskImager.exe
(in Windows Vista, 7 and 8 we recommend that you right-click this file and choose
“Run as
administrator”). You will see something like this:
c) If the SD card (Device) you are using isn’t found automatically then click on the
drop down box
and select it
d) In the Image File box, choose the Raspbian .img file that you downloaded
e) Click Write
f) After a few minutes you will have an SD card that you can use in your Raspberry Pi
5. Booting your Raspberry Pi for the first time
4|Page
Internet of Things Enrollment No:
22012250410322
Configuration:
Raspbian Configuration:
For configuring Raspberry Pi in Raspbian, we are using Raspbian with PIXEL desktop. It is
one of the best ways to get Raspbian started with the Raspberry Pi. Once we finish booting,
we will be in the PIXEL desktop environment.
Now to open the menu, you need to click the button that has the Raspberry Pi logo on it. This
button will be in the top left. After clicking the button, choose Raspberry Pi configuration
from the preferences.
Following is the configuration tool in PIXEL desktop −
5|Page
Internet of Things Enrollment No:
22012250410322
By default, the configuration tool opens to its system tab which has the following options −
1) Change Password: The default password is raspberry. You can change it by clicking
the change password button.
2) Change the hostname: The default name is raspberry pi. You can also change it to
the name, which you want to use on the network.
3) Boot: You can choose from the two options and control whether Raspberry Pi boots
into the desktop or CLI i.e., command line interface.
4) Auto Login: With the help of this option, you can set whether the user should
automatically log in or not.
5) Network at Boot: By choosing this option, you can set whether the pi user is
automatically logged in or not.
6) Splash screen: You can enable or disable it. On enabling, it will display the
graphical splash screen that shows when Raspberry Pi is booting.
7) Resolution: With the help of this option, you can configure the resolution of your
screen.
8) Underscan: There are two options, enable or disable. It is used to change the size of
the displayed screen image to optimally fill the screen. If you see a black border
around the screen, you should disable the underscan. Whereas, you should enable the
underscan, if your desktop does not fit your screen.
There are three other tabs namely Interfaces, Performance and Localization. The job of
interface tab is to enable or disable various connection options on your Raspberry Pi.
6|Page
Internet of Things Enrollment No:
22012250410322
You can enable the Pi camera from the interface tab. You can also set up a secure connection
between computers by using SSH (short for Secure Shell) option.
If you want to remote access your Pi with a graphical interface then, you can enable
RealVNC software from this tab. SPI, I2C, Serial, 1-wire and Remote GPIO are some other
interfaces you can use.
There is another tab called Performance, which will give you access to the options for
overclocking and changing the GPU memory.
The localization tab, as the name implies, enable us to set:
1) The character set used in our language.
2) Our time zones.
3) The keyboard setup as per our choice.
4) Our Wi-Fi country.
Configure Wi-Fi
Configure Bluetooth Devices
Data Partition Setup:
As we know that data partition is that area on your memory card (SD or MicroSD) which can
be shared by various distributions. One of the best examples of use of a data partition is
transferring the files between distributions.
The data partition has the label data.
You can use this labelled data to make a directory point to it as follows −
Step 1: First, you need to boot the Raspberry Pi into Raspbian.
Step 2: Now, click the Terminal icon to get to the command line.
Step 3: Next, type the command mkdir shared. It will create a directory named shared.
Step 4: Write the command Sudo mount -L data shared. This command will point the
directory to the shared partition.
Step 5: Write the command Sudo Chown $USER: shared. It will set the permission for
writing in this shared folder.
Step 6: Now, to go to this shared folder, you need to type the command cd shared.
Once all the files are created in this shared folder, they will be available to all the
distributions that have the permission to access the data partition.
7|Page
Internet of Things Enrollment No:
22012250410322
Experiment: 11
Aim: Identify, understand, and document the various electronic
components and modules commonly used in Raspberry Pi-based projects.
Typical
Category Component/Module Function
Applications
Storage for
Booting OS,
SD Card Raspberry Pi OS
data storage
and data
Connects to Peripheral
GPIO Header external control,
components prototyping
Weather
Input Devices Measure
Temperature Sensors stations, HVAC
(Sensors) temperature
systems
1|Page
Internet of Things Enrollment No:
22012250410322
Air quality
Detect gases (e.g.,
Gas Sensors monitoring,
CO2, smoke)
safety systems
Surveillance,
Capture images or
Camera Modules facial
video
recognition
Status signals,
Output Devices
LEDs Visual indicators decorative
(Actuators)
lighting
Robotics,
Create mechanical
Motors automated
motion
systems
2|Page
Internet of Things Enrollment No:
22012250410322
Alarms,
Buzzers Produce sound
notifications
Home
Control high- automation,
Relays
power devices industrial
systems
Enable short-range
Remote control,
Bluetooth Modules wireless
peripherals
communication
Facilitate radio
Wireless sensor
RF Modules frequency
networks
communication
Provide Navigation,
GPS Modules
geolocation data vehicle tracking
3|Page
Internet of Things Enrollment No:
22012250410322
Provide wired
Networking Servers, secure
Ethernet Modules network
Components systems
connectivity
4|Page
Internet of Things Enrollment No:
22012250410322
Security
Keypads Provide user input systems,
interfaces
Add functionality
Modular
HATs (Hardware like displays,
expansion for
Attached on Top) sensors, or motor
specific tasks
control
5|Page
Internet of Things Enrollment No:
22012250410322
Experiment: 12
Aim: Create a code that blinks the LED.
Code:
const int ledpin=13;
void setup()
{
pinMode(ledpin, OUTPUT);
}
void loop()
{
digitalWrite(ledpin, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(ledpin, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
Output:
1|Page
Internet of Things Enrollment No:
22012250410322
Schematic View:
2|Page
Internet of Things Enrollment No:
22012250410322
Experiment: 13
Aim: Create a code that blinks the RGB LEDs.
Code:
void setup()
{
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT); }
void loop() {
//here current flows through pin 6 illuminating red led in the RGB LED
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
delay(700);
//here current flows through pin 3 illuminating green led in the RGB LED
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
delay(700);
//here current flows through pin 4 illuminating blue led in the RGB LED
digitalWrite(11, LOW);
1|Page
Internet of Things Enrollment No:
22012250410322
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
delay(700);
//Further mixture of colours can be crteated by keeping any two pins HIGH at the same time
}
Output:
Schematic View:
2|Page
Internet of Things Enrollment No:
22012250410322
Experiment: 14
Aim: Create a code that rotates the servo from 0 to 360 degrees and returns
to 0 degrees.
Code:
#include <Servo.h>
Servo myServo;
void setup()
{
myServo.attach(9);
}
void loop()
{
for (int angle = 0; angle <= 180; angle++) {
myServo.write(angle);
delay(15);
}
delay(1000);
delay(1000);
}
1|Page
Internet of Things Enrollment No:
22012250410322
Output:
Schematic View:
2|Page
Internet of Things Enrollment No:
22012250410322
Experiment: 15
Aim: Create a code that controls the motor both clockwise and
anticlockwise.
Code:
int a;
void setup()
{
pinMode(13,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
Serial.begin(115200);
Serial.println("Enter Num Between 0-255 for speed");
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
}
void loop()
{
analogWrite(11,255);
if(Serial.available())
{
a = Serial.readString().toInt();
}
Serial.println(a);
}
1|Page
Internet of Things Enrollment No:
22012250410322
Output:
Schematic View:
2|Page
Internet of Things Enrollment No:
22012250410322
Experiment: 16
Aim: Create a code that detects motion using a PIR sensor and turns on an
LED or buzzer.
Code:
#define echoPin 2
#define trigPin 3
void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
}
1|Page
Internet of Things Enrollment No:
22012250410322
Output:
Schematic View:
2|Page