0% found this document useful (0 votes)
13 views

IOT_LabManual Solution

Uploaded by

sr19742813
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

IOT_LabManual Solution

Uploaded by

sr19742813
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Internet of Things Enrollment No:

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.

Installation and setup of the Arduino:


1. Download & install the Arduino environment (IDE)
If you just got your Arduino Uno board, you’ll first have to install the Arduino IDE
(Integrated Development Environment) on another computer. The code is typed into the IDE
and sent to the Arduino via a USB cable.
Visit arduino.cc to download the most recent Arduino IDE version for your computer. There
are different versions for Mac, Windows and Linux OS.

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

6. Select your serial port


Select the serial device of the Arduino board. Go to Tools, and then the serial port menu. You
might see COM3 or higher (COM1 and COM2 are usually reserved for hardware serial
ports). To find out which port your Arduino board is connected to, disconnect your Arduino
board and re-open the menu. The entry that disappears should be the Arduino board.
Reconnect the board and choose that serial port.

7. Open the blink example


We'll start with the LED Blink example that comes with the Arduino IDE. Just go to File-
>Examples->Basics->Blink.

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

Microcontroller for Robotics, IoT,


Core Components Arduino Boards processing and GPIO home
control automation

Solderless platform for Circuit testing


Breadboard
prototyping circuits and design

Weather
Measure temperature
Input Devices Temperature Sensors stations, HVAC
(e.g., DHT11, LM35)
systems

Detect ambient light Automatic


Light Sensors intensity (e.g., LDR, lighting, solar
TSL2561) trackers

Motion Sensors Detect movement or Security


distance (e.g., PIR, HC- systems,
SR04) obstacle
detection

1|Page
Internet of Things Enrollment No:
22012250410322

Touch panels,
Detect touch inputs
Touch Sensors interactive
(e.g., TTP223)
devices

Detect gases like Air quality


Gas Sensors smoke, CO (e.g., MQ-2, monitoring,
MQ-135) safety systems

Detect sound or audio Voice-activated


Sound Sensors levels (e.g., KY-038, systems, sound
MAX9814) level meters

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

Produce sound (e.g., Alarms, audio


Buzzers
Piezo buzzers) signals

2|Page
Internet of Things Enrollment No:
22012250410322

Electrically operated Home


Relays switches for high-power automation,
devices motor control

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)

Internet connectivity Smart home,


Wi-Fi Modules
(e.g., ESP8266, ESP32) data logging

Radio frequency
Wireless sensor
RF Modules communication (e.g.,
networks
nRF24L01)

Provide geolocation Navigation,


GPS Modules
data (e.g., Neo-6M) vehicle tracking

Long-range
Agriculture,
LoRa Modules communication (e.g.,
smart cities
SX1278)

3|Page
Internet of Things Enrollment No:
22012250410322

Power Power Arduino


Power Adapters Provide DC power
Components boards

Portable power sources Mobile or


Batteries
(e.g., Li-ion, AA) remote projects

Regulate voltage (e.g., Power


Voltage Regulators
LM7805) distribution

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

Store energy in Filters, power


Inductors
magnetic fields supplies

Signal
Act as
Transistors processing,
switches/amplifiers
motor control

Track time (e.g., Timers, data


Miscellaneous RTC Modules
DS3231) logging

4|Page
Internet of Things Enrollment No:
22012250410322

Store data (e.g., SD Data logging,


Memory Modules
card, EEPROM) media storage

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

Preparing SD Card for Raspberry Pi


The SD card contains the Raspberry Pi’s operating system (the OS is the software that makes
it work,
like Windows on a PC or OSX on a Mac). This is very different from most computers and it
is what many
people find the most daunting part of setting up their Raspberry Pi.
The following instructions are for Windows users. Linux and Mac users can find instructions
at
www.raspberrypi.org/downloads
1. Download the Raspberry Pi operating system
The recommended OS is called Raspbian. It can be downloaded using following link:
http://downloads.raspberrypi.org/images/raspbian/2012-12-16-wheezy-raspbian/2012-12-16-
wheezy-raspbian.zip
2. Unzip the file that you just downloaded
a) Right click on the file and choose “Extract all”.
b) Follow the instructions—you will end up with a file ending in .img
This .img file can only be written to your SD card by special disk imaging software
3. Download the Win32DiskImager software
a) Download win32diskimager-binary.zip (currently version 0.6) from:
https://launchpad.net/win32-image-writer/+download
b) Unzip it in the same way you did the Raspbian .zip file
c) You now have a new folder called win32diskimager-binary
You are now ready to write the Raspbian image to your SD card.
4. Writing Raspbian to the SD card
a) Plug your SD card into your PC

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

a) Follow the Quick start guide on page 1


b) On first boot you will come to the Raspi-config window
c) Change settings such as timezone and locale if you want
d) Finally, select the second choice: expand_rootfs and say ‘yes’ to a reboot
e) The Raspberry Pi will reboot and you will see raspberry pi login:
f) Type:
pi
g) You will be asked for your Password
h) Type:
raspberry
i) You will then see the prompt:
pi@raspberry ~ $
j) Start the desktop by typing:
startx
k) You will find yourself in a familiar-but-different desktop environment.
l) Experiment, explore and have fun!

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

Microcomputer for IoT, AI/ML,


Core Components Raspberry Pi Boards processing and robotics, media
GPIO control servers

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

Detect ambient Smart lighting,


Light Sensors
light intensity solar trackers

1|Page
Internet of Things Enrollment No:
22012250410322

Detect movement Security


Motion Sensors or measure systems,
distance robotics

Detect sound or Voice


Sound Sensors measure audio activation, audio
levels analysis

Air quality
Detect gases (e.g.,
Gas Sensors monitoring,
CO2, smoke)
safety systems

Surveillance,
Capture images or
Camera Modules facial
video
recognition

Accelerometer & Measure motion Wearables,


Gyroscope and orientation gaming, robotics

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

Show text or Dashboards,


Displays
graphics media interfaces

Home
Control high- automation,
Relays
power devices industrial
systems

Communication Provide wireless


Wi-Fi Modules IoT, smart home
Modules connectivity

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

Enable long-range Smart cities,


LoRa Modules
communication agriculture

Power Supply (5V Provide power to General


Power Components
Adapter) the Raspberry Pi operation

Portable power Mobile projects,


Batteries
source field use

Provide backup Critical


UPS Modules power during applications,
outages servers

Provide additional Data logging,


Storage Modules USB Drives
storage media storage

Offer large storage Databases,


External SSD/HDD
capacity media servers

Faster alternative High-speed boot


eMMC Modules
to SD cards and operation

Provide wired
Networking Servers, secure
Ethernet Modules network
Components systems
connectivity

Enable mobile IoT in remote


Cellular Modules (e.g.,
network areas, vehicle
4G)
connectivity systems

4|Page
Internet of Things Enrollment No:
22012250410322

Audio DACs (Digital-to- Improve sound Media centers,


Audio Modules
Analog Converters) output quality audio recording

Capture high- Voice assistants,


Microphone Arrays
quality audio sound analysis

Keep accurate time


Miscellaneous Data logging,
Real-Time Clock (RTC) even when
Modules timers
powered off

Security
Keypads Provide user input systems,
interfaces

Capture motion Gaming, robotic


Joystick Modules
and button inputs arms

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()
{

// initialize digital pin 3,4 & 6 as an output.

pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT); }

// the loop function runs over and over again forever

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);

for (int angle = 180; angle >= 0; angle--)


{
myServo.write(angle);
delay(15);
}

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);

long duration = pulseIn(echoPin, HIGH);


int distance = duration * 0.034 / 2; // Convert to cm

Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
}

1|Page
Internet of Things Enrollment No:
22012250410322

Output:

Schematic View:

2|Page

You might also like