Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

19ece101 Introduction To Iot Laboratory Manual: B. Tech - Electronics and Communication Engineering

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Amrita School of Engineering Bengaluru

B. Tech - Electronics and Communication Engineering

19ECE101 Introduction to IoT Laboratory


Manual

Prepared by
Dr. Vivek Venugopal

Verified by Approved by

Department of Electronics and Communication Engineering


Amrita School of Engineering, Bengaluru - 560035
2022-2023 ODD

Amrita School of Engineering Bengaluru 1


Amrita School of Engineering Bengaluru

Component Marks
Internal Continuous 30
Evaluation
Mid-term Exam 20
Mini Project 20
Record 10
End Semester Exam 20

Amrita School of Engineering Bengaluru 2


Amrita School of Engineering Bengaluru

List of Experiments
1. Introduction and familiarization of Arduino, Ardublock and controlling
switching ON/OFF (blinking) an LED with Arduino controller
2. Interfacing of Arduino controller with Serial Monitor, IR sensor
3. Utilisation of Arduino controller to detect motion using PIR sensor and targets
using Ultrasonic sensor
4. Interfacing Potentiometer and Buzzer witn Arduino controller
5. Interfacing of Arduino with DC Motor and perform direction control and
rotation control.
6. Serial communication and device control using Bluetooth Module and
Arduino controller
7. Serial communication and device control using Wi-Fi Module and Arduino
controller
8. Fabrication and control of Wheeled robot using Arduino Controller and
Bluetooth/Wi-Fi Module
9. Basic App Development using MIT App Inventor and Remote Device Control
Android App Development
10. Assembly, Programming and Flight control of Quadcopter (Demo only)

Amrita School of Engineering Bengaluru 3


Amrita School of Engineering Bengaluru

Experiment No: Date:

Sample Record Format


TITLE OF EXPERIMENT

Aim
Write the aim of the experiment.

Components required
List out the components required for the experiment.

Procedure
Write the steps involved in performing the experiment in a sequential manner.

Circuit Diagram
Draw the circuit diagram of the related experiment (Sample Circuit Diagram for first
experiment (LED interfacing) is shown below)

ArduBlock Model or Android Layout


Place a screenshot of the ArduBlock Model or Android Layout based on the experiment.

Arduino IDE Code


Place a screenshot of the code section from Arduino IDE.

Result and Inference


Write the result of the experiment along with the inferences obtained from the experiment
conducted.

Amrita School of Engineering Bengaluru 4


Amrita School of Engineering Bengaluru

Table of Contents
Experiment No 1: Introduction and familiarization of Arduino, Ardublock and controlling
switching ON/OFF (blinking) an LED with Arduino controller ............................................... 6
Introduction to Arduino .......................................................................................................... 6
Introduction to Ardublock ...................................................................................................... 9
Experiment No 2: Interfacing of Arduino controller with Serial Monitor, IR sensor ............. 14
Experiment No 3: Utilisation of Arduino controller to detect motion using PIR sensor and
targets using Ultrasonic sensor ................................................................................................ 18
Experiment No 4: Interfacing Potentiometer and Buzzer with Arduino controller ................. 22

Amrita School of Engineering Bengaluru 5


Amrita School of Engineering Bengaluru

Experiment No: 1

Introduction and familiarization of Arduino, Ardublock and controlling switching


ON/OFF (blinking) an LED with Arduino controller

Aim
To familiarise with the Arduino Board, Ardublock tool and to perform the following
1. Switching LED ON
2. Switching LED OFF
3. Blinking the LED ON and OFF using delay elements
Components required
Arduino Uno Board, USB power cable

Introduction to Arduino

What is Arduino?
• Arduino is an open source electronics prototyping platform.
• Arduino is used for creating interactive objects:
▪ That can communicate with humans by using sensors and actuators, and
▪ Controlled by software running inside a microcontroller (which is a small
computer on a single chip).
• The Arduino hardware and software is open source.
▪ You can download the Arduino hardware design and build your own (with Arduino as the
starting point).
▪ The Arduino software, known as the Integrated Development Environment (IDE), is
free. You can download it from www.arduino.cc.
• The Arduino IDE is easy-to-use and can run on Windows, Macintosh, and Linux.

Applications of Arduino
• Arduino can be used for rapid prototyping of IoT projects.
• In this lab, you will learn to use Arduino to:
▪ Control LED switch ON/OFF and blinking frequency.
▪ Sensing the surrounding by interfacing with an IR sensor.
▪ Detect a gas by interfacing with a gas sensor.
▪ Control a DC motor.
▪ Measure the distance of an obstacle by interfacing with an ultrasonic sensor.
▪ Transfer data wirelessly by interfacing with a Bluetooth communication
module.
• Arduino is in fact capable of much more.

Major Parts of Arduino.


• Arduino is composed of two major parts:
▪ The Arduino board, which is the piece of hardware you work on when you build

Amrita School of Engineering Bengaluru 6


Amrita School of Engineering Bengaluru

your objects, and


▪ The Arduino Integrated Development Environment, or IDE, which is the piece
of software you run on your computer.
• The Arduino board is a small microcontroller board
▪ Which contains a whole computer on a small chip (the microcontroller).
▪ It is a rectangular/square shaped ATmega328 chip with 28 “legs” which is the
heart of the board.

Amrita School of Engineering Bengaluru 7


Amrita School of Engineering Bengaluru

• The Arduino has two rows of strips with lots of labels.


▪ These strips are the connectors, which are used to attach to sensors and actuators.
• There are 14 Digital I/O pins (pins 0–13)
▪ These pins can be either inputs or outputs.
▪ Inputs are used to read information from sensors, while outputs are used to control
actuators.
▪ You will specify the direction (in or out) in the sketch you create in the IDE.
▪ Digital inputs can only read one of two values, and digital outputs can only
output one of two values (HIGH and LOW).
• There are 6 Analogue In pins (pins 0–5)
▪ The analogue input pins are used for reading voltage measurements from analogue sensors.
▪ In contrast to digital inputs, which can distinguish between only two different levels (HIGH
and LOW), analogue inputs can measure 1,024 different levels of voltage.
• There are 6 Analogue Out pins (pins 3, 5, 6, 9, 10, and 11)
▪ These are actually six of the digital pins that can perform a third function: they can provide
analogue output.
▪ As with the digital I/O pins, you specify what the pin should do in your sketch.
• The board can be powered from your computer’s USB port, most USB chargers, or an AC
adapter (9 volts recommended).
• Whenever power is provided at the power socket, Arduino will use that, and if there is no
power at the power socket, Arduino will use power from the USB socket.
• It’s safe to have power at both the power socket and the USB socket.

• Youuse the IDE to create a sketch (a little computer program) that you upload to the
Arduino board.

▪ The sketch tells the board what to do.


• Arduino makes your life simple by hiding away most of the complexities of
programming microcontrollers.

Amrita School of Engineering Bengaluru 8


Amrita School of Engineering Bengaluru

Different Kinds of Arduino


https://www.arduino.cc/en/Main/Products

• Arduino Uno exists in two versions.


▪ One without Wi-Fi and one Wi-Fi included on the board.
• But no worries.
▪ Either you can use an Arduino Wi-Fi shield,
▪ Or you can connect the Arduino board with an ESP-01 with Wi-Fi included

Introduction to Ardublock

ArduBlock is a graphical programming add-on to the default Arduino IDE. Instead of


memorizing cryptic functions, forgetting semicolons, and debugging code, ArduBlock allows
you to build your Arduino program by dragging and dropping interlocking blocks.
ArduBlock is supported for Arduino IDE versions up to 1.8. Any versions beyond that would
not support ArduBlock.

a) ArduBlock Installation in Arduino IDE

1. Go to C:\Users\<Username>\ Documents\Arduino\

2. Create a folder tools (case sensitive) inside the Arduino folder.

3. Open tools folder, create another folder ArduBlockTool (case sensitive).

4. Open ArduBlockTool folder, create another folder tool (case sensitive).

5. Open tool folder, paste the ardublock-all.jar file.

These steps are performed inorder to add ArduBlock Add On into the Tools Tab of
Arduino IDE.
6. Close the Arduino IDE if it is opened.
7. Open Arduino IDE, click on Tools Tab and verify ArduBlock Add On is listed. If
it is not listed, then the ardublock jar file is not pasted in the actual location.

Amrita School of Engineering Bengaluru 9


Amrita School of Engineering Bengaluru

8. Click on ArduBlock, then ArduBlock workspace will be opened.

On the left-hand side, you can see many colored blocks such as control, Pins, Tests, Generic
hardware, and so on. Each of these blocks contains many sub-blocks which can be dragged
onto the right-side working area. Once the necessary blocks required for the implementation
are done, click on Upload to Arduino and the corresponding code for the blocks inserted
will be generated in Arduino IDE.

The Arduino program will start Compiling, followed by Uploading. If the COM Port is not
selected properly, the following error will be displayed.

So Click on Tools Menu, Click Port and Select the correct COM Port (Eg. COM6) where
the board is connected.
Identify COM Port to which Arduino is connected

Amrita School of Engineering Bengaluru 10


Amrita School of Engineering Bengaluru

Click on Tools Menu in Arduino IDE, Click Port and Select the correct COM Port
(Eg. COM6)

Click on Upload to Arduino Button in ArduBlock IDE once again. Then Arduino
IDE will be activated, Compiling followed by Uploading will be performed. Once the Upload
is completed, Done Uploading message will be displayed in output window of Arduino IDE.

Procedure
1. For Turning LED ON

• Open ArduBlock
• Go to Digital Pins tab, drag Set Digital Pin # block into the working area
• Once inserted in the working area change the pin number to D13 and ensure
that the pin is in HIGH state in the block.
• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.

2. For Turning LED OFF

• Open ArduBlock
• Go to Digital Pins tab, drag Set Digital Pin # block into the working area
• Once inserted in the working area change the pin number to D13 and ensure
that the pin is in LOW state in the block.
• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.

3. For Blinking LED ON and OFF

• Open ArduBlock
• Go to Digital Pins tab, drag Toggle Digital Pin # block into the working area
• Once inserted in the working area change the pin number to D13

Amrita School of Engineering Bengaluru 11


Amrita School of Engineering Bengaluru

• Go to Generic Hardware tab, drag Delay Millis block into the working area
and place it below the Toggle Digital Pin # block.
• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.

Circuit Diagram
Draw the circuit diagram of the related experiment

ArduBlock Model

1. Switching LED ON

2. Switching LED OFF

3. Blinking LED ON and OFF

Amrita School of Engineering Bengaluru 12


Amrita School of Engineering Bengaluru

Arduino IDE Code


1. Switching LED ON

2. Switching LED OFF

3. Blinking LED ON and OFF

Amrita School of Engineering Bengaluru 13


Amrita School of Engineering Bengaluru

Experiment No: 2

Interfacing of Arduino controller with Serial Monitor, IR sensor

Aim
To interface the Arduino Board with Serial monitor and IR sensor and perform the following
1. Printing “Hello World” message on the Serial monitor
2. Interfacing Arduino Board with IR sensor and display the sensor value
3. Conditional Turning ON of LED based on IR sensor value
Components required
Arduino Uno Board, USB power cable, IR sensor

Procedure

1. For Printing “Hello World” Message on Serial monitor

• Open ArduBlock
• Go to Communication tab, drag Serial Print block into the working area
• Once inserted in the working area change the message to Hello World!!! and
ensure that the newline is in True state in the block.
• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.
• For viewing the message click on the Serial Monitor button on the top right
corner

2. For Printing IR sensor value on Serial monitor

• Open ArduBlock
• Go to Communication tab, drag Serial Print block into the working area
• Once inserted in the working area change the message to IR sensor value is
and ensure that the newline is in True state in the block.
• From the communication tab, add a Glue block which has a square notch on
one side and a curved corner in the other end. This is required to add the next
block (Digital pin block)
• After the Glue block, add a Digital Pin # block from the Pins tab. Make sure
that the Pin number is D2.
• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.
• For viewing the message click on the Serial Monitor button on the top right
corner

Amrita School of Engineering Bengaluru 14


Amrita School of Engineering Bengaluru

3. Conditional Turning the LED ON and OFF based on IR sensor value

• Open ArduBlock
• Go to Control tab, drag if/else block into the working area. Once inserted in
the working area, add a Digital Pin # block from the Pins tab right next to the
test tab. Make sure that the Pin number is D2.
• Go to Digital Pins tab, drag Set Digital Pin # block into the working area and
place it next to then tab inside if/else block. Once inserted in the working area
change the pin number to D13 and ensure that the pin is in HIGH state in the
block.
• Go to Digital Pins tab, drag Set Digital Pin # block into the working area and
place it next to else tab inside if/else block. Once inserted in the working area
change the pin number to D13 and ensure that the pin is in LOW state in the
block.
• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.

Circuit Diagram

1. For printing “Hello World” message on the Serial monitor

2. For interfacing with IR sensor

Amrita School of Engineering Bengaluru 15


Amrita School of Engineering Bengaluru

ArduBlock Model

1. For Printing “Hello World” message on Serial monitor

2. For printing IR sensor value on the serial monitor

3. For conditional turning ON and OFF of LED based on IR sensor value

Arduino IDE Code

1. For printing “Hello World”

Amrita School of Engineering Bengaluru 16


Amrita School of Engineering Bengaluru

2. For interfacing with IR sensor

3. For conditional turning of LED ON or OFF based on IR sensor value

Amrita School of Engineering Bengaluru 17


Amrita School of Engineering Bengaluru

Experiment No: 3

Utilisation of Arduino controller to detect motion using PIR sensor and targets using
Ultrasonic sensor

Aim
To interface the Arduino Board with PIR sensor and Ultrasonic sensor and perform the
following
1. Detecting motion using the PIR sensor.
2. Calculate the distance of the obstacle from the Arduino board using Ultrasonic sensor.
Components required
Arduino Uno Board, USB power cable, PIR sensor, Ultrasonic sensor

Procedure
1. For detecting motion using PIR sensor

• Open ArduBlock
• Go to Communication tab, drag Serial Print block into the working area
• Once inserted in the working area change the message block to Human
Present?? and ensure that the newline is in True state in the block.
• From the communication tab, add a Glue block which has a square notch on
one side and a curved notch in the other end. This is required to add the next
block (Digital pin block)
• After the Glue block, add a Digital Pin # block from the Pins tab. Make sure
that the pin value is set to D2.
• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.
• For viewing the message click on the Serial Monitor button on the top right
corner

2. For calculating distance of the obstacle using Ultrasonic sensor

• Open ArduBlock
• Go to Communication tab, drag Serial Print block into the working area
• Once inserted in the working area remove the message block and ensure that
the newline is in True state in the block.
• From the communication tab, add a Glue block which has a square notch on
one side and a rotated V shaped notch in the other end. This is required to add
the next block (ultrasonic block)
• After the Glue block, add a Ultrasonic block from the Pins tab. Make sure
that the Trigger is set to D2 and Echo to D3 pins.

Amrita School of Engineering Bengaluru 18


Amrita School of Engineering Bengaluru

• Go to Generic Hardware tab, drag Delay Millis block into the working area
and place it below the Serial Print block and set the delay to 1000 ms.
• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.
• For viewing the message click on the Serial Monitor button on the top right
corner

Circuit Diagram

1. For detecting motion using PIR sensor

2. For detecting distance of obstacle from Arduino board using Ultrasonic sensor

Amrita School of Engineering Bengaluru 19


Amrita School of Engineering Bengaluru

ArduBlock Model

1. Detecting motion using PIR sensor

2. For calculating distance of obstacle from Arduino board using ultrasonic sensor

Arduino IDE Code

1. Detecting motion using PIR sensor

Amrita School of Engineering Bengaluru 20


Amrita School of Engineering Bengaluru

2. For calculating distance of obstacle from Arduino board using ultrasonic sensor

The code snippet before the setup and loop essentially declares the ultrasonic sensor
and the sensor sends a pulse of 20 microseconds duration through the trigger pin. The
duration variable denotes the time difference between the transmitted pulse and the
pulse generated by echo pin after reception. The speed of sound is 343 m/s or
approximately 0.0343 cm/μs (1/29.1545). The duration variable gives the time for the
wave to go and come back therefore the distance in cm is half of duration value
multiplied by speed in cm/μs. The ultrasonic sensor can only calculate distances
between 2 cm and 300 cm in this code.

Amrita School of Engineering Bengaluru 21


Amrita School of Engineering Bengaluru

Experiment No: 4
Interfacing Potentiometer and Buzzer with Arduino controller

Aim
To interface the Arduino Board with Buzzer and Potentiometer and perform the following
1. Reading of voltage value from Potentiometer.
2. Vary the ON time and OFF time of the LED using Potentiometer.
3. Implementation of voltage divider using Potentiometer
4. Interfacing of Arduino board with Buzzer
Components required
Arduino Uno Board, USB power cable, Buzzer, Potentiometer

Procedure

1. Reading the voltage value from Potentiometer

• Open ArduBlock
• Go to Communication tab, drag Serial Print block into the working area
• Once inserted in the working area change the message block to Pot Value and
ensure that the newline is in True state in the block.
• From the communication tab, add a Glue block which has a square notch on
one side and rotated V shaped notch in the other end. This is required to add
the next block (Analog pin block)
• After the Glue block, add a Analog Pin # block from the Pins tab. Make sure
that the pin value is set to A0.
• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.
• For viewing the message click on the Serial Monitor button on the top right
corner

2. For varying ON and OFF time of LED using Potentiometer

• Open ArduBlock
• Go to Variables/Constants tab, drag Set integer variable block into the
working area
• Once inserted in the working area change the variable block to Pot Value and
value as Analog Pin A0 after inserting Analog Pin # block from Pins tab.
• From the pins tab, add a Toggle Digital Pin block. Make sure that the pin
value is set to D13.
• After the Toggle Digital Pin block, add a Delay Millis block from the
Generic Hardware tab. Make sure that the delay value is set to Pot Value.

Amrita School of Engineering Bengaluru 22


Amrita School of Engineering Bengaluru

• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.

3. Implementation of voltage divider using Potentiometer with 2 LED


• Open ArduBlock
• Go to Communication tab, drag Serial Print block into the working area
• Once inserted in the working area change the message block to Reading: and
ensure that the newline is in True state in the block.
• After the Serial Print block, add a Delay Millis block from the Generic
Hardware tab. Make sure that the delay value is set to 1000.
• Go to Variables/Constants tab, drag Set integer variable block into the
working area
• Once inserted in the working area change the variable block to Pot Value and
value as Analog Pin A0 after inserting Analog Pin # block from Pins tab.
• Go to Variables/Constants tab, drag Set integer variable block into the
working area
• Once inserted in the working area change the variable block to Percent and in
the value remove the block 1 and insert map block from Math operators tab.
• From the variables/constants tab, select Integer block and insert it in the value
tab of map block. Change the value from Integer to Pot Value. Change the
range of from to 0 to 1023 and to block 0 to 100.
• Go to Communication tab, drag Serial Print block into the working area
• Once inserted in the working area change the message block to Percent= and
ensure that the newline is in True state in the block.
• From the communication tab, add a Glue block which has a square notch on
one side and rotated V shaped notch in the other end. This is required to add
the next block (Integer block)
• Go to Variables/Constants tab, select Integer block and insert it after the
message block. Change the value from Integer to Percent.
• Go to Control tab, drag if/else block into the working area. Once inserted in
the working area, add a < block from the Tests tab. From the
variables/constants tab, select Integer block and insert it before the < sign in
the < block. Change the value from Integer to Percent.
• From the variables/constants tab, select 1 block and insert it after the < sign in
the < block. Change the value from 1 to 50.
• Go to Digital Pins tab, drag Set Digital Pin # block into the working area and
place it next to then tab inside if/else block. Once inserted in the working area
change the pin number to D8 and ensure that the pin is in HIGH state in the
block.
• Add another Set Digital Pin # block into the working area and place it next to
then tab inside if/else block after the previous Set Digital Pin #. Once inserted
in the working area change the pin number to D9 and ensure that the pin is in
LOW state in the block.

Amrita School of Engineering Bengaluru 23


Amrita School of Engineering Bengaluru

• Add a Delay Millis block from the Generic Hardware tab. Make sure that the
delay value is set to 1000.
• Go to Digital Pins tab, drag Set Digital Pin # block into the working area and
place it next to else tab inside if/else block. Once inserted in the working area
change the pin number to D8 and ensure that the pin is in LOW state in the
block.
• Add another Set Digital Pin # block into the working area and place it next to
else tab inside if/else block after the previous Set Digital Pin #. Once inserted
in the working area change the pin number to D9 and ensure that the pin is in
HIGH state in the block.
• Add a Delay Millis block from the Generic Hardware tab. Make sure that the
delay value is set to 1000.
• Click on Upload to Arduino and run the code by first clicking on the Verify
button and then Upload button in Arduino IDE.
• For viewing the message click on the Serial Monitor button on the top right
corner
4. Interfacing Arduino with Buzzer
• Open ArduBlock
• From the Pins tab, select Tone block with pin#, frequency and milliseconds
tab. Change the pin number to D9, frequency to 1000 and delay to 1000.
• From the Pins tab, select No tone block. Make sure that the pin number is D9.
• Add a Delay Millis block from the Generic Hardware tab. Make sure that the
delay value is set to 1000.

Circuit Diagram

1. For reading voltage and varying the ON and OFF time of LED

Amrita School of Engineering Bengaluru 24


Amrita School of Engineering Bengaluru

2. Implementation of voltage divider using Potentiometer and 2 LED

3. Interfacing of Arduino with Buzzer

Amrita School of Engineering Bengaluru 25


Amrita School of Engineering Bengaluru

ArduBlock Model

1. For reading voltage value from potentiometer

2. For varying ON and OFF time of LED using Potentiometer

3. Implementing voltage divider with 2 LED and Potentiometer

Amrita School of Engineering Bengaluru 26


Amrita School of Engineering Bengaluru

4. Interfacing of Arduino with Buzzer

Arduino IDE Code

1. Reading Voltage value from Potentiometer

2. Varying ON and OFF time of LED using Potentiometer

Amrita School of Engineering Bengaluru 27


Amrita School of Engineering Bengaluru

3. Implementation of Voltage Divider using 2 LEDs and Potentiometer

4. Interfacing of Arduino with Buzzer

Amrita School of Engineering Bengaluru 28

You might also like