You are on page 1of 64

MADANAPALLE INSTITUTE OF TECHNOLOGY &

SCIENCE
(UGC AUTONOMUS)

MADANAPALLE – 517325

18ECE209 – INTERNET OF THINGS


LABORATORY MANUAL

DEPARTMENT OF
ELECTRONICS & COMMUNICATION ENGINEERING
(R18 BATCH)

1
MADANAPALLE INSTITUTE OF TECHNOLOGY &
SCIENCE
(UGC AUTONOMUS)

MADANAPALLE – 517325

LABORATORY MANUAL
FOR
INTERNET OF THINGS- 18ECE209
DEPARTMENT OF
ELECTRONICS & COMMUNICATION ENGINEERING
(2020 -2021)
PREPEARED BY VERFIFED BY APPROVED BY
Name: Name:Dr.Sathesh.K Name: Dr.S.Rajeskaran
Dr.Satrughan Kumar
Dr.Bibhuti Bhusan Pradhan
Dr.Sharwan Ram
Dr.Velmani Ramasamy
Dr.Sambhudutta Nanda
Dr.Sumit Gupta
Designation: Designation: Assoc. Professor Designation: Professor &Head
Professor
Sr.Asst. Professor
Assoc. Professor
Asst. Professor

Signature: Signature: Signature:

2
MADANAPALLE INSTITUTE OF TECHMOLOGY & SCIENCE
(UCG-AUTONOMOUS)
Affiliated to JNTUA, Ananthapuramu & Approved by AICTE, New Delhi
Recognised Research Center, Accredited by NBA, NAAC for CSE, ECE, EEE, ME & MBA
World Bank Funded Institute, Recognised by UGC under the sections 2(f) and 12(B) of the UGC act 1956
Recognised as Scientific & Industrial Research Organization by DSIR of DST
Department of Electronics & Communication Engineering
---------------------------------------------------------------------------------------------------------------------

Name of the Lab Course : Internet of Things Laboratory-18ECE209

Code : 18ECE209 Programme: UG


Branch: ECE Version No: 1
Year : III Updated on:22/02/21
Semester : II No. of Pages:72

Classification Status(Unrestricted/restricted):Unrestricted
Distribution List : Department, Lab, Lab Incharge
PREPEARED BY VERFIFED BY APPROVED BY
Name: Name: Dr.Sathesh.K Name: Dr.S.Rajeskaran
Dr.Satrughan Kumar
Dr.Bibhuti Bhusan Pradhan
Dr.Sharwan Ram
Dr.Velmani Ramasamy
Dr.Sambhudutta Nanda
Dr.Sumit Gupta

Designation: Designation: Assoc. Professor Designation: Professor &Head


Professor
Sr.Asst. Professor
Assoc. Professor
Asst. Professor

Signature: Signature: Signature:

3
MADANAPALLE INSTITUTE OF TECHMOLOGY & SCIENCE
(UCG-AUTONOMOUS)
Affiliated to JNTUA, Ananthapuramu & Approved by AICTE, New Delhi
Recognised Research Center, Accredited by NBA, NAAC for CSE, ECE, EEE, ME & MBA
World Bank Funded Institute, Recognised by UGC under the sections 2(f) and 12(B) of the UGC act 1956
Recognised as Scientific & Industrial Research Organization by DSIR of DST
Department of Electronics & Communication Engineering
---------------------------------------------------------------------------------------------------------------------

VISION AND MISSION OF THE INSTITUTE


VISION
To become a globally recognized research and academic institution and thereby contribute to
technological and socio-economic development of the nation.

MISSION
To foster a culture of excellence in research, innovation, entrepreneurship, rational thinking
and civility by providing necessary resources for generation, dissemination and utilization of
knowledge and in the process create an ambience for practice-based learning to the youth for
success in their careers.

VISION AND MISSION OF THE DEPARTMENT

VISION
To excel in technical education and research in the area of Electronics and Communication
Engineering to produce skilled, trained and competent individuals with high motivation to
meet the present-day challenges of the society.

MISSION
M1 Impart high quality education to enable students to face the challenges in the
fields of Electronics and Communication Engineering.

M2 Provide facilities, infrastructure, environment to develop the spirit of


innovation, creativity, and research among students and faculty.

4
M3 Inculcate ethical, moral values and lifelong learning skills in students to address
the societal needs.

MADANAPALLE INSTITUTE OF TECHMOLOGY & SCIENCE


(UCG-AUTONOMOUS)
Affiliated to JNTUA, Ananthapuramu & Approved by AICTE, New Delhi
Recognised Research Center, Accredited by NBA, NAAC for CSE, ECE, EEE, ME & MBA
World Bank Funded Institute, Recognised by UGC under the sections 2(f) and 12(B) of the UGC act 1956
Recognised as Scientific & Industrial Research Organization by DSIR of DST
Department of Electronics & Communication Engineering
---------------------------------------------------------------------------------------------------------------------

PROGRAM EDUCATIONAL OBJECTIVES (PEOs)

PEO1 For successful employment in Electronics and Communication Engineering


To design, test and develop the state-of-the-art hardware and software in
PEO2
Electronics and Communication Engineering
PEO3 For lifelong learning skills, societal ethics and higher education.

PROGRAM OUTCOMES (POs)

Engineering knowledge: Apply the knowledge of mathematics, science,


PO1 engineering fundamentals, and an engineering specialization to the solution
of complex engineering problems.
Problem analysis: Identify, formulate, review research literature, and
analyze complex engineering problems reaching substantiated conclusions
PO2
using first principles of mathematics, natural sciences, and engineering
sciences.
Design/development of solutions: Design solutions for complex
engineering problems and design system components or processes that meet
PO3
the specified needs with appropriate consideration for the public health and
safety, and the cultural, societal, and environmental considerations.
Conduct investigations of complex problems: Use research-based
knowledge and research methods including design of experiments, analysis
PO4
and interpretation of data, and synthesis of the information to provide valid
conclusions.
Modern tool usage: Create, select, and apply appropriate techniques,
resources, and modern engineering and IT tools including prediction and
PO5
modeling to complex engineering activities with an understanding of the
limitations.
The engineer and society: Apply reasoning informed by the contextual
PO6 knowledge to assess societal, health, safety, legal and cultural issues and the
consequent responsibilities relevant to the professional engineering practice.
5
Environment and sustainability: Understand the impact of the professional
PO7 engineering solutions in societal and environmental contexts, and
demonstrate the knowledge of, and need for sustainable development.
Ethics: Apply ethical principles and commit to professional ethics and
PO8
responsibilities and norms of the engineering practice.
Individual and team work: Function effectively as an individual, and as a member or
PO9
leader in diverse teams, and in multidisciplinary settings.
Communication: Communicate effectively on complex engineering
activities with the engineering community and with society at large, such as,
PO10 being able to comprehend and write effective reports and design
documentation, make effective presentations, and give and receive clear
instructions.
Project management and finance: Demonstrate knowledge and
understanding of the engineering and management principles and apply
PO11
these to one’s own work, as a member and leader in a team, to manage
projects and in multidisciplinary environments.
Life-long learning: Recognize the need for, and have the preparation and
PO12 ability to engage in independent and life-long learning in the broadest
context of technological change.

PROGRAM SPECIFIC OUTCOMES (PSOs)

Design and analyze systems in the field of Electronics and Communication


PSO1
Engineering.
Apply the concepts to design and develop solutions in the field of VLSI & Embedded
PSO2
System.
Analyse and develop hardware/software applications in the field of Signal & System
PSO3
Engineering.

6
MADANAPALLE INSTITUTE OF TECHMOLOGY & SCIENCE
(UCG-AUTONOMOUS)
Affiliated to JNTUA, Ananthapuramu & Approved by AICTE, New Delhi
Recognised Research Center, Accredited by NBA, NAAC for CSE, ECE, EEE, ME & MBA
World Bank Funded Institute, Recognised by UGC under the sections 2(f) and 12(B) of the UGC act 1956
Recognised as Scientific & Industrial Research Organization by DSIR of DST
Department of Electronics & Communication Engineering
---------------------------------------------------------------------------------------------------------------------

ATTAINMENT OF PROGRAM OUTCOMES


&
PROGRAM SPECIFIC OUTCOMES
S.No Experiment Program Program Specific
Outcomes Outcomes Attained
Attained Obtained
1. Study on IoT Platform(Getting information PO1,PO2 PSO1
and study of IOT microcontrollers)
2. Study on IoT Platform
a)Getting information about Sensors (IR,
tempe-rature, pressure, gas sensor)
b) Getting information about actuators
(Piezoelectric actuator, pneumatic actuator).
3. . Programming with Arduino platform
a)Installation of Arduino in computer and
verifying any errors in connection.
b) Control LED using Arduino
c) Traffic Light Control
4. Programming with Arduino platform and
Reading from Sensors
a) interfacing sensors to Arduino board and
getting information from them (anytwosensors).
b) Experiment with both analog and digital
sensors.
5. Programming with Resperrypi
a) Displaying Date on Serial Monitor
b) Automated Door Opening System
6. Connecting Android Phone with Arduino
a) Connecting Arduino with Mobile Device
Using the Bluetooth Module.
b) Control any two actuators connected to the
development board using Bluetooth.
7. Integrating Ethernet Shield.
Read data from sensor and send it to a
requesting client using socket communication.
Note: The client and server should be connected
to same local area network

7
8. Creating Mobile App
a) Create a mobile app to control an actuator.
b) Control Electronic Devices from anywhere
across the world using Internet & Mobile
App.
9. Interfacing Cloud
a) Push sensor data to cloud - Use Arduino to
Upload data from Environmental Sensors to
Cloud Server.
b) Control an actuator through cloud
10. Data analysis and Visualization
Access the data pushed from sensor to cloud
and apply any data analytics or visualization
services.
11. Social media with IoT
Creating Program for Local host Web Server
for controlling devices and update status on
Twitter through Arduino.
Content beyond Syllabus
12. Home Automation
13.
14.

8
MADANAPALLE INSTITUTE OF TECHMOLOGY & SCIENCE
(UCG-AUTONOMOUS)
Affiliated to JNTUA, Ananthapuramu & Approved by AICTE, New Delhi
Recognised Research Center, Accredited by NBA, NAAC for CSE, ECE, EEE, ME & MBA
World Bank Funded Institute, Recognised by UGC under the sections 2(f) and 12(B) of the UGC act 1956
Recognised as Scientific & Industrial Research Organization by DSIR of DST

Department of Electronics & Communication Engineering


---------------------------------------------------------------------------------------------------------------------
SYLLABUS
18ECE209 INTERNET OF THINGS PRACTICALS
Course Prerequisite: 18ECE209

Course Description
This course provide hands-on practices on IoT using Arduino & Raspberry microcontrollers with
various interfaces such as sensors, actuators, mobile app, cloud, social media.
Course Objectives
1. To understand working principles of IoT devices
2. To get exposure towards the IoT internals.
3. To understand the concepts of real world designs, industrial automation and commercial
needs for designing IOT enabled solution

LIST OF EXPERIMENTS:
1. Study on IoT Platform
a) Getting information and study of IOT microcontrollers (Arduino, Resperrypi)
2. Study on IoT Platform
a) Getting information about Sensors (IR, temperature, pressure, gas sensor)
b) Getting information about actuators. (Piezoelectric actuator, pneumatic actuator)
3. Programming with Arduino platform
a) Installation of Arduino in computer and verifying any errors in connection.
b) Control LED using Arduino
c) Traffic Light Control
4.Programming with Arduino platform and Reading from Sensors
a) interfacing sensors to Arduino board and getting information from them (any two sensors).
b) Experiment with both analog and digital sensors.
5.Programming with Resperrypi
a) Displaying Date on Serial Monitor
b) Automated Door Opening System
6.Connecting Android Phone with Arduino
a) Connecting Arduino with Mobile Device Using the Bluetooth Module.
b) Control any two actuators connected to the development board using Bluetooth.
7. Integrating Ethernet Shield. Read data from sensor and send it to a requesting client using
socket communication.

9
8. Creating Mobile App
a) Create a mobile app to control an actuator.
b) Control Electronic Devices from anywhere across the world using Internet & Mobile App.
9. Interfacing Cloud
a) Push sensor data to cloud - Use Arduino to Upload data from Environmental Sensors to
Cloud Server.
b) Control an actuator through cloud
10. Data analysis and Visualization
Access the data pushed from sensor to cloud and apply any data analytics or visualization
services.
11. Social media with IoT
Creating Program for Local host Web Server for controlling devices and update status on
Twitter through Arduino.
12. Mini Project Identify a problem in your local area or college which can be solved by
integrating the things you learned so far and create a prototype to solve it.

Course Outcomes
Upon successful completion of the course, students will be able to
1. Choose the sensors and actuators for an IoT application
2. Select protocols for a specific IoT application.
3. Utilize the cloud platform and APIs for IoT application .
4. Experiment with embedded boards for creating IoT prototypes.
5. Design and develop a solution for a given IoT application.

10
LIST OF EXPERIMENTS

S. No. Experiment Page No.

1 Study on IoT Platform(Getting information and study of IOT 14-32


microcontrollers)
Study on IoT Platform
2 a)Getting information about Sensors (IR, temperature, pressure, 33-41
gas sensor)
b) Getting information about actuators(Piezoelectric actuator,
pneumatic actuator).
Programming with Arduino platform
3 a)Installation of Arduino in computer and verifying any errors in 42-52
connection.
b) Control LED using Arduino
c) Traffic Light Control
Programming with Arduino platform and Reading from Sensors
4 a) interfacing sensors to Arduino board and getting information from 53-55
them (any two sensors).
b) Experiment with both analog and digital sensors.
Programming with Resperrypi
5 a) Displaying Date on Serial Monitor 56-60
b) Automated Door Opening System
Connecting Android Phone with Arduino
6 a) Connecting Arduino with Mobile Device Using the Bluetooth 61-66
Module.
b) Control any two actuators connected to the development board
using Bluetooth.
Integrating Ethernet Shield.
7 Read data from sensor and send it to a requesting client using socket
communication. Note: The client and server should be connected to
same local area network
Creating Mobile App
8 a) Create a mobile app to control an actuator. 67-70
b) Control Electronic Devices from anywhere
across the world using Internet & Mobile App.
Interfacing Cloud
9 a) Push sensor data to cloud - Use Arduino to Upload data from 71-
Environmental Sensors to Cloud Server.
b) Control an actuator through cloud
Data analysis and Visualization
10 Access the data pushed from sensor to cloud and apply any data 72-
analytics or visualization services.

11
Social media with IoT
11 Creating Program for Local host Web Server for controlling devices
and update status on Twitter through Arduino.

12
GENERAL GUIDELINES AND SAFETY INSTRUCTIONS
1. Sign in the log register as soon as you enter the lab and strictly observe your lab
timings.
2. Strictly follow the written and verbal instructions given by the teacher / Lab
Instructor. If you do not understand the instructions, the handouts and the procedures,
ask the instructor or teacher.
3. Never work alone! You should be accompanied by your laboratory partner and / or
the instructors / teaching assistants all the time.
4. It is mandatory to come to lab in a formal dress and wear your ID cards.
5. Do not wear loose-fitting clothing or jewelry in the lab. Rings and necklaces are usual
excellent conductors of electricity.
6. Mobile phones should be switched off in the lab. Keep bags in the bag rack.
7. Keep the labs clean at all times, no food and drinks allowed inside the lab.
8. Intentional misconduct will lead to expulsion from the lab.
9. Do not handle any equipment without reading the safety instructions. Read the
handout and procedures in the Lab Manual before starting the experiments.
10. Do your wiring, setup, and a careful circuit checkout before applying power. Do not
make circuit changes or perform any wiring when power is on.
11. Avoid contact with energized electrical circuits.
12. Do not insert connectors forcefully into the sockets.
13. NEVER try to experiment with the power from the wall plug.
14. Immediately report dangerous or exceptional conditions to the Lab instructor /
teacher: Equipment that is not working as expected, wires or connectors are broken,
the equipment that smells or “smokes”. If you are not sure what the problem is or
what's going on, switch off the Emergency shutdown.
15. Never use damaged instruments, wires or connectors. Hand over these parts to the
Lab instructor/Teacher.
16. Never use damaged instruments, wires or connectors. Hand over these parts to the
Lab instructor/Teacher.
17. Observation book and lab record should be carried to each lab. Readings of current
lab experiment are to be entered in Observation book and previous lab experiment
should be written in Lab record book. Both the books should be corrected by the
faculty in each lab.

13
Experiment No. 1
AIM: Getting information and study of IOT microcontrollers (Arduino and Raspberry Pi)

1. Theory
PART A: Study on Arduino Board.

1.1 Introduction to Arduino Uno Board


Arduino Uno is a microcontroller board based on the 8-bit ATmega328P microcontroller as
shown in Figure 1. Along with ATmega328P, it also contains other components, such as crystal
oscillator, serial communication, voltage regulator, etc. to support the microcontroller. Arduino
Uno has 14 digital input/output pins (6 of which can be used as PWM outputs), 6 analog input
pins, USB connection, power barrel jack, ICSP connector and reset button. It is an open-source
platform, means the boards and software are readily available and anyone can modify and
optimize the boards for better functionality.

Figure 1.1 Arduino UNO Board (ATmega328p).

The software used for Arduino devices is called IDE (Integrated Development Environment)
which is free to use and required some basic skills to learn it. It can be programmed using C and
C++ language. Some people get confused between Microcontroller and Arduino. While former is
just an on system 40 pin chip that comes with a built-in microprocessor and later is a board that

14
comes with the microcontroller in the base of the board, bootloader and allows easy access to
input-output pins and makes uploading or burning of the program very easy.

Table 1.1 shows the pin category, pin names and its functionality in detail.

Pin Category Pin Name Details


I. Power Vin, 3.3V, 5V, Vin: Input voltage to Arduino when using
GND an external power source.
5V: Regulated power supply used to power
microcontroller and other components on
the board.
3.3V: 3.3V supply generated by on-board
voltage regulator. Maximum current draw is
50mA.
GND: ground pins.
ii Reset Reset Resets the microcontroller.
iii Analog Pins A0 – A5 Used to provide analog input in the range of
0-5V
iv Input/Output Digital Pins 0 - 13 Can be used as input or output pins.
Pins
v Serial 0(Rx), 1(Tx) Used to receive and transmit TTL serial
data.
vi External 2, 3 To trigger an interrupt.
Interrupts
vii PWM 3, 5, 6, 9, 11 Provides 8-bit PWM output.
viii SPI 10 (SS), 11 Used for SPI communication.
(MOSI), 12
(MISO) and 13
(SCK)
ix Inbuilt LED 13 To turn on the inbuilt LED.
x TWI A4 (SDA), A5 Used for TWI communication.
(SCA)
xi AREF AREF To provide reference voltage for input
voltage.

Table 1.2 Technical Specifications of Arduino Uno Board


S. NO Components Specifications
i Microcontroller ATmega328P – 8 bit AVR family
microcontroller
ii Operating Voltage 5V
iii Recommended Input Voltage 7-12V
iv Input Voltage Limits 6-20V
v Analog Input Pins 6 (A0 – A5)

15
vi Digital I/O Pins 14 (Out of which 6 provide PWM
output)
vii DC Current on I/O Pins 40 mA
viii DC Current on 3.3V Pin 50 mA
ix Flash Memory 32 KB (0.5 KB is used for Bootloader)
x SRAM 2 KB
xi EEPROM 1 KB
xii Frequency (Clock Speed) 16 MHz

1.4 Arduino Uno to ATmega328 Pin Mapping

When ATmega328 chip is used in place of Arduino Uno, or vice versa, the image below
shows the pin mapping between the two.

Figure 1.2 ATmega328 Pin Mapping

1.5 How to use Arduino Board

1.5.1 Digital Pins


The 14 digital input/output pins can be used as input or output pins by using pinMode(),
digitalRead() and digitalWrite() functions in arduino programming. Each pin operates at 5V and

16
can provide or receive a maximum of 40mA current, and has an internal pull-up resistor of 20-50
KOhms which are disconnected by default. Out of these 14 pins, some pins have specific
functions as listed below:

1. Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. On
the Arduino Diecimila, these pins are connected to the corresponding pins of the FTDI USB-
to-TTL Serial chip. On the Arduino BT, they are connected to the corresponding pins of
the WT11 Bluetooth module. On the Arduino Mini and LilyPad Arduino, they are intended for
use with an external TTL serial module (e.g. the Mini-USB Adapter).

2. External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a


low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for
details.

3. PWM: 3, 5, 6, 9, 10, and 11. provide 8-bit PWM output with the analogWrite() function.
On boards with an ATmega8, PWM output is available only on pins 9, 10, and 11.

4. BT Reset: 7. (Arduino BT-only) Connected to the reset line of the Bluetooth module.

5. SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication,
which, although provided by the underlying hardware, is not currently included in the
Arduino language.

6. LED: 13. On the Diecimila and LilyPad, there is a built-in LED connected to digital pin 13.
When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

1.5.2 Analog Pins


In addition to the specific functions listed below, the analog input pins support 10-bit analog-to-
digital conversion (ADC) using the analogRead() function. Most of the analog inputs can also be
used as digital pins: analog input 0 as digital pin 14 through analog input 5 as digital pin 19.
Analog inputs 6 and 7 (present on the Mini and BT) cannot be used as digital pins.

17
 I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire
library (documentation on the Wiring website).

1.5.3 Power Pins

 VIN (sometimes labelled "9V"). The input voltage to the Arduino board when it's using
an external power source (as opposed to 5 volts from the USB connection or other
regulated power source). You can supply voltage through this pin, or, if supplying
voltage via the power jack, access it through this pin. Note that different boards accept
different input voltages ranges, please see the documentation for your board. Also note
that the LilyPad has no VIN pin and accepts only a regulated input.
 5V. The regulated power supply used to power the microcontroller and other components
on the board. This can come either from VIN via an on-board regulator, or be supplied by
USB or another regulated 5V supply.
 3V3. (Diecimila-only) A 3.3 volt supply generated by the on-board FTDI chip.
 GND. Ground pins.

1.5.4 Other Pins

1. AREF. Reference voltage for the analog inputs. Used with analogReference().

2. Reset. (Diecimila-only) Bring this line LOW to reset the microcontroller. Typically used
to add a reset button to shields which block the one on the board.

1.6 Architecture and basic working of CPU of ATmega328


1. The data is uploaded in serial via the port (being uploaded from the computer’s Arduino
IDE). The data is decoded and then the instructions are sent to instruction register and it
decodes the instructions on the same clock pulse.
2. On the next clock pulse the next set of instructions are loaded in instruction register.
3. In general purpose registers the registers are of 8-bit but there are 3 16-bit registers also.
i) 8-bit registers are used to store data for normal calculations and results.

18
ii) 16-bit registers are used to store data of timer counter in 2 different register. Eg. X-
low & X-high. They are fast, and are used to store specific hardware functions

Figure 1.4 Architecture of Arduino Uno (ATmega328 IC)

4. EEPROM stores data permanently even if the power is cut out. Programming inside a
EEPROM is slow.

5. Interrupt Unit checks whether there is an interrupt for the execution of instruction to be
executed in ISR (Interrupt Service Routine).

6. Serial Peripheral Interface (SPI) is an interface bus commonly used to send data between
microcontrollers and small peripherals such as Camera, Display, SD cards, etc. It uses

19
separate clock and data lines, along with a select line to choose the device you wish to talk to.

7.Watchdog timer is used to detect and recover from MCU malfunctioning.

8. Analog comparator compares the input values on the positive and negative pin, when the
value of positive pin is higher the output is set.

9. Status and control is used to control the flow of execution of commands by checking other
blocks inside the CPU at regular intervals

10. ALU (Arithmetic and Logical unit)The high performance AVR ALU operates in direct
connection with all the 32 general purpose working registers. Within a single clock cycle,
arithmetic operations b/w general purpose registers are executed. The ALU operations are
divided into 3 main categories – arithmetic, logical and bit-function.

11. I/O pins The digital inputs and outputs (digital I/O) on the Arduino are what allow you to
connect the Arduino sensors, actuators, and other ICs. Learning how to use them will allow
you to use the Arduino to do some really useful things, such as reading switch inputs, lighting
indicators, and controlling relay outputs.

1.7 Communication in Arduino board


Arduino can be used to communicate with a computer, another Arduino board or other
microcontrollers. The ATmega328P microcontroller provides UART TTL (5V) serial
communication which can be done using digital pin 0 (Rx) and digital pin 1 (Tx). An
ATmega16U2 on the board channels this serial communication over USB and appears as a
virtual com port to software on the computer. The ATmega16U2 firmware uses the standard
USB COM drivers, and no external driver is needed. However, on Windows, a .inf file is
required. The Arduino software includes a serial monitor which allows simple textual data to be
sent to and from the Arduino board. There are two RX and TX LEDs on the arduino board which
will flash when data is being transmitted via the USB-to-serial chip and USB connection to the
computer (not for serial communication on pins 0 and 1). A SoftwareSerial library allows for
serial communication on any of the Uno's digital pins. The ATmega328P also supports I2C
(TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of
the I2C bus.
20
1.8 Software and programing on Arduino board

1.8.1 Software

Arduino IDE (Integrated Development Environment) is required to program the Arduino Uno
board https://www.arduino.cc/en/software.

1.8.2 Programming Arduino

Once arduino IDE is installed on the computer, connect the board with computer using USB
cable. Now open the arduino IDE and choose the correct board by selecting
Tools>Boards>Arduino/Genuino Uno, and choose the correct Port by selecting Tools>Port.
Arduino Uno is programmed using Arduino programming language based on Wiring. To get it
started with Arduino Uno board and blink the built-in LED, load the example code by selecting
Files>Examples>Basics>Blink. Once the example code (also shown below) is loaded into your
IDE, click on the ‘upload’ button given on the top bar. Once the upload is finished, you should
see the Arduino’s built-in LED blinking. Below is the example code for blinking:

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever


void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

21
1.9 Application on Arduino board
1. Prototyping of Electronics Products and Systems
2. Multiple DIY Projects.
3. Easy to use for beginner level DIYers and makers.
3. Projects requiring Multiple I/O interfaces and communications.

PART B: Study on Raspberry Pi.

2.1 Introduction to Raspberry Pi

Raspberry Pi is a series of small single-board computers developed in the United Kingdom by


the Raspberry Pi Foundation in association with Broadcom. The Raspberry Pi project originally
leaned towards the promotion of teaching basic computer science in schools and in developing
countries. Created by the Raspberry Pi Foundation, the Raspberry Pi is an open-source, Linux
based, credit card sized computer board. The Pi is an exciting and accessible means of improving
computing and programming skills for people of all ages. By connecting to your TV or monitor
and a keyboard, and with the right programming, the Pi can do many things that a desktop
computer can do such as surf the internet and play video. The Pi is also great for those innovative
projects that you want to try out - newer models are ideal for Internet of Things projects due to
their processing power. With Pi 3, Wireless LAN and Bluetooth Low Energy are on-board too.
The original model became more popular than anticipated, selling outside its target market for
uses such as robotics. It is widely used in many areas, such as for weather monitoring because of
its low cost, modularity, and open design. It is typically used by computer and electronic
hobbyists, due to its adoption of HDMI and USB devices.

2.1.1 Generations of Raspberry Pi


Several generations of Raspberry Pis have been released.
1. The first generation (Raspberry Pi Model B) was released in February 2012, followed by
the simpler and cheaper Model A. These first generation boards feature ARM11 processors,
are approximately credit-card sized and represent the standard mainline form-factor.

22
2. The Raspberry Pi 2 was released in February 2015 and initially featured a 900 MHz 32-
bit quad-core ARM Cortex-A7 processor with 1 GiB RAM. Later versions featured a
1.2 GHz 64-bit quad-core ARM Cortex-A53 processor.
3. Raspberry Pi 3 Model B was released in February 2016 with a 1.2 GHz 64-bit quad
core ARM Cortex-A53 processor, on-board 802.11n Wi-Fi, Bluetooth and USB boot
capabilities. On Pi Day 2018, the Raspberry Pi 3 Model B+ was launched with a faster
1.4 GHz processor, a three-times faster gigabit Ethernet (throughput limited to ca.
300 Mbit/s by the internal USB 2.0 connection), and 2.4 / 5 GHz dual-band 802.11ac Wi-Fi
(100 Mbit/s).
4. Raspberry Pi 4 Model B was released in June 2019 with a 1.5 GHz 64-bit quad
core ARM Cortex-A72 processor, on-board 802.11ac Wi-Fi, Bluetooth 5, full gigabit
Ethernet (throughput not limited), two USB 2.0 ports, two USB 3.0 ports, and dual-monitor
support via a pair of micro HDMI (HDMI Type D) ports for up to 4K resolution. The Pi 4 is
also powered via a USB-C port, enabling additional power to be provided to downstream
peripherals, when used with an appropriate PSU.
5. Raspberry Pi 400 was released in November 2020. It features a custom board that is
derived from the existing Raspberry Pi 4, specifically remodelled with a keyboard attached.
A robust cooling solution similar to the one found in a Commodore 64 allows the Raspberry
Pi 400's Broadcom BCM2711C0 processor to be clocked at 1.8 GHz, which is slightly higher
than the Raspberry Pi 4. The keyboard-computer features 4 GiB of LPDDR4 RAM.

6. Raspberry Pi Pico was released in January 2021 with a retail price of $4. It was
Raspberry Pi's first board based upon a single microcontroller chip; the RP2040, which was
designed by Raspberry Pi in the UK. The Pico has 264 KiB of RAM and 2 MiB of flash
memory. It is programmable in MicroPython, Circuit Python, and C.

2.2 The Raspberry Pi 3 Model B

The Raspberry Pi 3 Model B builds upon the features of its predecessors with a new, faster
processor on board to increase its speed. It also features WiFi and Bluetooth Low Energy

23
capabilities to enhance the functionality and the ability to power more powerful devices over the
USB ports.

1. Quad Core 1.2GHz Broadcom BCM2837 64bit CPU,1GB RAM

2. BCM43438 WiFi and Bluetooth Low Energy (BLE) on board

3. 40-pin Extended GPIO

4. 4x USB 2 ports

5. 4 Pole stereo output and composite video port, Full size HDMI

6. CSI camera port for connecting a Raspberry Pi camera

7. DSI display port for connecting a Raspberry Pi touchscreen display

8. Micro SD port for loading your operating system and storing data

9. Upgraded switched Micro USB power source up to 2.5A.

2.3 The IC of Raspberry Pi 3 Model B

Figure 1.5 Raspberry Pi 3 Model B

24

Figure 1.6 Raspberry Pi 3 Model B-Pin configuration

2.4 Table 3 shows the pin category of Raspberry Pi 3 pin names and its functionality in detail.

PIN GROUP PIN NAME DESCRIPTION

POWER SOURCE +5V, +3.3V, GND and Vin +5V -power output
+3.3V -power output
GND – GROUND pin
COMMUNICATION UART Interface(RXD, UART (Universal Asynchronous
INTERFACE TXD) [(GPIO15,GPIO14)] Receiver Transmitter) used for
interfacing sensors and other
devices.
SPI Interface (MOSI, MISO, CLK, CE) x 2 SPI (Serial Peripheral Interface)
[SPI0-(GPIO10, GPIO9, GPIO11, used for communicating with
GPIO8)] other boards or peripherals.
[SPI1--(GPIO20,GPIO19,
GPIO21, GPIO7)]
TWI Interface (SDA, SCL) x 2 [(GPIO2, TWI (Two Wire Interface)
GPIO3)] Interface can be used to connect
[(ID_SD,ID_SC)] peripherals.
INPUT OUTPUT PINS 26 I/O Although these some pins have
multiple functions they can be
considered as I/O pins.
PWM Hardware PWM available on These 4 channels can provide
GPIO12, GPIO13, GPIO18, PWM (Pulse Width Modulation)

25
GPIO19 outputs.
*Software PWM available on all
pins
EXTERNAL All I/O In the board all I/O pins can be
INTERRUPTS used as Interrupts.

2.5 Table 4 shows Technical Specifications Raspberry Pi 3


Name Description
Microprocessor Broadcom BCM2837 64bit Quad Core Processor
Processor Operating 3.3V
Voltage
Raw Voltage input 5V, 2A power source
Maximum current through 16mA
each I/O pin
Maximum total current 54mA
drawn from all I/O pins
Flash Memory (Operating 16Gbytes SSD memory card
System)
Internal RAM 1Gbytes DDR2
Clock Frequency 1.2GHz
GPU Dual Core Video Core IV® Multimedia Co-Processor. Provides
Open GLES 2.0, hardware-accelerated Open VG, and 1080p30
H.264 high- profile decode.
Capable of 1Gpixel/s, 1.5Gtexel/s or 24GFLOPs with texture
filtering and DMA infrastructure.
Ethernet 10/100 Ethernet
Wireless Connectivity BCM43143 (802.11 b/g/n Wireless LAN and Bluetooth 4.1)
Operating Temperature -40ºC to +85ºC

2.6 Table 4 shows Board Connectors of Raspberry Pi 3


Name Description
Ethernet Base T Ethernet Socket
USB 2.0 (Four sockets)
Audio Output 3.5mm Jack and HDMI
Video output HDMI
Camera 15-pin MIPI Camera Serial Interface (CSI-2)
Connector
Display Display Serial Interface (DSI) 15 way flat flex cable connector with two data
Connector lanes and a clock lane.
Memory Card Push/Pull Micro SDIO
Slot

26
2.7 How to Use RASPBERRY PI 3

As mentioned earlier PI is simply a COMPUTER ON A SINGLE BOARD so it cannot be used


like ARDUINO development boards. For the PI to start working we need to first install
OPERATING SYSTEM. This feature is similar to our PC. The PI has dedicated OS for it; any
other OS will not work.
We will discuss the programming of PI in step by step below.

1. Take the 16GB micro SD card and dedicate it specifically for PI OS.
2. Choose and Download OS software. [https://www.raspberrypi.org/downloads/]
(‘NOOBS’ recommended for beginners )
3. Format the SD card and install OS on to the SD memory card using convenient methods.
4. Take the SD card after OS installation and insert it in PI board.
5. Connect monitor, keyboard and mouse
6. Power the board with micro USB connector
7. Once the power is tuned ON the PI will run on the OS installed in the memory card and
will start from boot.
8. Once all drivers are checked the PI will ask for authorization, this is set by default and
can be changed.
9. After authorization you will reach desktop where all application program development
starts.

On the PI you can download application programs required for your use and can directly install
as you do for your PC. After that you can work on developing required program and get the PI
run the developed programs.

2.8 Programming Languages on RASPBERRY PI 3

Python is the recommended programming language — particularly if you are new to


programming or want to refresh your programming knowledge. Scratch is a great interactive
programming language for children who want to learn to code through creating games, stories
and animations. Other programming languages you can get on your Pi include C, C++, Java and
Ruby.

2.9 Application on RASPBERRY PI 3

1. Hobby projects.
2. Low cost PC/tablet/laptop
3. IoT applications

27
4. Media center
5. Robotics
6. Industrial/Home automation
7. Server/cloud server
8. Print server
9. Security monitoring
10. Web camera
11. Gaming
12. Wireless access point
13. Environmental sensing/monitoring (e.g. WEATHER STATION)

2.10 Detailed description of components:


2.10.1 System Timer: The System Timer peripheral provides four 32-bit timer channels and a
single 64-bit free running counter. Each channel has an output compare register, which is
compared against the 32 least significant bits of the free running counter values.

2.10.2 The Processor: At the heart of the Raspberry Pi is the same processor you would have
found in the iPhone 3G and the Kindle 2, so you can think of the capabilities of the Raspberry Pi
as comparable to those powerful little devices. This chip is a 32 bit, 700 MHz System on a Chip,
which is built on the ARM11 architecture. ARM chips come in a variety of architectures with
different cores configured to provide different capabilities at different price points. The Model B
has 512MB of RAM and the Model A has 256 MB. (The first batch of Model Bs had only
256MB of RAM.).

2.10.3 Interrupt controller: The interrupt controller can be programmed to interrupt the
processor when any of the status bits are set. The GPIO peripheral has three dedicated interrupt
lines. Each GPIO bank can generate an independent interrupt. The third line generates a single
interrupt whenever any bit is set.

2.10.4 General Purpose Input/Output (GPIO): 3.3 volt logic via 26 pin header (NOT 5 volt or
short tolerant) Pins can be configured to be input/output. General Purpose Input/Output (GPIO)
is a generic pin on a chip whose behavior can be controlled by the user at run time. True GPIO
(General Purpose Input Output) pins that you can use to turn LEDs on and off etc. I2C interface
pins that allow you to connect hardware modules with just two control pins. SPI interface with
SPI devices, a similar concept to I2C but uses a different standard.

28
2.10.5 PCM / I2S Audio: The PCM audio interface is an APB peripheral providing input and
output of telephony or high quality serial audio streams. It supports many classic PCM formats
including I2S. The PCM audio interface has 4 interface signals; PCM_CLK - bit clock. PCM_FS
- frame sync signal. PCM_DIN - serial data input. PCM_DOUT - serial data output. PCM is a
serial format with a single bit data_in and out.

2.10.6 DMA Controller: The BCM2835 DMA Controller provides a total of 16 DMA channels.
Each channel operates independently from the others and is internally arbitrated onto one of the
3 system busses.

2.10.7 UART: The BCM2835 device has two UARTS. On mini UART and PL011 UART. The
PL011 UART is a Universal Asynchronous Receiver/Transmitter. This is the ARM UART
(PL011) implementation. The UART performs serial-to-parallel conversion on data characters
received from an external peripheral device or modem, and parallel-to-serial conversion on data
characters received from the Advanced Peripheral Bus (APB).

2.10.8 Pulse Width Modulator: PWM controller incorporates the following features:
1 Two independent output bit-streams, clocked at a fixed frequency.
2 Bit-streams configured individually to output either PWM or a serialized version of a 32-bit
word.
3 PWM outputs have variable input and output resolutions.
4 Serialize mode configured to load data to and/or read data from a FIFO storage block that can
store up to eight 32-bit words.
5 Both modes clocked by clk_pwm which is nominally 100MHz, but can be varied by clock
manager.
2.10.9 CPU
 ARM 1176JZF-S (armv6k) 700MHz
 RISC Architecture and low power draw.
2.10.10 MEMORY

 RAM:- 512MB (Model B rev.2), 256 MB (Model A, Model B rev.1)


 SD Card:- At least 4GB SD card is needed, and it should be a Class 4 card. Class 4 cards
are capable of transferring at least 4MB/sec. Some of the earlier Raspberry Pi boards had
problems with Class 6 or higher cards, which are capable of faster speeds but are less

29
stable. One can also use micro SD card using adapter. As there is no hard drive on the Pi;
everything is stored on an SD Card. A protective case is needed as the solder joints on the
SD socket may fail if the SD card is accidentally bent.

2.10.11 Two USB 2.0 ports in RPi: Dual USB sockets on RPi model B, single on model A.It
can be expandable via regular or powered hubs. On the Model B there are two USB 2.0 ports,
but only one on the Model A. Some of the early Raspberry Pi boards were limited in the amount
of current that they could provide. Some USB devices can draw up 500mA. The original Pi
board supported 100mA or so, but the newer revisions are up to the full USB 2.0 spec.

2.10.12 Ethernet port: The model B has a standard RJ45 Ethernet port. The Model A does not,
but can be connected to a wired network by a USB Ethernet adapter (the port on the Model B is
actually an onboard USB to Ethernet adapter). WiFi connectivity via a USB dongle is another
option.

2.10.13 HDMI connector: The HDMI port provides digital video and audio output. 14 different
video resolutions are supported, and the HDMI signal can be converted to DVI (used by many
monitors), composite (analog video signal usually carried over a yellow RCA connector), or
SCART (a European standard for connecting audio-visual equipment) with external adapters.

2.10.14 Video: HDMI or (digital) DVI via cheap adaptor/cable, Composite NTSC/PAL via RCA
,Wide range of resolutions , NO VGA without an add-on, nontrivial converter (Adafruit).

2.10.15 Audio: Via HDMI or from stereo jack , Support Maturity appears to be lagging

2.10.16 Networking : 10/100mbps via RJ45 on model B , Wireless via USB add-on supported.

2.10.17 Power: There is no power switch on the Pi. Micro-USB connector is used to supply
power (this isn‟t an additional USB port; it‟s only for power). Micro-USB was selected because
cheap USB power supplies are easy to find.

Primary power via microUSB plug: a 1Amp cell charger works well, but to use a USB hard
drive, 2 Amp power is needed.

2.11 Conclusion: - Target board of such types can be used in low cost system designs using very
less amount of components and can be used for many user defined applications or customizations

30
2.12 Remarks: - The stiff cables microcontroller on all sides make it hard to keep flat, and
some of the components like the SD card slot can be mechanically damaged even through
normal use. The Pi contains six layers of conductive traces connecting various components,
unlike a lot of simple microcontroller PCBs that just have traces on the top and the bottom. There
are four layers of thin traces sandwiched in between the top and bottom; if the board gets flexed
too much you can break some of those traces in a manner that is impossible to debug

31
Experiment No: 2
Study on IoT Platform
1. Aim: Study of the sensor (IR, temperature, pressure, gas) and the actuator (Piezoelectric
actuator, pneumatic actuator) using Arduino.

2. Objectives: Understanding the connectivity of Arduino Uno board circuit with IR,
temperature, pressure, gas and Piezoelectric actuator, pneumatic actuator.

3. Apparatus: IR transmitter & receiver, LM 35 temperature sensor, BMP 280-Atmospheric


Pressure Sensor, Gas sensor MQ 135, Piezoelectric actuator, pneumatic actuator.

4. Theory:
Sensors: An electronic sensor detects and measures a physical phenomenon, such as
temperature, pressure, force, or acceleration, and provides a corresponding output, usually in the
form of an electronic signal.

4.1 IR sensor:

1. An infrared sensor is an electronic instrument which is used to sense certain


characteristics of its surroundings by their emitting and/or detecting infrared radiation.
2. Infrared sensors are also capable of measuring the heat being emitted by an object and
detecting motion.
3. Infrared waves are not visible to the human eye. In the electromagnetic spectrum,
infrared radiation can be found between the visible and microwave regions.
4. The infrared waves typically have wavelengths between 0.75 and 1000 µm.

Figure 2.1 IR sensor structure

32
Surface
IR Transmitter

Object Body

IR Receiver Rays reflected from


surface

Figure 2.2 IR sensor functionality

4.2 LM 35 temperature sensor:


1. The LM 35 temperature sensor is a nice little module that provides the digital
temperate. It is really easy to set up and only requires one wire for the data signal.
2. These sensors are frequently used in remote weather stations, home environment
control systems. The programming is simple too.

Figure 2.3 Temperature Sensor

4.3 BMP 280-Atmospheric Pressure Sensor:


1. BMP 280 pressure sensor module is an Arduino compatible tool used for atmospheric
pressure measurement in environments. Such measurements mainly allow for forecasting
of short term changes in the weather.

33
2. The GY-BMP 280 module comes with BMP280 sensor, which is an environmental
sensor with barometric pressure that is the next generation upgrade to the
BMP085/BMP180/BMP183.
3. The sensor is great for all sorts of weather sensing and can even be used in both 12C and
SPI.
4. The precision sensor is the best low-cost, precision sensing solution for measuring
barometric pressure with ± 1hPa absolute accuracy, ad temperature with ± 1.0°C
accuracy. Because pressure changes with altitude and the pressure measurements are so
good that we can use altimeter with ± 1-meter accuracy.
5. Pin pitch: 2.54 mm

Table 2.1 Pin description

Pin No. Pin Name Pin description


1. VCC Power source of 3.3 VDC
2. GND Ground
3. SCL Serial clock
4. SDA Serial Data

Figure:

34
Figure:
Applications:

1. Enhancement of GPS navigation (e.g. time to first fix improvement, dead-reckoning, slope
detection)

2. Indoor navigation (floor detection, elevator detection)

3. Outdoor navigation, leisure and sports application

4. Weather forecast, home weather stations

5. Heath care application (e.g., sirometry)

6. Vertical velocity indication (e.g., risk/sink speed)


7. Handsets such as mobile phones, tablets PCs, GPS devices.

8. Flying toys
9. Watches

4.4 Gas sensor MQ 135:


1. MQ-135 gas sensor applies SnO2 which has a lower conductivity in the clean air as a gas-
sensing material.

35
2. In an atmosphere where there may be polluting gas, the conductivity of the gas sensor
raises along with the concentration of the polluting gas increases.
3. MQ-135 performs a good detection to smoke and other harmful gas, especially sensitive
to ammonia, sulfide and benzene steam.
4. It has the ability to detect various harmful gas and lower cost make MQ-135 an ideal
choice of different applications of gas detection.
5. The MQ-135 sensor module comes with a Digital pin which makes this sensor to operate
even without a microcontroller and that comes in handy when we are only trying to detect
one particular gas.
6. If we need to measure the gases in PPM the analog pin need to be used. The analog pin is
TTL driven and works on 5 V and so can be used with most common microcontrollers.
7. Simply power the module with 5 V and we should notice the power LED on the module
to glow and when no gas it detected the output LED will remain turned off meaning the
digital output pin will be 0 V.
8. The sensors have to be kept on for pre-heating time before we can actually work with it.
9. Every time, when the sensor gets introduced to this gas at this particular concentration the
digital pin will go high (5 V) else will remain low (0V).

Figure

Applications:
The module can be applied to harmful gas detecting devices.

36
4.6 Actuators: Actuators convert an electrical signal to the corresponding physical quantity such
as movement, force, sound, display etc. The actuator is a part of any machine which is
responsible for mechanical rotation or controlling. Example: Microphone (coverts sound to
electrical signal), Speaker (converts electrical signal to sound), antenna (converts
electromagnetic energy into electricity and vice versa). The actuators which induce movement,
can be classified into three categories, namely electric, hydraulic and pneumatic actuators
depending on their operation. Hydraulic actuators facilitate mechanical movement using
hydraulic power. Pneumatic actuators use compressed air pressure and electrical actuators use
electric power. A sophisticated example of an actuator used in the IoT is a “digital fingers”,
which is used to switch on/off the switches (or anything that requires a small movement) and is
controlled wirelessly.

4.6.1 Piezoelectric actuators: Piezoelectric actuators are devices that produce a small
displacement with a high force capability when voltage is applied. There are many applications
where a piezoelectric actuator may be used, such as ultra-precise positioning and in the
generation and handling of high forces or pressures in static or dynamic situations. Actuator
configuration can vary greatly, depending on application. Piezoelectric stack or multilayer
actuators are manufactured by stacking up piezoelectric disks or plates, the axis of the stack
being the axis of linear motion that occurs when a voltage is applied. Tube actuators are
monolithic devices that contract laterally and longitudinally when a voltage is applied between
the inner and outer electrodes. A disk actuator is a device in the shape of a planar disk. Ring
actuators are disk actuators with a center bore, making the actuator axis accessible for optical,
mechanical, or electrical purposes. Other less common configurations include block, disk, bender
and bimorph styles. These devices can also be ultrasonic. Ultrasonic actuators are specifically
designed to produce strokes of several micrometers at ultrasonic (>20kHz) frequencies. They are
especially useful for controlling vibration, positioning applications, and quick switching. In
addition, piezoelectric actuators can be either direct or amplified. The effect of amplification is
not only larger displacement, but it can also result in slower response times. The critical
specifications for piezoelectric actuators are displacement, force and operating voltage of the
actuator. Other factors to consider are stiffness, resonant frequency, and capacitance. Stiffness is
a term used to describe the force needed to achieve a certain deformation of a structure. For

37
piezoelectric actuators, it is the force needed to elongate the device by a certain amount,
normally specified in terms of Newtons per micrometer. Resonance is the frequency at which the
actuators respond with maximum output amplitude. The capacitance is a function of the
excitation voltage frequency.

Figure

4.6.2 Pneumatic actuators: A pneumatic actuator uses energy formed by vacuum or


compressed air at high pressure to convert into either linear or rotary motion. Pneumatic
actuators are notable in their use for applications where the opening and closing of valves takes
place. For the reason, they hold value within applications where there is a fire or ignition risk.
Pneumatic actuators are also known in the industry by several different monitors including:
pneumatic cylinders, air cylinders and air actuators. Pneumatic rack and pinion actuators are
used for valve controls of water pipes. Pneumatic energy quickly responds to starting and
stopping signals. The power source does not need to be stored in reverse for operation.
Pneumatic actuators enable large forces to be produced from relatively small pressure changes
(i.e., Pneumatic brakes are very responsive to small changes in pressure applied by the driver). It
is responsible for converting pressure into force.

Example-Used in robotics, use sensors that work like human fingers by using compressed air.
There are some advantages are pneumatic actuators are a low-cost option and are used at extreme

38
temperatures where using air is a safer option than chemicals, they need low maintenance, are
durable and have a long operational life, and it is very quick in starting and stopping the motion.
It has some disadvantages are also there such that loss of pressure can make it less efficient, the
air compressor should be running continuously, air can be polluted and it needs maintenance.

Figure

Conclusion
We have accessed the data from sensors and actuators and apply Arduino uno board. Further,
data is collected, analyzed and visualized of the IR, temperature, pressure, gas sensors as well as
piezoelectric and pneumatic actuator.

39
Experiment 3:
Programming with Arduino platform
3.1 AIM:

a) Installation of Arduino in computer and verifying any errors in connection.

b) Control LED using Arduino

c) Traffic Light Control

3.2 Apparatus
Arduino UNO, PC, Proteus Software, IDE, Connecting wires, LEDs

3.3 Theory
To install and test the Arduino software with a Windows operating system (Windows 8,
Windows 7, Vista, and XP).

Step 1 − First you must have your Arduino board (you can choose your favorite board) and a
USB cable. In case you use Arduino UNO, Arduino Duemilanove, Nano, Arduino Mega 2560,
or Diecimila, you will need a standard USB cable (A plug to B plug), the kind you would
connect to a USB printer as shown in the following image.

Figure 3.1

40
In case you use Arduino Nano, you will need an A to Mini-B cable instead as shown in the
above image.

Step 2 − Download Arduino IDE Software.

You can get different versions of Arduino IDE from the Download page on the Arduino Official
website. You must select your software, which is compatible with your operating system
(Windows, IOS, or Linux). After your file download is complete, unzip the file.

Figure

Step 3 − Power up your board.

The Arduino Uno, Mega, Duemilanove and Arduino Nano automatically draw power from
either, the USB connection to the computer or an external power supply. If you are using an
Arduino Diecimila, you have to make sure that the board is configured to draw power from the
USB connection. The power source is selected with a jumper, a small piece of plastic that fits
onto two of the three pins between the USB and power jacks. Check that it is on the two pins
closest to the USB port.

Connect the Arduino board to your computer using the USB cable. The green power LED
(labeled PWR) should glow.

Step 4 − Launch Arduino IDE.

After your Arduino IDE software is downloaded, you need to unzip the folder. Inside the folder,
you can find the application icon with an infinity label (application.exe). Double-click the icon
to start the IDE.

41
Figure
Step 5 − Open your first project.
Once the software starts, you have two options −

 Create a new project.


 Open an existing project example.
To create a new project, select File → New.

Figure

42
To open an existing project example, select File → Example → Basics → Blink.

Figure
Here, we are selecting just one of the examples with the name Blink. It turns the LED on and
off with some time delay. You can select any other example from the list.

Step 6 − Select your Arduino board.

To avoid any error while uploading your program to the board, you must select the correct
Arduino board name, which matches with the board connected to your computer.

Go to Tools → Board and select your board.

Figure

43
Here, we have selected Arduino Uno board according to our tutorial, but you must select the
name matching the board that you are using.

Step 7 − Select your serial port.

Select the serial device of the Arduino board. Go to Tools → Serial Port menu. This is likely to
be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find
out, you can disconnect your Arduino board and re-open the menu, the entry that disappears
should be of the Arduino board. Reconnect the board and select that serial port.

Figure
Step 8 − Upload the program to your board.

Before explaining how we can upload our program to the board, we must demonstrate the
function of each symbol appearing in the Arduino IDE toolbar.

Figure
A − Used to check if there is any compilation error.
B − Used to upload a program to the Arduino board.
C − Shortcut used to create a new sketch.

44
D − Used to directly open one of the example sketch.
E − Used to save your sketch.
F − Serial monitor used to receive serial data from the board and send the serial data to the
board.

Now, simply click the "Upload" button in the environment. Wait a few seconds; you will see the
RX and TX LEDs on the board, flashing. If the upload is successful, the message "Done
uploading" will appear in the status bar.

3.4 Control LED Using Arduino


To turn on an LED, the Arduino needs to send a HIGH signal to one of it’s pins. To turn off the
LED, it needs to send a LOW signal to the pin. You can make the LED flash by changing the
length of the HIGH and LOW states.

The delay(.) function tells the Arduino to hold the HIGH or LOW signal at pin (.) for some ms..
You can change the blinking speed by changing the number inside the parentheses of the delay(.)
functions.
The Arduino has an on-board surface mount LED that’s hard wired to digital pin 13. It’s the one
with an “L” next to it:
An external LED or any other powered module can be controlled in a similar way. LEDs need to
have a resistor placed in series (in-line) with it. Otherwise, the unrestricted current will quickly
burn out the LED. The resistor can be any value between 100 Ohms and about 10K Ohms.
Lower value resistors will allow more current to flow, which makes the LED brighter. Higher
value resistors will restrict the current flow, which makes the LED dimmer.

Figure Circuit diagram of blinking of LED

45
3.4.1 Coding to blink internal LED
void setup() {
pinMode(13, OUTPUT); // Select pin 13 as output pin
}
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

3.4.2 Coding to blink External LED


void setup() {
pinMode(8, OUTPUT);
}
void loop() {
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(8, LOW);
delay(1000);
}

3.5 Traffic light Control


The use of personal vehicles is very common now a days and a result, the number of vehicles on
the roads are exponentially increasing. Roads without any supervision or guidance can lead in to
traffic congestions and accidents.

Traffic Lights or Traffic Signals are signalling devices that are used to control the flow of traffic.
Generally, they are positioned at junctions, intersections, ‘X’ roads, pedestrian crossings etc. and
alternate the priority of who has to wait and who has to go.

The traffic lights will provide instructions to the users (drivers and pedestrians) by displaying
lights of standard color. The three colors used in traffic lights are Red, Yellow and Green.

The system must be used to control the traffic lights for smooth and safe movement of traffic.

46
These control systems consist of electro mechanical controllers with clockwork mechanisms or
modern solid state computerized systems with easy setup and maintenance.

Figure Circuit diagram of traffic light control

Coding
void setup () {
peripheral_setup();
// TODO: put your setup code here, to run once:
pinMode(1,OUTPUT );
pinMode(2,OUTPUT );
pinMode(3,OUTPUT );
pinMode(4,OUTPUT );
pinMode(5,OUTPUT );
pinMode(6,OUTPUT );
pinMode(7,OUTPUT );
pinMode(8,OUTPUT );

47
pinMode(9,OUTPUT );
pinMode(10,OUTPUT );
pinMode(11,OUTPUT );
pinMode(12,OUTPUT );
}
void loop() {
peripheral_loop();
// TODO: put your main code here, to run repeatedly:
//---------------------------------------LANE-1----------------------------------------------
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
delay(2000);
//-----------------------------LANE-2--------------------------------------------------
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(1000);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);

48
digitalWrite(3, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
delay(2000);
//---------------------------LANE-3--------------------------------------------------

digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(9, HIGH);
digitalWrite(4, HIGH);
digitalWrite(8, LOW);
digitalWrite(5, LOW);
delay(2000);
//---------------------------------LANE-4---------------------------
digitalWrite(8, HIGH);
digitalWrite(11, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
delay(1000);
digitalWrite(12, HIGH);
digitalWrite(7, HIGH);
digitalWrite(11, LOW);
digitalWrite(8, LOW);
delay(2000);
// -------------------------------Repeat--------------------
digitalWrite(12, LOW);
digitalWrite(11, HIGH);

49
digitalWrite(2, HIGH);
digitalWrite(1, LOW);
delay(1000);
}

Output of traffic light control

Conclusion
In this experiment Arduino IDE is installed in computer and two hardware experiments such as:
blinking of LED and traffic light control are carried out using Arduino.

50
Experiment 4
4.1. AIM - Programming with Arduino platform and Reading data from Temperature
Sensors.

4.2. Apparatus: Arduino, LM35 sensor, Breadboard, Connecting wires

4.3. Theory
The Temperature Sensor LM35 series are precision integrated-circuit temperature devices with
an output voltage linearly proportional to the Centigrade temperature. The LM35 device has an
advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to
subtract a large constant voltage from the output to obtain convenient Centigrade scaling. The
LM35 device does not require any external calibration or trimming to provide typical accuracies
of ±¼°C at room temperature and ±¾°C over a full −55°C to 150°C temperature range.

4.4 Hardware Integration (Circuit Diagram)

Figure
LM35 sensor has three terminals - Vs, Vout and GND. We will connect the sensor as follows −

 Connect the +Vs to +5v on your Arduino board.

 Connect Vout to Analog0 or A0 on Arduino board.

Connect GND with GND on Arduino.

51
The Analog to Digital Converter (ADC) converts analog values into a digital approximation
based on the formula ADC Value = sample * 1024 / reference voltage (+5v).

Open the Arduino IDE software on your computer. Coding in the Arduino language will control your
circuit. Open a new sketch File by clicking New

Figure
5. Coding

float temp;
int tempPin = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
temp = analogRead(tempPin);
// read analog volt from sensor and save to variable temp
temp = temp * 0.48828125;
// convert the analog volt to its temperature equivalent
Serial.print("TEMPERATURE = ");
Serial.print(temp); // display temperature value
Serial.print("*C");

52
Serial.println();
delay(1000); // update sensor reading each one second
}
6. Conclusion:

53
Experiment No. 5
5.1. AIM OF THE EXPERIMENT

(a) To display the date on serial monitor using Raspberry Pi

5.2 APPARATUS:
Raspberry Pi, USB Connector, LAN connector, Memory Card (SD Card)

5.3. THEORY:
The Raspberry Pi does not have a similar feature to the Arduino's Serial Monitor present in
integrated development environment (IDE). We can communicate with an Arduino over both
the GPIO serial and USB serial and use the Serial monitor. However, by using a LAN
connection, the data can be viewed on any other display device.
A date in Python is not a data type of its own, but we can import a module named
datetime to work with dates as date objects.

datetime.datetime.now()

The date contains year, month, day, hour, minute, second, and microsecond. The datetime
module has many methods to return information about the date object. For instance, the
strftime() function formats a local time and/or date according to locale settings.
datetime.datetime.now().strftime('%m-%d-%Y_%H.%M.%S').

5.4. PROGRAM:
from datetime import *
import time
from time import time
today = datetime.now()
print (today.strftime(' %a %d-%m-%Y @ %H:%M:%S'))

54
Experiment 5 B
5.1. AIM OF THE EXPERIMENT

(b) To create an automatic door opening system using Raspberry Pi

5.2 APPARATUS:
Raspberry Pi, PIR Motion sensor, LED, Resistors, Breadboard, Jumper wire

5.3 THEORY:
The PIR sensor acts as a motion detector and detects the presence of human beings within the
field of its vision. When it detects the human presence, it notifies the Raspberry Pi controller.
The DC motor connected to the output of the Raspberry Pi controller is used to open and close
the gate automatically. In this experiment, LED light is used to indicate the presence of intruder.
The actuator can be incorporated by using a DC motor and a motor driver module.

5.3.1 Raspberry Pi: The Raspberry Pi GPIO can be accessed through a Python program. Each
pin on the Raspberry Pi is named based on its order (1,2,3, ...) as shown in the diagram below:

Figure

5.3.1 PIR motion sensor: PIR stands for passive infrared. This motion sensor consists of a
Fresnel lens, an infrared detector, and supporting detection circuitry. The lens on the sensor

55
focuses any infrared radiation present around it toward the infrared detector. Our bodies generate
infrared heat, and as a result, this heat is picked up by the motion sensor. The sensor outputs a
5V signal for a period of one minute as soon as it detects the presence of a person. It offers a
tentative range of detection of about 6–7 meters and is highly sensitive. When the PIR motion
sensor detects a person, it outputs a 5V signal to the Raspberry Pi through its GPIO and we
define what the Raspberry Pi should do as it detects an intruder through the Python coding. Here
we are just printing "Intruder detected".

Figure

5.4 PROCEDURE: -
5.4.1 Blinking an LED Using the Raspberry Pi GPIO-Output GPIO Control:

In this experiment, the LED is used as an indicator of the presence of any intruder using a Python
script. Copy and paste the following code into the Raspberry Pi. This can be done by opening the
text editor "leafpad" on the Raspberry Pi and copying this code into it, and saving this as a
Python file: ledblink.py :

 Open the text editor "leafpad" on Raspberry Pi


 Type the program
 Save as a Python file: ledblink.py
 Execute the Python program using this command: sudo python ledblink.py

5.4.1.1 PROGRAM:

56
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(3,GPIO.OUT) #Define pin 3 as an output pin
while True:
GPIO.output(3,1) #Outputs digital HIGH signal (5V) on pin 3
time.sleep(1) #Time delay of 1 second
GPIO.output(3,0) #Outputs digital LOW signal (0V) on pin 3
time.sleep(1) #Time delay of 1 second

Connect the LED to pin 3 on the Raspberry Pi GPIO. The LED blinks because it receives a
HIGH (5V) signal and a LOW (0V) signal from the Raspberry Pi GPIO at a delay of one
second.

5.4.2 Interfacing the PIR Motion Sensor to the Raspberry Pi's Input GPIO
The sensor outputs a digital HIGH (5V) signal when it detects a person. Type the program and
save as a Python file: pirtest.py

5.4.2.1 PROGRAM:
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN) #Read output from PIR motion sensor
GPIO.setup(3, GPIO.OUT) #LED output pin
while True:
i=GPIO.input(11)
if i==0: #When output from motion sensor is LOW
print "No intruders",i
GPIO.output(3, 0) #Turn OFF LED

57
time.sleep(0.1)
elif i==1: #When output from motion sensor is HIGH
print "Intruder detected",i
GPIO.output(3, 1) #Turn ON LED
time.sleep(0.1)

Connect the Raspberry Pi GPIO to the PIR motion sensor and run the code.

It can be noted that this code prints "Intruder detected" when the hand is placed over the sensor.
After removing the hand and waiting some time, it prints: "No intruders".

58
Experiment -06
Aim : Connecting android phone with Arduino
(a) Connecting Arduino with Mobile device using the Bluetooth module.
(b) Control any two actuators connected to the development board using bluetooth

Appratus requirement

Arduino, HC-05 module, 5V relay module, 12 V DC Adopter, 5V Relay Module,AC Plug and
Socket, USB A to B for programming theArduino, Mobile phone, LED, Serovo meter and
Relay
Theory:
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 use the Arduino programming
languag (based on Wiring and the Arduino Software (IDE), based on Processin.
Bluetooth is a wireless technology standard used for exchanging data between fixed and
mobile devices over short distances using short-wavelength UHF radio waves in
the industrial, scientific and medical radio bands, from 2.402 GHz to 2.480 GHz, and
building personal area networks (PANs). It was originally conceived as a wireless alternative
to RS-232 data cables.

HC-05 module Information


 HC-05 has red LED which indicates connection status, whether the Bluetooth is connected or
not. Before connecting to HC-05 module this red LED blinks continuously in a periodic
manner. When it gets connected to any other Bluetooth device, its blinking slows down to two
seconds.
 This module works on 3.3 V. We can connect 5V supply voltage as well since the module has
on board 5 to 3.3 V regulator.
 As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V
level, so, no need to shift transmit level of HC-05 module. But we need to shift the transmit
voltage level from microcontroller to RX of HC-05 module.

Servo meter
A servo motor is a rotary actuator or motor that allows for a precise control in terms of
angular position, acceleration and velocity, capabilities that a regular motor does not have. It

59
makes use of a regular motor and pairs it with a sensor for position feedback. The controller is
the most sophisticated part of the servo motor, as it is specifically designed for the purpose.
The servo motor is a closed-loop servomechanism that uses position feedback in order to
control its rotational speed and position. The control signal is the input, either analog or
digital, which represents the final position command for the shaft. A type of encoder serves as
a sensor, providing speed and position feedback. In most cases, only the position is reported.
The final position is reported to the controller and this is compared to the initial position
input, and then if there is a discrepancy, the motor is moved in order to get to the correct
position.

Procedure
To use the HC05 module, simply connect the VCC to the 5V output on the Arduino, GND to
Ground, RX to TX pin of the Arduino, and vice versa.
This is done because the RX pin on the Arduino is Pin 0 and the TX pin is Pin 1. You are free to
use any other pins as the RX and TX Pins, but you will have to use the SoftwareSerial Library of
the Arduino to enable that. Do remember to remove the jumpers while uploading code to the
Arduino if you have selected Pin 0 and 1 as Serial pins.
Download the ardino Bluetooth controller in mobile and connect with HC-05 then you can use
digital ON-OFF option to control the LED.

60
Code
char data = 0; //Variable for storing received data
void setup()
{
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data
transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}
void loop()
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data and store it into variable data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n"); //New line
if(data == '1') //Checks whether value of data is equal to 1
digitalWrite(13, HIGH); //If value is 1 then LED turns ON
else if(data == '0') //Checks whether value of data is equal to 0
digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}

}
Servo motor using Bluetooth code

The android app sends data packets to the Bluetooth module. The Bluetooth modules sends
this data packet to Arduino Uno through Serial Communication. Arduino Uno is
programmed to generate control signal for the servo motor depending upon the value of the
data packet. Here is a flowchart for better understanding.

The android app sends data packets to the Bluetooth module. The Bluetooth modules sends
this data packet to Arduino Uno through Serial Communication. Arduino Uno is programmed
to generate control signal for the servo motor depending upon the value of the data packet.
Here is a flowchart for better understanding.
#include <Servo.h>

61
#include<SoftwareSerial.h>
#include<Servo.h>
Servo x;
int bttx=9; //tx of bluetooth module is connected to pin 9 of arduino
int btrx=10; //rx of bluetooth module is connected to pin 10 of arduino
SoftwareSerial bluetooth(bttx,btrx);
void setup()
{
x.attach(11); // servo is connected to pin 11 of arduino
Serial.begin(9600);
bluetooth.begin(9600);
}
void loop()
{
if(bluetooth.available()>0) //if bluetooth module is transmitting data
{
int pos=bluetooth.read(); // store the data in pos variable
Serial.println(pos);
x.write(pos); //move servo head to the given position
}
}
Bluetooth based relay control
Since this project is based on serial communication, no sensors have been used here thereby
keeping the production cost low. The Bluetooth HC-05 module used here communicate with
both Arduino through wired connection and the smartphone wirelessly. The smartphone
provides the input to the Bluetooth module and the module in turn provides an input to the
Arduino. Thus it can be said the Bluetooth acts as a mediator between the Arduino and the
smartphone. The relay works as the actuator here and is connected to a socket such that it
can ON and OFF any device which is connected to the socket making it very robust. The
project can also be made with ESP module but it has been mentioned before, our motiv e was
to keep the project economical so we used Bluetooth instead. You can use any smartphone

62
app that can control HC-05 Bluetooth module such as ‘Bluetooth Terminal HC-05’ by
‘mightyIT Communication’ or you can use the ‘.apk’ file provided here which I cr eated
through MIT App Inventor.

int relay = 12;//variable for assigning the relay module


int state = 0;//variable for assigning the value communicated by bluetooth module
int flag = 0; //variable for assigning flag to for a desirable operation
void setup()
{
pinMode(relay, OUTPUT);//setting relay as output
digitalWrite(relay, LOW);// initializing the output as off
Serial.begin(9600); // default connection rate for the BT module
}
void loop()
{
if (Serial.available() > 0) //checking if connection available with bluetooth module
{
state = Serial.read();//assigning the value communicated by bluetooth module
flag = 0;//initial value set for flag
}
if (state == '0') // LOW value communicated by bluetooth module
{
digitalWrite(relay , LOW);//relay is switched OFF

63
if (flag == 0) //initial flag
{
Serial.println("POWER: Off");//display on the smartphone app
flag = 1;//flag toggled
}
}
else if (state == '1') //HIGH value communicated by bluetooth module
{
digitalWrite(relay, HIGH);// relay is turned ON
if (flag == 0)//initial flag
{
Serial.println("POWER: On");//display on the smartphone app
flag = 1;//flag toggled
}
}
}
Result

64

You might also like