Es&Iot Manual
Es&Iot Manual
LABORATORY RECORD
For
Semester: V
1
BONAFIDE CERTIFICATE
2
COURSE OUTCOMES
CO NO DESCRIPTION OF COURSE
OUTCOME
3
CS3691 EMBEDDED SYSTEMS AND IOT LABORATORY
INDEX
S.NO NAME OF THE PAGE DATE SIGNATURE
EXPERIMENT NO
4
Ex.No:1 Addition of two Numbers using assembly language
Date:
Components Required:
TASM Software
PC
Algorithm:
Initialize Ports P0 and P1 as input ports.
PROGRAM
ORG 0000H
MOV A, 00H
CPL A
JMP XX
END
OUTPUT
5
Ex.No:2 Data Transfer using assembly language
Date:
Algorithm:
Initialize Ports P0 and P1 as input ports
PROGRAM
MOV@R1, A
INC R0
INC R1
END
6
OUTPUT:
Result: Thus the program using program of store average of n – bytes was executed
successfully and output is verified.
7
Ex.No:3 ALU operation using assembly Language
Date:
Algorithm:
Initialize Ports P0 and P1 as input ports.
PROGRAM
SJMP START
ORG 30H
START:
MOV A, #30H
ADD A, R0
Div:
Mov a, #25h
Mov b, #12h
Add a, b
Mov 40h, a
8
Mov a, #25h
Sub a, b
Mov 41h, a
Mov a, #25h
Mul a, b
Mov 42h, a
Mov 43h, b
Mov a, #25h
Mov b, #12h
Div a b
Mov 44h, a
Mov 45h, b
Mov a, #25h
Inc a
Mov 46h, a
Dec a
Mov 47h, a
end
OUTPUT:
Result: Thus the program using program to store Average of n – bytes was
executed successfully and output is verified.
9
Ex.No:4 Average of n-type stored in assembly language
Date:
Algorithm:
Initialize Ports P0 and P1 as input ports.
Program:
MOV B, #05H
INC R1
DJNZ R0, L1
DIV AB
MOV @RO, A
END
10
Output:
Result: Thus the program using program to store Average of n – bytes was
executed successfully and output is verified.
11
Ex.No:5 Arithmetic operation using embedded C
Date:
Algorithm:
Initialize Ports P0 and P1 as input ports.
Program:
#include<reg.51.h>
Unsigned int I;
P1=0*00;
P2=0*00;
S=0*03
P=0*02;
q=s+p;
P1=q;
I =s*p;
P2=I;
While (1);
12
Program:
#include<reg.51.h>
Unsigned char p, q, r;
Unsigned int s;
P1=0*00;
P2=0*00;
p=0*06;
q=0*02;
r=p-q;
P1=r;
s =p*q;
P2=s;
While (1);
Output:
Result: Thus the program using program to store Average of n – bytes was
executed successfully and output is verified.
13
Ex.No:6 LED Blinking using Arduino
DATE:
Hardware Requirements
Software Requirements
Arduino IDE
Algorithm
PROGRAM:
14
Ex.No:7 Interfacing IR Sensor Using Raspberry pi
DATE:
Components Required:
Raspberry Pi 4
IR sensor module
Breadboard
LED
Jumper wires
IR Sensor Module:
IR sensors (Infrared sensor) are modules which detect the presence of objects
before them. If the object is present it give 3.3V as output and if it is not present it
gives 0 volt. This is made possible by using a pair of IR pair (transmitter and
receiver), the transmitter (IR LED) will emit an IR ray which will get reflected if
there is a object present before it. This IR ray will be received back by the receiver
(Photodiode) and the output will be made high after amplified using an op-amp
link LM358 .The IR Sensor is shown above. Like all IR sensor it has three pins
which are 5V, Gnd and Out respectively. The module is powered by the 5V pin from
Raspberry Pi and the out pin is connected to GPIO14 of Raspberry Pi. The
potentiometer on top of the module can be used to adjust the range of the IR sensor.
Note: When connecting any sensor, make sure the ground of the sensor is connected
to ground of the MCU or MPU (here Raspberry Pi). Only then they will be able to
communicate.
15
Program:
Import time
GPIO.Set up(8,GPIO>IN)
While true
Time.sleep(0.1)
else
16
Output:
17
Ex.No:8 Bluetooth Interfacing Arduino
DATE:
Components Required :
Arduino Uno
1 HC05 module
Arduino IDE
Connection cable
It start with the hardware part. Using jumper cables , connect the HC05 module to the
18
This is the connection that works for me. However, I found some references that
mention that the +5V terminal in the HC05 module should be connected to a 5V pin on
Next, need to give power the Arduino board by connecting it to a laptop (using the
USB cable) or other external power supply. When it will see the LED on the HC05
Once it type the code , save the sketch and click compile. The code is very simple and
minimum, so there shouldn’t be any error at this stage. Next, click the upload button to
write the code to the Arduino board. If there is an error, usually it’s because of
improper connection between the board and laptop. Please ensure that the board is
Note: remove +5V HC05 connection from the board before uploading the code
19
The First Bluetooth Data Transmission
At this point, the board is already transmitting data via the Bluetooth module.
However, for the time being, there is no other Bluetooth device paired and connected
to the Arduino board to receive the data that we transmit. So the only way is to make
sure that the board is transmitting is by looking at the serial monitor on Arduino IDE.
Open the serial monitor in Arduino IDE, then adjust the baud rate to 9600 baud (the
same baud rate we specify in the code). If everything is correct, to the screen:
CONNECTIONS:
Program:
Void loop ()
If ( serial . Available ( ))
20
}
21
Ex .No: 9 LED Blinking using Raspberry pi
DATE:
Components Required:
CIRCUIT CONNECTIONS
The first step to design a simple led circuit. Then it will make the LED circuit
controllable from the Raspberry Pi by connecting the circuit to the general purpose
input/output (GPIO) pins on the Raspberry Pi.
A simple LED circuit consists of a LED and resistor. The resistor is used to limit the
current that is being drawn and is called a current limiting resistor. Without the
resistor the LED would run at too high of a voltage, resulting in too much current
being drawn which in turn would instantly burn the LED, and likely also the GPIO
port on the Raspberry Pi.
When hooking up the circuit note the polarity of the LED. It notice that the LED has
a long and short lead. The long lead is the positive side also called the anode, the short
lead is the negative side called the cathode. The long should be connected to the
resistor and the short lead should be connected to ground via the blue jumper wire and
pin 6 on the Raspberry Pi as shown on the diagram.
To find the pin number refer to this diagram showing the physical pin numbers on the
Raspberry Pi.
22
PROGRAM:
Turn LED on for 2 seconds and off for 1 second, loop forever. Code is given below
Result: Thus the program LED Blinking using Raspberry Pi was successfully
verified.
23
Ex.No:10 Message transfer using Arduino and raspberry pi
DATE:
Aim : To write a program for Message transfer using Arduino and raspberry pi
Components Required
Arduino IDE Software
Arduino Board
Raspberry pi board
USB Cable
Program :
import serial
import time
ser=serial.serial(‘/dur//tty ACMO’,11500,time out=1.0)
time.sleep(3)
ser.reset_input_buffer()
printf(“serial OK”)
ser.close(
void setup(){
serial.begin(115200);
}
Void loop(){
//put your main code here, to run repeatedly;
}
To make a Serial connection it can also use plain wires between the Raspberry Pi
GPIOs and the Arduino pins.
24
Depending on your Arduino board might need to use a voltage level-shifter. The
Raspberry Pi is operating at 3.3V. For Arduino boards like Due, 101, it will be fine
because it use 3.3V.
But, for many Arduino, such as Uno, Mega, Leonardo, Nano, and many more, the
board is operating at 5V. it need a 3.3V/5V level-shifter to protect the Raspberry
Pi when connecting RX and TX (more info on Raspberry Pi pins and Arduino Uno
pins). For the rest of the use setup with the USB cable.
Output:
Serial OK
Result: Thus the program for Message transfer using Arduino and raspberry pi was
successfully verified .
25
Ex.No:11 SETUP A CLOUD PLATFORM TO LOG THE DATA
DATE:
Components Required:
PC
WIFI or internet
Algorithm:
Steps to Setup a cloud platform to log the data
Step 1 - Confirm Google Operations Logs
PROCEDURE:
Step 1 - Confirm Google Operations Logs: First, confirm the logs are located in
project by visiting the Logs Viewer section on Google Cloud Platform.
26
Step 2 - Export Logs To Google Pub/Sub
Located the logs to export, choose the option to CREATE SINK. It will be prompted
with the following options. Choose the Cloud Pub Sub topic option.
Sink name
Sink Service (choose Pub/Sub)
Sink Destination (choose create new Cloud Pub/Sub topic)
27
Once entered these details choose create sink. This will ensure that the logs you have
specified are directed to the Pub/Sub sink.
28
Enter a suitable subscription ID and make sure delivery type is set to pull.
29
Step 4 - Create Service Account
Visit service accounts and choose the project then to add the service account to. This
will be used to retrieve logs from the Google Pub Sub and send to Log stash.
Give the service account a name and add the relevant Pub/Sub permissions for the
service account.
Now we need to create a key for the service account, this will be used by Log stash to
access the service account in order to retrieve logs.
30
Choose the option to add a key and then select create a key option, remember to
download the service key as json when prompted.
31
Step 5 - Configuring Logstash
To start pulling Logs from the Google Cloud Platform pub/sub to your Stack a Log it.
To configure the Log stash input for you. To share the following details securely over
intercom using the button below.
The Logit.io platform makes correlating the performance of your Google operations
logs easy.
Result: Thus the data to Setup a cloud platform was verified successfully.
32
Ex.No:12 LOG DATA USING RASPBERRY PI AND UPLOAD THE
CLOUD PLATFORM
DATE:
Aim: To log the data using raspberry pi and upload the cloud platform
Components Required:
1. Raspberry Pi
2. Power Cable
3. WiFi or Internet
Algorithm:
Steps to log data using Raspberry pi and upload the cloud platform
Step 1 - Signup for Thing Speak
Step 2 - Create a Channel for Your Data
Step 3 - Getting API Key in Thing Speak
Step 4 - Python Code for Raspberry Pi
Step 5 - Check Thing Speak site for Data Logging
Steps for building Raspberry Pi Data Logger on Cloud
Step 1: Signup for Thing Speak
For creating the channel on Thing Speak first need to sign up on Thing Speak. In case
if already have an account on Thing Speak just sign in using your id and password.
33
After this verify the E-mail id and click on continue.
After clicking on “New Channel”, enter the Name and Description of the data then to
upload on this channel. Now enter the name of data (like Temperature or pressure) in
Field1.Enter the name and description of your data.
After this click on save channel button to save the details.
Step 3: Getting API Key in Thing Speak
To send data to Thing Speak, we need an unique API key, which we will use later in
our python code to upload our CPU data to Thing Speak Website.
Click on “API Keys” button to get your unique API key for uploading your CPU data.
34
Now copy and “Write API Key”. It will use this API key in our code.
Step 4: Python Code for Raspberry Pi
Complete code is given at the end of this tutorial, just make a file with any name
and .py extension and copy-paste the code and save the file. Must to replace the API
key with yours. It can run the python file any time using below command:
Python/path/filename.py
Sudo apt-get install python
Case 1: To give the code.
Now install all libraries:
sudo apt-get install httplib
sudo apt-get install urllib
After installing libraries run code (python /path/filename.py)
If the code runs properly will see some CPU temperature values as shown in below
image.
35
If there are any errors uploading the data, will receive “connection failed” message.
Step 5: Check Thing Speak site for Data Logging
After completing these steps open the channel and will see the CPU temperature data
is updating into Thing Speak website.
36
It can send any sensor data connected with Raspberry pi to the Thing Speak Cloud.
Then to connect LM35 temperature sensor with Raspberry Pi and send the
temperature data to Thing Speak, which can be monitored from anywhere.
Program:
import http lib
import url lib
import time
key = "ABCD" # 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 = url lib. Urlen code({'field1': temp, 'key': key })
headers = {"Content-typZZe": "application/x-www-form- urlencoded","Accept":
"text/plain"}
conn = http lib . HTTP Connection ("api.thingspeak.com:80")
try:
conn .request ("POST", "/update", params, headers)
response = conn. Get response()
print temp
print response. status, response .reason
data = response .read()
conn. close()
except :
print "connection failed"
break
if __name__ == "__main__":
while True:
thermometer()
Result: To log data using raspberry pi and upload the cloud platform was verified
successfully.
37