Embedded IOT Kit User Manual - Final
Embedded IOT Kit User Manual - Final
User Manual
Supplied by
Vintech Systems,
Nagercoil,
Cell : 8098577988, 8300185460,
e.mail : [email protected]
Vintech Systems
EXP.NO : 5 Introduction to Arduino Platform and Programming
HARDWARE DETAILS
Advantages :
It is cheap
It comes with an open supply hardware feature that permits users to develop their own kit
The software of the Arduino is well-suited with all kinds of in operation systems like Linux,
Windows, and Macintosh, etc.
It also comes with open supply software system feature that permits tough software system
developers to use the Arduino code to merge with the prevailing programing language
libraries and may be extended and changed.
For beginners also it is very simple to use.
Vintech Systems
SOFTWARE DETAILS
ARDUINO IDE
Programming Structure:
Vintech Systems
Programming :
File :
Vintech Systems
Edit :
Sketch :
Vintech Systems
Tools :
Help :
Vintech Systems
Compile & Upload programs :
Vintech Systems
EXP.NO : 5.a LED BLINKING
Aim :
Perform Interfacing of LED with ARDUINO and evaluate the response of variations.
APPARATUS REQUIRED :
1. Arduino Kit
2. USB Cable
3. Arduino SDK Software tool
4. Patch cards
THEORY:
LEDs are the most efficient way to turn an electric current into illumination. When a current
flows through a diode in the forward direction, it consists of surplus electrons moving in one
direction in the lattice and “holes” (voids in the lattice) moving in the other. Occasionally,
electrons can recombine with holes. When they do, the process releases energy in the form of
photons.
This is true of all semiconductor junctions, but LEDs use materials that maximize the effect. The
color of the light emitted (corresponding to the energy of the photon) is determined by the
semiconductor materials that form the diode junction.
The latest high-brightness (HB) white LEDs are made possible by the discovery of
semiconductor materials that produce blue or ultraviolet photons. In addition to the diode, an HB
package contains “yellow” phosphors on the inside of its lens. Some “blue” photons escape, but
others excite the phosphors, which then give off “yellow” photons. The result can be tuned in
manufacturing to produce “white” light.
Vintech Systems
PROCEDURE :
There are 4 LEDs in the kit namely D4, D5, D6 and D7. They are to be connected to the
D4, D5, D6 and D7 pins of Arduino board. The power supply +5V and Gnd pins of
Arduino board also are to be connected in this section.
Connect the USB connector to the USB of Arduino board and the computer system.
Using this program, the first LED (left most LED) is switched on for 0.5 sec and then it is
switched off.
After 0.5 sec., the second LED is switched on for 0.5 sec. and then it is switched off. In
this way, all the four LEDs are switched on and off. Then the cycle repeats continuously.
In computer, open the sketch software and write the program LED blinking and execute
the program in sketch and check for the proper result.
Program :
int LED_PIN = 8;
void setup()
{
pinMode(LED_PIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_PIN, HIGH);
delay(1000);
digitalWrite(LED_PIN, LOW);
delay(1000);
}
Result:
Vintech Systems
EXP.NO : 5b LED pattern
Aim :
Perform Interfacing of LED Pattern with ARDUINO and evaluate the response of variations.
PROCEDURE :
There are 4 LEDs in the kit namely D4, D5, D6 and D7. They are to be connected to the D4,
D5, D6 and D7 pins of Arduino board. The power supply +5V and Gnd pins of Arduino
board also are to be connected in this section.
Connect the USB connector to the USB of Arduino board and the computer system.
The 4 LEDs are used as 4 bits. To represent 0-15 decimal number in binary, 4 bits are
needed. The program is written such that in one for loop, 0-15 is counted and after every
count, the bits of the number is read one by one and displayed in the LEDs. In this way,
binary pattern of 0-15 decimal number is displayed in 4 LEDs
Program
// 8 LEDs used to display binary pattern of decimal numbers 0-15
// For loop is written to generate a decimal number 0-15. Byte variable is used.
// For every count, the first 4 bits are read from the byte representation of the number
// 8 bits are assigned to LEDs. Thereby, binary pattern of decimal number 0-15 is displayed
int t = 40;
int rnd =5;
int pat1t =75;
void setup()
{
for(int i=3; i<=12; i++) // pin d3 to d11 used
pinMode(i,OUTPUT);
}
void loop(){
Vintech Systems
pat6();}
for(int i=0; i<=rnd; i++) {
pat7();}
for(int i=0; i<=rnd; i++) {
pat8();}
for(int i=0; i<=rnd; i++) {
pat9();}
void pat1(){
for(int i=3; i<=12; i++) {
digitalWrite(i,HIGH);
delay(pat1t);
digitalWrite(i,LOW);
Vintech Systems
void pat3(){
for(int i=3; i<=12; i=i+2) {
digitalWrite(i,HIGH);
delay(100);
digitalWrite(i,LOW);
Vintech Systems
}
for(int i=8; i<=12; i++) {
digitalWrite(i,HIGH);
}
delay(200);
}
void pat7(){
for(int i=3; i<=12; i=i+2) {
digitalWrite(i,HIGH);
}
for(int i=4; i<=12; i=i+2) {
digitalWrite(i,LOW);
}
delay(200);
for(int i=3; i<=12; i=i+2) {
digitalWrite(i,LOW);
}
for(int i=4; i<=12; i=i+2) {
digitalWrite(i,HIGH);
}
delay(200);
}
void pat8(){
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(t);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
delay(t);
digitalWrite(6,HIGH);
digitalWrite(9,HIGH);
delay(t);
digitalWrite(6,LOW);
digitalWrite(9,LOW);
delay(t);
digitalWrite(5,HIGH);
digitalWrite(10,HIGH);
delay(t);
digitalWrite(5,LOW);
digitalWrite(10,LOW);
delay(t);
digitalWrite(4,HIGH);
digitalWrite(11,HIGH);
delay(t);
digitalWrite(4,LOW);
digitalWrite(11,LOW);
Vintech Systems
delay(t);
digitalWrite(3,HIGH);
digitalWrite(12,HIGH);
delay(t);
digitalWrite(3,LOW);
digitalWrite(12,LOW);
delay(t);
digitalWrite(4,HIGH);
digitalWrite(11,HIGH);
delay(t);
digitalWrite(4,LOW);
digitalWrite(11,LOW);
delay(t);
digitalWrite(5,HIGH);
digitalWrite(10,HIGH);
delay(t);
digitalWrite(5,LOW);
digitalWrite(10,LOW);
delay(t);
digitalWrite(6,HIGH);
digitalWrite(9,HIGH);
delay(t);
digitalWrite(6,LOW);
digitalWrite(9,LOW);
delay(t);
}
void pat9(){
for(int i=3; i<=12; i++) {
digitalWrite(i,HIGH);
}
for(int i=3; i<=12; i++) {
digitalWrite(i,LOW);
delay(100);
digitalWrite(i,HIGH);
}
for(int i=11; i>=4; i--) {
digitalWrite(i,LOW);
delay(100);
digitalWrite(i,HIGH);
}
Result:
Vintech Systems
EXP.NO 5.c. LED Pattern with Push Button control Arduino
Aim :
Perform Interfacing of LED Pattern with Push Button Control With Arduino and evaluate the
response of variations.
APPARATUS REQUIRED :
1. Arduino Kit
2. USB Cable
3. Arduino SDK Software tool
4. Patch cards
THEORY:
Usually each push button switch has two pairs of contacts. Each pair of contacts consists of a NO
contact and a NC contact. When the button is pressed, the two pairs of contacts act simultaneously,
the NC contact is disconnected, and the NO contact is closed.
A 'push to make' switch allows electricity to flow between its two contacts when held in. When
the button is released, the circuit is broken. This type of switch is also known as a Normally Open
(NO) Switch. (Examples: doorbell, computer case power switch, calculator buttons, individual keys
on a keyboard)
A 'push to break' switch does the opposite, i.e. when the button is not pressed, electricity can
flow, but when it is pressed the circuit is broken. This type of switch is also known as a Normally
Closed (NC) Switch. (Examples: Fridge Light Switch, Alarm Switches in Fail-Safe circuits)
Many Push switches are designed to function as both 'push to make' and 'push to break' switches. For
these switches, the wiring of the switch determines whether the switch functions as a 'push to make'
or as a 'push to break' switch.
Vintech Systems
PROCEDURE :
There are 4 switches and 4 LEDs. The program is written such that when the particular
switch is pressed, the LED just above the switch will glow. Though the program is
lengthy, the program is simple.
Connect the LEDs D4, D5, D6 and D7 to digital pins 4, 5, 6, 7 of Arduino. Similarly,
connect Sw8, Sw9, Sw10 and Sw11 to digital pins 8,9,10,11 of Arduino. Connect +5V
and Gnd from Arduino board.
Program
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
Vintech Systems
EXP.NO : 5d. Switch and LED pattern
The switch S9 is used to increment a counter from 0-15. For every count value, the binary
pattern is displayed in the 4 LEDs. Connect the LEDs D4, D5, D6 and D7 to digital pins 4, 5, 6,
7 of Arduino. Similarly, connect Sw8, Sw9, Sw10 and Sw11 to digital pins 8,9,10,11 of
Arduino. Connect +5V and Gnd from Arduino board.
Program
//D9 switch is used to increment a counter 0-15
// The 4 LEDs shows the binary pattern of the number for every count
int ledPin[] = {4,5,6,7}; // ledPins are assigned to digital pins as array variable
int SW = 9; // SW 9 is assigned to digital pin 9
int i = 0; // variable used for a counter
void setup()
{
for (int i =0;i<4;i++)
{ pinMode(ledPin[i], OUTPUT); // ledPins are configured as OUTPUT
}
pinMode(SW,INPUT); // Switch is configured as INPUT
}
void loop()
{
if(digitalRead(SW)) { // switch status is read
// if it is 1, then counter variable is incremented
i++;
displayBinary(i); // displayBinary function is called
delay(500);
}
if(i>15) { // the counter is counted from 0 to 15 again
i=0;
}
}
void displayBinary(byte number) // displayBinary user defined function
{
for (int i =0;i<4;i++) {
if (bitRead(number,i)==1) {
digitalWrite(ledPin[i], HIGH);
}
else {
digitalWrite(ledPin[i], LOW);
}
}
}
Vintech Systems
EXP.NO : 5. E. Displaying Hello world message in LCD
Aim :
APPARATUS REQUIRED :
1. Arduino Kit
2. USB Cable
3. Arduino SDK Software tool
4. Patch cards
THEORY :
Program
/*
LiquidCrystal Library - Hello World
The circuit:
Vintech Systems
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 4
* LCD D5 pin to digital pin 5
* LCD D6 pin to digital pin 6
* LCD D7 pin to digital pin 7
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
#include <LiquidCrystal.h>
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
// lcd.setCursor(0, 1);
// print the number of seconds since reset:
// lcd.print(millis() / 1000);
}
Vintech Systems
EXP.NO : 5.f RC Servo position control
Aim :
Perform Interfacing of RC Servo Motor with Arduino board and evaluate the response of
variations.
APPARATUS REQUIRED :
1. Arduino Kit
2. USB Cable
3. Arduino SDK Software tool
4. Patch cards
THEORY :
RC servo motor can be used to set the position of the shaft of the servo motor to 0 to 180 degrees.
50 Hz frequency pulses (Period 20msec) with pulse width (0.5 to 2.5msec) positions the servo between 0
degrees and 180 degrees.
There is a built in servo library in sketch software. It is used by writing #include Servo.h as the first line
in the Arduino program. In this experiment, potentiometer is used to output 0-5V analog voltage.
The analog voltage is read in A0 pin using analogRead function. It converts the 0-5V analog voltage to
10 bit digital outputs (10 bit resolution) and digital output with decimal value 0-1023.
This read value is sent out from the Arduino as pwm signal in pin D9. The 0-1023 value is changed to the
output of 0-255. If the analog converted value is 1023, then the output will have full on time pulse width
255. If the analog converted value is 500, then the output will have on time pulse width of (1023/255) x
Vintech Systems
500. Since the pulses are continuous, the average output will be dc voltage depending upon the analog
voltage input.
However, a map function to convert 0-1023 to 0-180 is used in the program. Servo.write() function is
used to give control input to the servo motor 0-180 degrees.
Program
//Small servo motor is tested for 0 to 180 degrees positioning
// Library Servo is included in this program
// Servo motor is operated by giving the angle information through the arduino pin 9
// as pwm signal which goes from 0 to 255, but it is mapped to 0-180
// Potentiometer voltage input is used to provide angle information
#include <Servo.h>
int servoPin = 9;
Servo servo;
int angle = 0; // servo position in degrees
void setup() {
servo.attach(servoPin);
}
void loop() {
Vintech Systems
EXP.NO : 5 .g. Temperature measurement using LM35 Thermistor IC
Aim :
Perform Interfacing of temperature sensor experiment with Arduino and evaluate the
response of variations.
APPARATUS REQUIRED :
1. Arduino Kit
2. USB Cable
3. Arduino SDK Software tool
4. Patch cards
THEORY:
A large distinction can be made between temperature sensor types. Sensors differ a lot in
properties such as contact-way, temperature range, calibrating method and sensing element. The
temperature sensors contain a sensing element enclosed in housings of plastic or metal. With the
help of conditioning circuits, the sensor will reflect the change of environmental temperature.
Vintech Systems
an advantage over linear temperature sensors calibrated in degrees Kelvin, as the user is not
required to subtract a large constant voltage from its output to obtain convenient Fahrenheit
scaling. The LM34 does not require any external calibration or trimming to provide typical
accuracies of ±1.2°F at room temperature and ±11.2°F over a full -50 to +300°F temperature
range. The LM34 is rated to operate over a -50° to +300°F temperature range.
LM 35 IC is a 3 pin IC. It has Vcc and Gnd pins and another output pin. +5V and Gnd are connected to Vcc
and Gnd pins. The output pin gives the output 10mV per degree centigrade. For example, if the ambient
temperature is 30°C, then the output pin gives 300mV dc output. The output pin is connected to A0 analog
input of Arduino. Arduino uses 10 bit analog to digital converter. The 10 bit resolution is 1024. 0-5V input
is read as 0-1023 inside the Arduino in this analog input A0. There are A0, A1, A2, A3, A4 and A5 analog
input pins available in Arduino. Connect the +5V and Gnd and A0 of Arduino to this LM 35 sensor section.
In this program, LCD is used to display the temperature.
Program
// Temperature is measured using sensor LM35.
// It gives 10mV output per degree centigrade
// since adc has 10 bit resolution, maximum voltage is 5V
// 10 bit resolution, number 1023 is output for 5V
// for one bit change, voltage required is 4.88mV
// 10mV/4.88mV = 2.05. Use this factor to display degree centigrade
// LCD is used to display temperature
#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 4, 5, 6, 7);
const int sensor=A1; // Assigning analog pin A1 to variable 'sensor'
float tempc; //variable to store temperature in degree Celsius
float tempf; //variable to store temperature in Fahreinheit
float vout; //temporary variable to hold sensor reading
void setup()
{
pinMode(sensor,INPUT); // Configuring pin A1 as input
Serial.begin(9600);
lcd.begin(16,2);
delay(500);
}
void loop()
{
vout=analogRead(sensor);
vout=(vout*500)/1023;
tempc=vout; // Storing value in Degree Celsius
tempf=(vout*1.8)+32; // Converting to Fahrenheit
lcd.setCursor(0,0);
lcd.print("in DegreeC= ");
lcd.print(tempc);
lcd.setCursor(0,1);
lcd.print("in Fahrenheit=");
lcd.print(tempf);
delay(1000); //Delay of 1 second for ease of viewing in serial monitor
Vintech Systems
}
Aim :
Perform Interfacing of temperature sensor experiment with Arduino and evaluate the
response of variations.
APPARATUS REQUIRED :
1. Arduino Kit
2. USB Cable
3. Arduino SDK Software tool
4. Patch cards
THEORY :
An ultrasonic sensor is an electronic device that measures the distance of a target object by
emitting ultrasonic sound waves, and converts the reflected sound into an electrical signal.
Ultrasonic waves travel faster than the speed of audible sound (i.e. the sound that humans can
hear).
Ultrasonic sensor HC-SR04 sensor is used. A burst of ultrasonic waves is transmitted. It hits the
object and return back in the form of echo. Time difference of outgoing waves and returning
echo is proportional to twice the distance travelled. HC – SR04 has 4 pins. 2 pins are +5V and
Gnd. There are Triggering and Echo signal pins.
Connect trigger signal pin to A4 analog pin and echo signal pin to A5 analog pin of Arduino
Vintech Systems
PROGRAMM :
Vintech Systems
EXP.NO : 5.i IR Sensor Analog Input With Arduino
Aim :
Perform Interfacing of IR Sensor with Arduino and evaluate the response of variations.
THEORY:
Program
void setup()
{
pinMode(13, OUTPUT); // Pin 13 has an LED connected on most Arduino boards:
pinMode(ProxSensor,INPUT); //Pin A0 is connected to the output of proximity sensor
Serial.begin(9600);
}
void loop()
{
if(digitalRead(ProxSensor)==HIGH) //Check the sensor output
Vintech Systems
{
digitalWrite(13, HIGH); // set the LED on
}
else
{
digitalWrite(13, LOW); // set the LED off
}
inputVal = analogRead(ProxSensor);
Serial.println(inputVal);
delay(1000); // wait for a second
}
Vintech Systems
EX.NO: 6 Explore different communication methods with IOT Device
Node MCU is a low-cost open source IoT platform. And its used to communicate sensors data with
the cloud platform. It initially included firmware which runs on the ESP8266 Wi-
Fi SoC from Espressif Systems, and hardware which was based on the ESP-12 module. Later
support for the ESP32 32-bit MCU was added.
Both the firmware and prototyping board designs are open source.
The firmware uses the Lua scripting language. The firmware is based on the eLua project, and built
on the Espressif Non-OS SDK for ESP8266. It uses many open source projects, such as lua-
cjson[9] and SPIFFS. Due to resource constraints, users need to select the modules relevant for their
project and build a firmware tailored to their needs. Support for the 32-bit ESP32 has also been
implemented.
0 [*] GPIO16
1 GPIO5
2 GPIO4
3 GPIO0
4 GPIO2
5 GPIO14
6 GPIO12
7 GPIO13
8 GPIO15
9 GPIO3
10 GPIO1
11 GPIO9
12 GPIO10
Vintech Systems
PROGRAM :
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(9600); /* Define baud rate for serial communication */
}
void loop() {
Vintech Systems
Ex .no : 7
Raspberry PI
Vintech Systems
Software platform:
Noobs
Raspbian
3rd OS
CentOS
OpenMedia
Vault
Fedora
LibreELEC
DietPi
RecalBox
Gentoo
Kano OS
Kali Linux
Lakka
OSMC (Open Source Media Center)
Manjaro
Retropie
Ubuntu
Kit Components:
Essential:
o Raspberry Pi board
o Prepared Operating System SD Card
o USB keyboard
o Display (with HDMI, DVI, or Composite input)
o Power Supply
Highly suggested extras include:
o USB mouse
o Internet connectivity - LAN cable
o Powered USB Hub
Programming Languages :
The Raspberry Pi Foundation recommends Python
Any language which will compile for ARMv6 can be used
Installed by default on the Raspberry Pi:
C
C++
Java
Scratch
Ruby
Vintech Systems
Python
Vintech Systems
RASPBERRY PI TRAINER KIT
Vintech Systems
Python Program :
Prerequisites
You should have a basic understanding of Computer Programming terminologies. A basic
understanding of any of the programming languages is a plus.
Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is
designed to be highly readable. It uses English keywords frequently where as other languages use
punctuation, and it has fewer syntactical constructions than other languages.
• Python is Interpreted − Python is processed at runtime by the interpreter. You do not need to
compile your program before executing it. This is similar to PERL and PHP.
• Python is Interactive − You can actually sit at a Python prompt and interact with the interpreter
directly to write your programs.
• Python is Object-Oriented − Python supports Object-Oriented style or technique of
programming that encapsulates code within objects.
• Python is a Beginner's Language − Python is a great language for the beginner-level
programmers and supports the development of a wide range of applications from simple text
processing to WWW browsers to games.
History of Python:
Python was developed by Guido van Rossum in the late eighties and early nineties at the National
Research Institute for Mathematics and Computer Science in the Netherlands. Python is derived
from many other languages, including ABC, Modula-3, C, C++, Algol-68, SmallTalk, and Unix
shell and other scripting languages. Python is copyrighted. Like Perl, Python source code is now
available under the GNU General Public License (GPL). Python is now maintained by a core
development team at the institute, although Guido van Rossum still holds a vital role in directing its
progress.
Vintech Systems
Python Features Python's features include –
• Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax. This
allows the student to pick up the language quickly.
• Easy-to-read − Python code is more clearly defined and visible to the eyes.
• Easy-to-maintain − Python's source code is fairly easy-to-maintain.
• A broad standard library − Python's bulk of the library is very portable and cross-platform
compatible on UNIX, Windows, and Macintosh.
• Interactive Mode − Python has support for an interactive mode which allows interactive testing and
debugging of snippets of code.
• Portable − Python can run on a wide variety of hardware platforms and has the same interface on
all platforms.
• Extendable − You can add low-level modules to the Python interpreter. These modules enable
programmers to add to or customize their tools to be more efficient.
• Databases − Python provides interfaces to all major commercial databases.
• GUI Programming − Python supports GUI applications that can be created and ported to many
system calls, libraries and windows systems,such as Windows MFC, Macintosh, and the X Window
system of Unix.
• Scalable − Python provides a better structure and support for large programs than shell scripting.
Apart from the above-mentioned features, Python has a big list of good features, few are listed below
–
• It supports functional and structured programming methods as well as OOP.
• It can be used as a scripting language or can be compiled to byte-code for building large
applications.
• It provides very high-level dynamic data types and supports dynamic type checking.
• It supports automatic garbage collection.
• It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
First Python Program:
1. Open notepad and type following program Print (“Hello World”)
2. Save above program with name.py
3. Open command prompt and change path to python program location
4. Type “python name.py” (without quotes) to run the program. Operators are the constructs which
can manipulate the value of operands.
Vintech Systems
Variables can be declared by any name or even alphabets like a, aa, abc, etc.
• Arithmetic Operators
• Comparison (Relational) Operators
• Assignment Operators
• Logical Operators
• Bitwise Operators
• Membership Operators
• Identity Operators Let us have a look on all operators one by one.
EX.NO :8
Vintech Systems
Interfacing Sensors with Raspberry Pi
Aim :
Perform Interfacing of DTH 11 Temperature and Humidity sensor with Raspberry Pi and evaluate
the response of variations.
APPARATUS REQUIRED :
THEORY:
Humidity is the measure of water vapour present in the air. The level of humidity in air affects
various physical, chemical and biological processes. In industrial applications, humidity can affect
the business cost of the products, health and safety of the employees. So, in semiconductor industries
and control system industries measurement of humidity is very important. Humidity measurement
determines the amount of moisture present in the gas that can be a mixture of water vapour, nitrogen,
argon or pure gas etc… Humidity sensors are of two types based on their measurement units. They
are a relative humidity sensor and Absolute humidity sensor. DHT11 is a digital temperature and
humidity sensor.
Vintech Systems
DHT11 humidity and temperature sensor is available as a sensor and as a module. The difference between this
sensor and module is the pull-up resistor and a power-on LED. DHT11 is a relative humidity sensor. To
measure the surrounding air this sensor uses a thermistor and a capacitive humidity sensor.
For measuring temperature this sensor uses a Negative Temperature coefficient thermistor, which causes a
decrease in its resistance value with increase in temperature. To get larger resistance value even for the
smallest change in temperature, this sensor is usually made up of semiconductor ceramics or polymers.
The temperature range of DHT11 is from 0 to 50 degree Celsius with a 2-degree accuracy. Humidity range of
this sensor is from 20 to 80% with 5% accuracy. The sampling rate of this sensor is 1Hz .i.e. it gives one
reading for every second. DHT11 is small in size with operating voltage from 3 to 5 volts. The maximum
current used while measuring is 2.5mA.
PROCEDURE :
Program :
import time
import board
import adafruit_dht
dhtDevice = adafruit_dht.DHT11(board.D4, use_pulseio=False) ## Raspberry pi 4 - gpio4
while True:
try:
# Print the values to the serial port
temperature_c = dhtDevice.temperature
temperature_f = temperature_c * (9 / 5) + 32
humidity = dhtDevice.humidity
print(
"Temp: {:.1f} F / {:.1f} C Humidity: {}% ".format(
Vintech Systems
temperature_f, temperature_c, humidity
)
)
time.sleep(2.0)
Result:
Vintech Systems
EX.NO: 9 Communicate between Arduino and Raspberry Pi using any wireless medium
Aim :
Perform and communicate between Arduino and Raspberry Pi using any Wireless medium and
evaluate the response .
APPARATUS REQUIRED :
PROCEDURE :
1. Arduino:
Write the arduino program and upload it
As per connection bluetooth to arduino TX-RX , RX-TX
2. Raspberry :
Connect the bluetooth on raspberry pi ,right corner click bluetooth icon and pair
finally disconnect the raspberry bluetooth -sudo rfcomm release 7 ----mac address---
Vintech Systems
Arduino Program :
int led=13;
void setup()
{
pinMode(led, OUTPUT);
Serial.begin(9600); //default baud rate for bt 38400
}
void loop()
{
if(Serial.available())
{
int a=Serial.parseInt();
Serial.println(a);
if (a==1)
{
digitalWrite(led, HIGH);
}
if (a == 0)
{
digitalWrite(led, LOW);
}
}
}
Vintech Systems
Raspberry Pi Program :
import serial
import time
bluetooth=serial.Serial("/dev/rfcomm7",9600)
while True:
a=input("enter:-")
string='X{0}'.format(a)
bluetooth.write(string.encode("utf-8"))
Result :
EXP.NO : 10
Vintech Systems
Setup a cloud Platform to log the data
Using NODE MCU module and Think Speak Cloud, writing and reading the temperature data
Node MCU is a low-cost open source IoT platform. It initially included firmware which runs on
the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which was based on the ESP-12
module. Later support for the ESP32 32-bit MCU was added.
Both the firmware and prototyping board designs are open source.
The firmware uses the Lua scripting language. The firmware is based on the eLua project, and built
on the Espressif Non-OS SDK for ESP8266. It uses many open source projects, such as lua-
cjson[9] and SPIFFS. Due to resource constraints, users need to select the modules relevant for their
project and build a firmware tailored to their needs. Support for the 32-bit ESP32 has also been
implemented.
0 [*] GPIO16
1 GPIO5
2 GPIO4
3 GPIO0
4 GPIO2
5 GPIO14
6 GPIO12
7 GPIO13
8 GPIO15
9 GPIO3
10 GPIO1
11 GPIO9
12 GPIO10
Vintech Systems
ThingSpeak is a cloud space owned by Matlab. Initally, we have to get an account and
create a new channel with say one field and save the channel. Then next screen appears in
which write and read api keys are available. These keys are noted and used later in the
program.
In this experiment, temperature is read and it is stored in the ThingSpeak cloud space.
Vintech Systems
Enter Name and Field. You may have multiple Fields depending on number of sensor create multiple fields
such as Light, Temperature, Humidity, etc.
Enter Name and Label thing speak esp8266
Keep everything else as it is. Blank or default values. and click on Save Channel. Thing Speak save channel
Vintech Systems
Note Write api key and update a channel feed
AT – Attention
AT+ RST - Reset
AT+CWMODE – 1- station , 2 – Access point , 3 - both
AT+ CWJAP+ SSID+PW – join network
AT+CIPMUX – 0 single , 1 – multi
AT+CIPSTART+type+host+port – 0 single, 1 – multiple – ( TCP/UDP)
AT+CIPSEND+datalength+bytes – 0 –single , 1 - multiple
AT+CIPCLOSE – 0 – single , 1 – multiple
Program:
#include <ESP8266WiFi.h>
String apiKey = " "; // Enter your Write API key from ThingSpeak
const char *ssid = " "; // replace with your wifi ssid and wpa2 key
Vintech Systems
const char *pass = " ";
const char* server = "api.thingspeak.com";
WiFiClient client;
void setup()
{
Serial.begin(115200);
delay(10);
dht.begin();
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
void loop()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
Vintech Systems
if (client.connect(server,80)) // "184.106.153.149" or api.thingspeak.com
{
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" degrees Celcius, Humidity: ");
Serial.print(h);
Serial.println("%. Send to Thingspeak.");
}
client.stop();
Serial.println("Waiting...");
Vintech Systems
OUT PUT :
Vintech Systems
EX.NO : 11 Log data using Raspberry Pi and upload to the cloud platform
IOT
INTRODUCTION TO IoT
Today the Internet has become ubiquitous, has touched almost every corner of the globe, and
is affecting human life in unimaginable ways.
We are now entering an era of even more pervasive connectivity where a very wide variety
of appliances will be connected to the web.
One year after the past edition of the Cluster book 2012 it can be clearly stated that the
Internet of Things (IoT) has reached many different players and gained further recognition. Out of
the potential Internet of Things application areas, Smart Cities (and regions), Smart Car and
mobility, Smart Home and assisted living, Smart Industries, Public safety, Energy & environmental
protection, Agriculture and Tourism as part of a future IoT Ecosystem (Figure 1.1) have acquired
high attention.
2. Another is the Internet of Things is defined as a paradigm in which computing and networking
capabilities are embedded in any kind of conceivable object.
We use these capabilities to query the state of the object and to change its state if possible.
In common parlance, the Internet of Things refers to a new kind of world where almost all the
devices and appliances that we use are connected to a network.
We can use them collaboratively to achieve complex tasks that require a high degree of
intelligence.
For this intelligence and interconnection, IoT devices areequipped with embedded sensors,
actuators, processors, andtransceivers.
IoT is not a single technology; rather it is anagglomeration of various technologies that work
together intandem.
Sensors and actuators are devices, which help in interactingwith the physical environment.
The data collected by thesensors has to be stored and processed intelligently in order toderive
useful inferences from it.
Note that we broadly definethe term sensor; a mobile phone or even a microwave ovencan count as
a sensor as long as it provides inputs about itscurrent state (internal state + environment).
Vintech Systems
An actuator is adevice that is used to effect a change in the environment suchas the temperature
controller of an air conditioner.
The storage and processing of data can be done on theedge of the network itself or in a remote
server.
If any preprocessingof data is possible, then it is typically done at eitherthe sensor or some other
proximate device.
The processeddata is then typically sent to a remote server.
The storageand processing capabilities of an IoT object are also restrictedby the resources
available, which are often very constraineddue to limitations of size, energy, power, and
computationalcapability.
As a result the main research challenge is toensure that we get the right kind of data at the desired
levelof accuracy.
Along with the challenges of data collection, and handling, there are challenges in communication
aswell.
The communication between IoT devices is mainlywireless because they are generally installed at
geographicallydispersed locations.
The wireless channels often have high rates of distortion and are unreliable.
In this scenario reliablycommunicating data without too many retransmissions is animportant
problem and thus communication technologiesare integral to the study of IoT devices.
We can directly modify the physical world through actuators or we may do something virtually.
For example,we can send some information to other smart things.
PROGRAM :
import httplib
import urllib
import time
key = "4IX9VESM09B9MQ7H" # Put your API Key here
def thermometer():
while True:
#Calculate CPU temperature of Raspberry Pi in Degrees C
temp = int(open('/sys/class/thermal/thermal_zone0/temp').read()) / 1e3 # Get Raspberry Pi CPU
temp
params = urllib.urlencode({'field1': temp, 'key':key })
headers = {"Content-typZZe": "application/x-www-form-urlencoded","Accept": "text/plain"}
conn = httplib.HTTPConnection("api.thingspeak.com:80")
try:
conn.request("POST", "/update", params, headers)
response = conn.getresponse()
print temp
print response.status, response.reason
data = response.read()
conn.close()
Vintech Systems
except:
print "connection failed"
break
if __name__ == "__main__":
while True:
thermometer()
Aim :
To design an IOT based System with Node MCU ESP8266 and BLYNK App and evaluate the
response of variations.
APPARATUS REQUIRED :
Theory :
A quick guide to designing a perfect Internet of Things (IoT) system taking into account
performance, connectivity, power consumption and security issues
The Internet of Things (IoT) is no longer a technology of the future. Smart cities, connected
industries and smart households have indeed ushered in an era where machines can communicate.
The beauty of this technology lies in the fact that the complex backend structure of systems is
represented to the end-user in the simplest possible form. This requires profound design know-how.
Vintech Systems
The IoT can be designed at different scales for different uses. It can start from our homes with
simple lighting or appliance control, and expand into the realm of factories and industries with
automated machines, smart security systems and central management systems—called connected
factories. It has scaled up to entire cities with smart parking, smart metering, waste management, fire
control, traffic management and any similar functions involved. However, irrespective of the scale of
application, the main IoT backbone remains similar.
The IoT architecture is multi-layered with delicate components intricately connected to each other. It
starts with sensors, which are the source of data being collected. Sensors pass data onto an adjacent
edge device, which converts data into readable digital values and stores these temporarily. When the
edge senses a suitable wireless network or the Internet, it pushes the locally stored data to a cloud
server involved in the application. The data is processed, analysed, stored and forwarded to the end-
user device, represented by an application software. All the design fundamentals and challenges
revolve around these layers.
Vintech Systems
Designing the connectivity module :
The ESP8266 is a system on a chip (SOC) Wi-Fi microchip for Internet of Things (IoT) applications
produced by Espressif Systems.
Given its low cost, small size and adaptability with embedded devices, the ESP8266 is now used
extensively across IoT devices. Although it’s now been succeeded by the newer generation ESP32
microcontroller chip, the ESP8266 is still a popular choice for IoT developers and manufacturers.
In this article, we’ll explain the main features of ESP8266 modules and development boards and
their application within the world of IoT.
The ESP8266 module enables microcontrollers to connect to 2.4 GHz Wi-Fi, using IEEE 802.11
bgn. It can be used with ESP-AT firmware to provide Wi-Fi connectivity to external host MCUs, or
it can be used as a self-sufficient MCU by running an RTOS-based SDK. The module has a full
TCP/IP stack and provides the ability for data processing, reads and controls of GPIOs.
Vintech Systems
PROGRAMM :
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
void setup( )
{
// Initialize Serial Monitor
Serial.begin(9600);
// Connect to Wi-Fi
Blynk.begin(auth, ssid, pass);
void loop( )
{
Blynk.run( );
}
Vintech Systems
// Blynk virtual pins for the 8 relays (V1)
BLYNK_WRITE(V1)
{
int value = param.asInt( ); // Get the value from the app
digitalWrite(D1, value);
}
WORKING PRINCIPLE :
Vintech Systems
Vintech Systems
Vintech Systems
Vintech Systems
Vintech Systems
Vintech Systems
Vintech Systems
Vintech Systems
Working of Relay module :
According to the diagram we can see that there is switch like thing inside the relay module whose
one end is connected to COM i.e. Pin 4 and the other end is either connected between NO i.e. Pin 5
or NC i.e. Pin 6. When we are applying 0 V to the signal pin i.e. Pin 3 then the switch remains in NO
position (normally open). When we apply +5 V to signal pin the switch drips from NO to NC
(normally connected).
Vintech Systems
Creating the project in BLYNK App :
Download the BLYNK App from Google Playstore (link has been already given). Open it and you
have to make an account there. After that click on "New Project". Now you have to click "CHOOSE
DEVICE" and you will be asked to select required hardware, you will choose "Arduino UNO" and
in "CONNECTION TYPE" you have to select "USB".You have to give a project name also. Then
you click on "Create".Your project is now created and BLYNK will send an authorization token to
your mail which you have to put in the arduino code.Then you will get a free space where you have
to add buttons,graphs etc. You will get all these from the widget box. In this project as we are
operating only one appliance so we will add only one button. After clicking on "Button" the icon
will be added in the free space. You can plasce the button anywhere on the screen. Then you have to
click on the button to customize it. You have to give a name there and you have to select whether
you are using digital or analog ao virtual pin. You also have to mention the pin no. As in this project
we are using D13 i.e. Digital pin 13 . Now select the mode whether "Push" or "Slide" , it depends
upon you. After that return to the main screen ,you will see a play button on the right corner of the
screen, you have to click on that to activate the project .If your system is ready and connected to
internet then on mobile after clicking the play button it will show "Online" otherwise "Offline".
First of all you have to add the following link in "additional boards manager URL" in preferences in
the Arduino IDE. Link :http://arduino.esp8266.com/stable/package_esp8266c...
Just copy the code(already provided) or you can get the code from Examples-->Blynk--
>Boards_USB_Serials-->Arduino_Serial_USB. In both cases the only change you have to make is
that copy the authorization code sent to your mail to Arduino code. Don't upload the code now. Now
open "Command Prompt" and run it as administration. A black screen will appear on the screen.
Then you have to copy the path of "scripts" folder. In my case it is "My Documents\Arduino\
libraries\Blynk\scripts" and paste it on the black screen and place enter. Then you have to copy and
paste the .bat file in the black screen. The file is "blynk-ser.bat -c COM4" .You have to change the
COM port number. In my case it was COM8 .Now upload the arduino code .Now come back to the
command prompt part and press "enter" thrice. This will connect you to Blynk Server .
Vintech Systems
Now open blynk app from your mobile and open the project you have created. If your system is
connected to Blynk server then you will see 'Online' in your mobile otherwise you will
see 'Offline'. Now click on the button to On or Off the appliance. If it is not working then check
whether the system is connected to the blynk server.
Result :
Vintech Systems