ESIoT Lab Manual
ESIoT Lab Manual
EXPERIMENT
OUTPUT:
RESULT:
Thus the assembly language program was performed and got output
successfully
2 EXPERIMENT
OUTPUT:
RESULT: Thus the data transfer between registers and memory experiment
was performed and got output successfully.
3.EXPERIMENT
AIM: To perform Arithmetic and Logical Unit (ALU) operations
(Addition, Subtraction, AND, OR) using the 8051 microcontroller and
verify the results by storing them in registers.
All Arithmetic and logical program
//Addition
MOV A,#25H
MOV B,#12H
ADD A,B
//SUBTRACTION
MOV A,#25H
MOV B,#12H
SUBB A,B
MOV 41H,A
//multiplication
MOV A,#25H
MOV B,#12H
MUL AB
MOV 42H,A
MOV 43H,B
//DIVISION
MOV A,#25H
MOV B,#12H
DIV AB
MOV 44H,A
MOV 45H,B
Logical operation
//AND OPERATION
MOV A,#25H
MOV B,#12H
ANL A,B
MOV 46H,A
//OR OPERATION
MOV A,#25H
MOV B,#12H
ORL A,B
MOV 47H,A
//XRL OPERATION
MOV A,#25H
MOV B,#12H
XRL A,B
MOV 48H,A
//INCREMENT
INC A
MOV 49H,A
//DECREMENT
DEC A
MOV 4AH,A
LCALL 0003
END
OUTPUT:
Arithmetic:
Logical:
RESULT: Thus the ALU operation was performed and got output
successfully.
4 A) EXPERIMENT
OUTPUT:
4C)
RESULT:
Thus the Program for flashing of LED is executed successfully using embedded C
program.
4D)
Square wave generation using C program
#include<REG51xD2.H>
for(;x>0;x--);
main()
{
P0=on;
delay(100);
P0=Off;
delay(100);
OUTPUT:
4 E)
Output: SM Micro System , hour=18; min=30; sec=30
4f)
Output: Temperature sensor:
Adc test 28 degree Celsius
Stepper motor:Motor will run in forward direction
Result:
Thus the program for stepper motor and temperature sensor is
executed sucessfully.
5) ARDUINO PROGRAMMING
5 A) BLINKING OF LED
AIM:
To execute blinking of led program using Arduino Uno board
ALGORITHM:
1.Start the program
2.Save the program
3.Compile the code by clicking the tick mark
4.Upload the code
5.Go to Tools--> Board--> Arduino Uno
6.Go to Tools-->port-->check in device manager for port selection
PROGRAM:
int LEDpin = 13;
int delayT = 2000;
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
pinMode(LEDpin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LEDpin, HIGH);
delay(delayT);
digitalWrite(LEDpin, LOW);
delay(delayT);
}
Output:
The led light turns on and off with a delay of 2 seconds.
RESULT:
Thus the program for blinking of LED is executed successfully.
5 B) IR SENSOR
AIM:
To determine whether is object is present or not using IR Sensor.
ALGORITHM:
1.Start the program
2.Save the program
3.Compile the code by clicking the tick mark
4.Upload the code
5.Go to Tools--> Board--> Arduino Uno
6.Go to Tools-->port-->check in device manager for port selection
7.Sketches-->Serial monitor to see the result
PROGRAM:
int IR_Sensor=2;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(IR_Sensor, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int SensorValue=digitalRead(IR_Sensor);
if(SensorValue==LOW)
{
Serial.println("No object Detected");
}
else {
Serial.println("object Detected");
}
delay(500);
}
or
Output:
The object is detected when it is placed near the sensor.
RESULT:
Thus the program for object is present or not using IR Sensor
is executed successfully.
5 C)ULTRASONIC SENSOR
AIM:
To measure the distance of the object using ultrasonic sensor.
ALGORITHM:
1.Start the program
2.Save the program
3.Compile the code by clicking the tick mark
4.Upload the code
5.Go to Tools--> Board--> Arduino Uno
6.Go to Tools-->port-->check in device manager for port selection
7.Sketches-->Serial monitor to see the result
PROGRAM:
const int trigPin=9; // it defines the Triger pin of the sensor to pin 5 of Arduino
const int echoPin=10;
// we have defined the variable
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
void setup()
{
// It sets the TRIG pin as INPUT
Serial.begin(9600); // // Serial Communication at the rate of 9600 bps
pinMode(echoPin, INPUT);
Serial.println("Test of the Ultrasonic Sensor HC-SR04"); // It will appear on Serial
Monitor
Serial.println("with the Arduino UNO R3 board");
}
void loop()
{
// It first sets the TRIG pin at LOW for 2 microseconds
digitalWrite(trigPin,HIGH);
delayMicroseconds(2);
digitalWrite(trigPin,LOW);
// It will read the ECHO pin and will return the time
duration = pulseIn(echoPin,HIGH);
// distance formula
distance = duration*(0.034/2); // (speed in microseconds)
// Speed of sound wave (340 m/s)divided by 2 (forward and backward bounce)
// To display the distance on Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm"); //specified unit of distance
delay(1000);
}
OUTPUT:
RESULT:
Thus the program for measuring distance of the object using
ultrasonic sensor is executed successfully.
5 D) WATER SENSOR
AIM:
To Detect the moisture level using Water Sensor.
ALGORITHM:
1.Start the program
2.Save the program
3.Compile the code by clicking the tick mark
4.Upload the code
5.Go to Tools--> Board--> Arduino Uno
6.Go to Tools-->port-->check in device manager for port selection
7.Sketches-->Serial monitor to see the result
PROGRAM:
#define Grove_Water_Sensor 8 // Attach Water sensor to Arduino Digital Pin 8
#define LED 13 // Attach an LED to Digital Pin 9 (or use onboard LED)
void setup() {
pinMode(Grove_Water_Sensor, INPUT); // The Water Sensor is an Input
Serial.begin(9600);
pinMode(LED, OUTPUT); // The LED is an Output
}
void loop() {
/* The water sensor will switch LOW when water is detected.
Get the Arduino to illuminate the LED and activate the buzzer
when water is detected, and switch both off when no water is present */
if( digitalRead(Grove_Water_Sensor) == LOW)
{
digitalWrite(LED,HIGH);
Serial.println("No Moisture");
}
else {
digitalWrite(LED,LOW);
Serial.println("Moisture is Present");
}
delay(500);
}
OUTPUT:
RESULT:
Thus the program to Detect the moisture level using Water Sensor
is executed successfully.
OUTPUT:
RESULT:
Thus the program to measure the temperature and humidity using
temperature Sensor is executed successfully.
EXPERIMENT 10: SETUP A CLOUD PLATFORM TO LOG THE DATA
AIM: To setup a cloud platform to log the data using wifi module
APPARATUS REQUIRED:
PROGRAM:
#define BLYNK_TEMPLATE_ID "TMPL3R5MDYF7N"
#define BLYNK_TEMPLATE_NAME "test2"
#define BLYNK_AUTH_TOKEN "ZN2-L6mu_9szoqLmqG8XIKR50wsI8RNc"
#define CLOUDCHECKER V4
#define TIMER V5
#define LIGHT 2
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
BLYNK_CONNECTED() {
Blynk.setProperty(CLOUDCHECKER, "offImageUrl", "https://static-
image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
Blynk.setProperty(CLOUDCHECKER, "onImageUrl", "https://static-
image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
Blynk.setProperty(CLOUDCHECKER, "url", "https://docs.blynk.io/en/getting-
started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}
void myTimerEvent() {
Blynk.virtualWrite(TIMER, millis() / 1000);
}
BLYNK_WRITE(V0)
{
if (param.asInt() == 1)
{
Serial.println(param.asInt());
Serial.println("Light is ON");
digitalWrite(LIGHT, LOW);
}
else
{
digitalWrite(LIGHT, HIGH);
}
}
void setup() {
Blynk.begin(auth, ssid, pass);
pinMode(LIGHT,OUTPUT);
Serial.begin(9600);
Serial.print("Ready!");
}
void loop() {
Blynk.run();
}
OUTPUT:
RESULT: Thus to setup a cloud platform to log the data exceuted successfully.
EXPLORE DIFFERENT COMMUNICATION METHODS WITH IOT DEVICES (ZIGBEE,
GSM, BLUETOOTH)
EXP NO: 6
DATE :
Zigbee
ZigBee is similar to Bluetooth and is majorly used in industrial settings. It has some significant
advantages in complex systems offering low-power operation, high security, robustness and
high and is well positioned to take advantage of wireless control and sensor networks in IoT
applications.
The latest version of ZigBee is the recently launched 3.0, which is essentially the unification of
the various ZigBee wireless standards into a single standard.
Bluetooth
Page | 28
Iot Technology – Bluetooth
This works with android phones and the HC-05 and HC-06 bluetooth modules, as well as pretty
much any arduino or arduino clone.
RX-pin2
TX-pin 3
GND-GND
VCC-5v
Page | 29
Step 3: Connect to the Bluetooth on Your Phone
Open up the bluetooth settings on your phone and look for the module. Mine is named Sailfish
but yours should be named either hc-05 or hc-06. The password is almost always 1234, if not,
try 0000.
download a bluetooth terminal app from the appstore, this one works great:
https://play.google.com/store/apps/details?id=Qwerty.BluetoothTerminal&hl=en and open it
up. Open the app, hit connect to a device - insecure and select your bluetooth module from the
list.
Page | 30
Step 5: Ready to Go!
Finally open up the Serial Monitor in the arduino IDE by hitting the magnifying glass in the top
right corner, and you should be good to go. You now have a back and forth extremely simple
connection between your phone and your arduino via bluetooth.
Cellular
Any IoT application that requires operation over longer distances can take advantage of
GSM/3G/4G cellular communication capabilities. While cellular is clearly capable of sending
high quantities of data, especially for 4G, the cost and also power consumption will be too high
for many applications.
But it can be ideal for sensor-based low-bandwidth-data projects that will send very low
amounts of data over the Internet.
Page | 31
IoT Communication Protocols – Cellular
RESULT
Thus the different communication methods with IOT devices (Zigbee, Gsm, Bluetooth)
was studied successfully
Page | 32
INTRODUCTION TO RASPBERRY PI PLATFORM AND PYTHON PROGRAMMING
EXP NO: 7
DATE :
Raspberry Pi - Introduction
Raspberry Pi, developed by Raspberry Pi Foundation in association with Broadcom, is a
series of small single-board computers and perhaps the most inspiring computer available
today.
From the moment you see the shiny green circuit board of Raspberry Pi, it invites you to
tinker with it, play with it, start programming, and create your own software with it. Earlier,
the Raspberry Pi was used to teach basic computer science in schools but later, because of its
low cost and open design, the model became far more popular than anticipated.
It is widely used to make gaming devices, fitness gadgets, weather stations, and much more.
But apart from that, it is used by thousands of people of all ages who want to take their first
step in computer science.
It is one of the best-selling British computers and most of the boards are made in the Sony
factory in Pencoed, Wales.
Generations and Models
In 2012, the company launched the Raspberry Pi and the current generations of regular
Raspberry Pi boards are Zero, 1, 2, 3, and 4.
Generation 1 Raspberry Pi had the following four options −
Model A
Model A +
Model B
Model B +
Among these models, the Raspberry Pi B models are the original credit-card sized format.
On the other hand, the Raspberry Pi A models have a smaller and more compact footprint and
hence, these models have the reduced connectivity options.
Raspberry Pi Zero models, which come with or without GPIO (general-purpose input output)
headers installed, are the most compact of all the Raspberry Pi boards types.
Speed Specifications
The table below gives the speed specifications of various Raspberry Pi models and
generations focusing on the version‟s release date, form factor and dimensions −
Page | 33
Raspberry Pi 3 Model A+ 2018 Compact 65 x 56.5
Raspberry
Pi 4 Model 46 40 Pin 1.5 GHz Quad 1,2,4, or 8 GB
B
Raspberry
Pi 3 Model 50 40 Pin 1.4 GHz Quad 1 GB
B+
Raspberry
Pi 3 Model 40 40 Pin 1.2 GHz Quad 1 GB
B
Raspberry
Pi 3 Model 28 40 Pin 1.4 GHz Quad 512 MB
A+
Raspberry
40 Pin 512
Pi Zero 10 1 GHz Single
Unpopulated MB
Wireless
Raspberry
Pi 2 Model 42 40 Pin 1.2 1 GB
Quad
B GHz
Raspberry
700 512
Pi 1 Model 42 40 Pin Single
MHz MB
B+
Raspberry
21 Pin (26 700 512
Pi 1 Model 38 Single
Pin Header) MHz MB
B
Raspberry
700 512
Pi 1 Model 23 40 Pin Single
MHz MB
A+
Raspberry
21 Pin (26 700 256
Pi 1 Model 30 Single
Pin Header) MHz MB
A
Connectivity Specifications
The table below gives the connectivity specifications of various Raspberry Pi boards focusing on
the version‟s full sized USB ports, other USB and charge methods, power and High-Definition
Multimedia Interface (HDMI) ports –
Raspberry Pi Full sized USB Other USB & Power HDMI Ports
Version Ports Charge Methods
Page | 35
Raspberry Pi 2 USB3.0 2 1 USB-C 5.1V at 3A 2 micro-HDMI
4 Model B USB2.0
Page | 36
The table below gives the connectivity specifications of various Raspberry Pi boards
focusing on the version‟s video out quality, video in, Ethernet, bluetooth, Wi-Fi and
external storage –
Raspberry 4kp60 CSI Camera Gigabit Bluetooth 5.0 Dual Band- MicroSD
Pi 4 Connector Ethernet 2.4 GHz and
Model B 5GHz
Raspberry 1080p60 CSI Camera 10/100 Bluetooth 4.1 2.4 GHz MicroSD
Pi 3 Connector Mbit/s
Model B
Raspberry 1080p60 CSI Camera ___ Bluetooth 4.1 2.4 GHz MicroSD
Pi Zero Connector
Wireless
with
Headers
Raspberry 1080p60 CSI Camera ___ Bluetooth 4.1 2.4 GHz MicroSD
Pi Zero Connector
Wireless
Page | 37
Raspberry 1080p60 CSI Camera 10/100 ___ ___ MicroSD
Pi 1 Connector Mbit/s
Model B
+
RESULT:
Thus the introduction to raspberry pi platform and python programming was studied
successfully.
Page | 38
INTERFACING SENSORS WITH RASPBERRY PI
EXP NO: 8
DATE :
The Raspberry Pi IR Sensor Interface can be converted into a Proximity Detector, where the
application will detect if the object is too close to the sensor.
Circuit Diagram
The following image shows the connection diagram of Interfacing IR Sensor with Raspberry Pi.
You have already seen the circuit diagram of the IR Sensor Module.
Components Required
Raspberry Pi 3 Model B
IR Sensor
5V Buzzer
Mini Breadboard
Connecting Wires
Power Supply
Computer
Circuit Design
The IR Sensor Module has only three Pins: VCC, GND and Data. Connect the VCC and GND
pins of the IR Sensor to +5V and GND pins of the Raspberry Pi.
Then connect the Data pin of the IR Sensor to GPIO23 i.e. Physical Pin 16 of the Raspberry Pi.
Page | 39
In order to indicate the alarm, I have used a simple 5V Buzzer. Connect one terminal of the
buzzer to GND of Raspberry Pi and the other terminal (usually marked +) to GPIO24 i.e.
Physical Pin 18 of Raspberry Pi.
Code
The following is the code for interfacing IR Sensor with Raspberry Pi. It is written in Python.
sensor = 16
buzzer = 18
GPIO.setmode(GPIO.BOARD)
GPIO.setup(sensor,GPIO.IN)
GPIO.setup(buzzer,GPIO.OUT)
GPIO.output(buzzer,False)
print "IR Sensor Ready....."
print " "
try:
while True:
if GPIO.input(sensor):
GPIO.output(buzzer,True)
print "Object Detected"
while GPIO.input(sensor):
time.sleep(0.2)
else:
GPIO.output(buzzer,False)
except KeyboardInterrupt:
GPIO.cleanup()
Working
We have learned how to interface an IR Sensor with Raspberry Pi. I‟ll now explain the working
of the project.
All the magic happens in the IR Sensor Module. As it is a Reflective type IR Sensor, whenever
an object is placed in front of the sensor, the Infrared light from the IR LED gets reflected back
after hitting the object and falls on the Photo Diode.
The photo diode then starts conducting. As a result, the voltage at the non-inverting input of the
LM358 will be greater than that at the inverting input.
Page | 40
Since the LM358 is acting as a Comparator, its output will become HIGH and the on-board
LED glows. The HIGH on the Data Pin is detected by the Raspberry Pi and it activates the
buzzer.
Using the 10 KΩ Potentiometer, you can adjust how far the object can be placed in front of the
sensor in order to detect.
Applications
As mentioned in the earlier sections, Proximity Sensor or Obstacle Detection is the main
application of interfacing IR Sensor with Raspberry Pi. Some of the common applications
include:
Contactless Tachometer
Line Follower Robot
Obstacle Avoiding Robot
Car Reverse Sensor
Mobile Proximity Sensor
RESULT:
Page | 41
COMMUNICATE BETWEEN ARDUINO AND RASPBERRY PI USING ANY
WIRELESS MEDIUM
EXP NO: 9
DATE :
1. Summary:
The process of how to communicate an Arduino and a Raspberry Pi with nRF24L01 module.
To Start off We will be learning Some basics of Raspberry Pi then we will have a look at
Headless Raspberry Pi setup. For the Implementation firstly, we will understand the simple
communication of Arduino to Arduino then we will learn Arduino to the raspberry pi.
2. Required Components:
Ultrasonic Sensor
2 Arduino Uno
Raspberry Pi 3
2 nRF24l01 transmitter and receiver
Jump wires
Arduino cable
MINI USB 2.0 for Pi
Breadboard
3. Required Software:
Raspbian for pi
Arduino IDE or Visual Studio
Putty on a remote computer for SSH
VNC viewer on a remote computer
4. Introduction to Raspberry Pi 3:
Page | 42
4.1. Components Specifications:
1.4 GHz 64-bit quad-core ARM Cortex-A53, 1GB RAM
2.4/5Ghz dual-band 802.11ac Wireless LAN, 10/100/1000Mbps Ethernet Bluetooth 4.2
4 USB ports, Full HDMI port, Combined 3.5mm audio jack and composite video port,
40 GPIO pins
Micro SD card slot, Video Core IV 3D graphics core, Camera interface (CSI), Display
interface (DSI)
4.2 Raspberry Pi Pinout:
Page | 43
4.3. Headless Raspberry Pi Setup:
Say, I just bought a raspberry pi and wish to check out how it works. But all I have is
my Laptop, the Pi, a micro SD card, and my Wi-Fi network. How do I connect and
control the Pi?
1) Download Raspbian:
Your Pi needs an OS. Download Raspbian from Raspberrypi.org „s download section:
https://www.raspberrypi.org/downloads/raspbian/
Page | 44
4) Configure Wi-Fi:
It‟s easier to make two devices talk to each other if they are in the same network. An
ethernet cable can easily make your laptop‟s network available to the Pi. But we don‟t
have one. So, we are going to add a file to the SD card so that the Pi boots with a wifi
pre-configured.
The SD card mounts as two volumes boot and rootfs . Open the boot volume and create
a file named wpa_supplicant.conf on booting the RPi, this file will be copied to
/etc/wpa_supplicant directory in /rootfs partition. The copied file tells the Pi the WIFI
setup information. This would overwrite any existing WIFI configuration, so if you had
already configured WIFI on the pi, then that will be overwritten.
A typical wpa_supplicant.conf file is as follows:
ctrl_interface=DIR=/var/run/wpa_supplicant
GROUP=netdevupdate_config=1country=US
network={ ssid="«your_SSID»" psk="«your_PSK»" key_mgmt=WPA-PSK}
NOTE: Your SSID is your WIFI‟s name. And psk is the password of the WI-FI.
5) Enable SSH
We will later access the Pi using a secured shell (SSH), SSH is disabled by default in
Raspbian. To enable SSH, create a file named ssh in the boot partition. If you are on
Linux, use the touch command to do that.
Page | 45
6) Find Pi‟s Ip address:
Before switching on your raspberry pi, we need to find out the existing devices
connected to the network. Make sure your laptop is connected to the same WIFI
network as the one you configured on pi above.
Download the Advanced IP Scanner to scan the IP of our raspberry pi. You can
download it from here https://www.advanced-ip-scanner.com/
Page | 46
Default credentials are:
username: pipassword: raspberry
8) Access Pi remotely:
Sometimes it doesn‟t feel right if we can‟t use the mouse. For that, we need to look into
the Raspbian desktop.
We need to setup VNC (Virtual Network Connection) to see and control Pi graphically.
Let‟s do that.
To access the remote desktop, you need VNC-viewer (client) for your laptop.
Fortunately, RealVNC is available for a lot of OSes, pick one for your OS
from https://www.realvnc.com/en/connect/download/viewer/
9) Commands for vncserver:
Page | 47
10) Now open VNC Viewer on your remote computer:
Page | 48
5. Implementation and Working:
Schematic Diagram for wiring of Arduino Uno with ultrasonic sensor and NRF24L01
To wire your NRF24L01+ wireless sender to your Arduino, connect the following pins:
Connect the VCC pin to 3.3 Volts
Connect the GND pin to ground (GND)
Page | 49
Connect the CE pin to Arduino 9
Connect the CSN pin to Arduino 10
Connect the SCK pin to Arduino 13
Connect the MOSI pin to Arduino 11
Connect the MISO pin to Arduino 12
Page | 50
5.2. Code:
Sender Side code:
Receiver Side code:
Sending the Data
Page | 51
Receiving the data:
Page | 52
Further are the steps to which involve the installation of the Library. It took me almost
one week to install it as no clear idea about it is present.
=> Way to go:
1. Login to Raspberry Pi using Putty.
2. Go to the VNC server for GUI.
3. In the terminal type:
sudo raspi-config
Page | 54
6.2. Wireless communication of Arduino to Arduino with nRF24L01:
In this, we will learn how to make wireless communication between Arduino and
Raspberry Pi using the NRF24L01. And measure distance with an ultrasonic sensor
with the help of Arduino Uno and transmit it to Raspberry Pi and Data is received.
Wiring Instructions:
To wire your NRF24L01+ wireless Sender to your Arduino, connect the following pins:
Connect the VCC pin to 3.3 Volts
Connect the GND pin to ground (GND)
Connect the CSN pin to Arduino 10
Connect the CE pin to Arduino 9
Connect the SCK pin to Arduino 13
Connect the MISO pin to Arduino 12
Connect the MOSI pin to Arduino 11
To wire your ultrasonic sensor to your Arduino, connect the following pins:
Connect the VCC pin to Arduino 5Volts
Connect the GND pin to ground (GND)
Connect the Trig pin to Arduino 4
Connect the Echo pin to Arduino 3
Schematic Diagram:
Page | 55
Schematic Diagram for wiring of Arduino Uno with ultrasonic sensor and NRF24L01
To wire your NRF24L01+ Wireless Receiver to your Raspberry Pi, connect the
following pins:
Connect the VCC pin to 3.3 Volts (Pin 1)
Connect the GND pin to ground (GND) (Pin 6)
Connect the CE pin to Raspberry GPIO 22
Connect the CSN pin to Raspberry GPIO 8
Connect the SCK pin to Raspberry GPIO 11
Connect the MOSI pin to Raspberry GPIO 10
Connect the MISO pin to Raspberry GPIO 09
Schematic Diagram:
Page | 56
Schematic Diagram for wiring of Raspberry Pi and NRF24L01
6.3. Code:
Sender Side Code:
Receiver Side Code:
It's not mandatory to use this code as it is tweaked by me as per my requirement.
To check the proper functioning of your connection and code you can run the examples
present in the library like pingpair_dyn.ino on your Arduino and pingpair_dyn.py on
Raspberry Pi
The snippet of my running communication:
Page | 57
RESULT:
Thus the communicate between arduino and Raspberry Pi Using Any Wireless Medium was
successfully studied.
Page | 58
LOG DATA USING RASPBERRY PI AND UPLOAD TO THE CLOUD PLATFORM
EXP NO: 11
DATE :
ThingSpeak is an open IoT platform for monitoring your data online. In ThingSpeak
channel you can set the data as private or public according to your choice. ThingSpeak takes
minimum of 15 seconds to update your readings. Its a great and very easy to use platform for
building IOT projects.
There are also some other platforms available for monitoring your data online which we will
cover in later articles but there are some advantages of ThingSpeak over other platforms like it
is very easy to set up and it also has many options to plot graph.
Components Required
1. Raspberry Pi
2. Power Cable
3. WiFi or Internet
Page | 67
Click on signup if you don‟t have account and if you already have account click on sign in.
After clicking on signup fill your details.
After clicking on “New Channel”, enter the Name and Description of the data you want to
upload on this channel. For example I am sending my CPU data (temperature), so I named it as
CPU data.
Page | 68
Now enter the name of your data (like Temperature or pressure) in Field1. If you want to use
more than one Field you can check the box next to Field option and enter the name and
description of your data.
After this click on save channel button to save your details.
Now copy your “Write API Key”. We will use this API key in our code.
python /path/filename.py
Page | 69
Assuming you already installed python in Raspberry pi using this command
Case 1: If you are using monitor screen then just use the given code.
Now install all libraries:
If there are any errors uploading the data, you will receive “connection failed” message.
Case 2: If you are using “Putty” then you should follow these commands:
First update your pi using:
Page | 70
After this make a file cpu.py using:
nano cpu.py
After creating this file copy your code to this file and save it using CTRL + X and then „y‟ and
Enter.
After this install all libraries using:
python cpu.py
If the code runs properly you will see some CPU temperature values as shown in above image.
Page | 71
Like this you can send any sensor data connected with Raspberry pi to the ThingSpeak Cloud.
In next article we will connect LM35 temperature sensor with Raspberry Pi and send the
temperature data to ThingSpeak, which can be monitored from anywhere.
Complete Python code for this Raspberry Pi Cloud Server is given below. Code is easy and
self-explanatory to understand.
Code
import httplib
import urllib
import time
def thermometer():
while True:
Page | 72
temp = int(open('/sys/class/thermal/thermal_zone0/temp').read()) / 1e3 # Get Raspberry Pi
CPU temp
conn = httplib.HTTPConnection("api.thingspeak.com:80")
try:
response = conn.getresponse()
print temp
data = response.read()
conn.close()
except:
break
if __name__ == "__main__":
while True:
thermometer()
RESULT:
Thus the Log Data Using Raspberry Pi and Upload to The Cloud Platform was studied
successfully
Page | 73
DESIGN AN IOT BASED SYSTEM
EXP NO: 12
DATE :
The location of gateways should be as close to the IoT fleet as possible. It‟s necessary to
provide a lower latency in their communication.
#6 Principle: The system should be easily scalable
The future growth of the IoT system directly depends on its opportunities to scale efficiently
and stay robust when the volume of data and the number of devices increase.
#7 Principle: Build trust in your system
Since the Internet of Things often deals with sensitive information, you need to build trust in
your system to acquire more users. Trust should become one of the core values.
#8 Principle: Deploy only working products
Once the connected devices are deployed, their replacement with a newer version will be an
almost impossible task to accomplish because of high costs. That means that one single error in
the fleet which is detected after the fleet deployment can lead to large financial losses. Due to
that, it‟s good to avoid untested hardware iterations and deploy only working products.
Building a great IoT design is not an easy task. However, we managed to find 3 breathtaking
examples that managed to follow our principles above.
Whistle – Better tech for better care
Whistle is an application that connects to the IoT device on a pet through the cellular network.
Its goal is to take care of the pets by providing precise data to their owners. The IoT device
monitors key behaviors like scratching, drinking, sleep, licking, and other activities. Then it
analyzes them and assigns a score to the pet‟s health. The scoring system leverages machine
Page | 77
learning methods and health stories from 100 000 + dogs to evaluate a pet‟s behavior and track
its wellness.
Keymitt – Smart locks for your doors
Keymitt offers smart door locks with voice assistance. The Keymitt application is very
convenient and user-friendly, and it is compatible with Android and iOS smartphones. This IoT
solution is much safer than ordinary door locks because it ensures privacy and secure access
thanks to real-time notifications of the owner. Moreover, smart locks have one great advantage
compared to traditional locks – your application is responsible for lock control, there is no need
to hold keys.
Curve – The smart GPS tracker
Curve is a smart GPS tracker that can be attached to almost anything. You can track your keys,
pets, or your favorite bag. Curve uses 4 different tracking technologies; GPS, Wi-Fi, Cellular
and Bluetooth so even if you‟re at home or outside, you‟ll have a reliable connection to
whatever you‟re trying to find.
August Smart Lock Pro – Key-free access to your home
The August Smart Lock Pro is a smart lock that allows users to remotely control their door
locks using their smartphones. It integrates with popular smart home platforms like Alexa and
Google Assistant, allowing users to lock and unlock their doors with voice commands. The
smart lock also includes a range of security features, such as two-factor authentication and
activity alerts, to ensure that the user‟s home is secure. The lock also allows users to provide
temporary access to guests or service providers through the August app, making it easy to grant
and revoke access as needed.
RESULT:
Page | 78