0% found this document useful (0 votes)
13 views37 pages

Es&Iot Manual

The document is a laboratory record for the CS3691 Embedded Systems and IoT course at Agni College of Technology, detailing the course outcomes and a series of experiments conducted in the lab. It includes a bonafide certificate for students, a list of experiments with aims, required components, algorithms, and sample programs for tasks such as LED blinking, data transfer using assembly language, and interfacing with various sensors. The document serves as a comprehensive guide for students completing their lab exercises during the academic year 2023-2024.

Uploaded by

21it30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views37 pages

Es&Iot Manual

The document is a laboratory record for the CS3691 Embedded Systems and IoT course at Agni College of Technology, detailing the course outcomes and a series of experiments conducted in the lab. It includes a bonafide certificate for students, a list of experiments with aims, required components, algorithms, and sample programs for tasks such as LED blinking, data transfer using assembly language, and interfacing with various sensors. The document serves as a comprehensive guide for students completing their lab exercises during the academic year 2023-2024.

Uploaded by

21it30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 37

AGNI COLLEGE OF TECHNOLOGY CHENNAI – 600097

LABORATORY RECORD
For

CS3691 EMBEDDED SYSTEMS AND IOT


LABORATORY
Of

B.TECH (INFORMATION TECHNOLOGY )

(Anna University Regulation 2021)

For the Batch (2021 to 2025)

Semester: V

ACADEMIC YEAR: 2023-2024

1
BONAFIDE CERTIFICATE

This is to certify that, _______________ roll number/ register number (


) of Third year (Fifth Semester) B. Tech Information Technology has successfully
completed all the lab exercises in CS3691 EMBEDDED SYSTEMS AND IOT
Laboratory for the academic year 2023-2024 in the fifth semester.

Faculty In-Charge HOD

Internal Examiner External Examiner

2
COURSE OUTCOMES

Upon completion of this course, the student will be able to:

CO NO DESCRIPTION OF COURSE
OUTCOME

CO 1 Explain the architecture of embedded


processors.
CO 2 Write embedded C program.

CO 3 Design simple embedded application.

CO 4 Compare the communication models in


IOT.
CO 5 Design IOT application using
Arduino/Raspberry Pi/open platform.

3
CS3691 EMBEDDED SYSTEMS AND IOT LABORATORY

INDEX
S.NO NAME OF THE PAGE DATE SIGNATURE
EXPERIMENT NO

1 Addition of two numbers using


assembly language

2 Data Transfer using assembly


language

3 ALU operation using assembly


language

4 Average of n – bytes stored in


assembly language

5 Arithmetic operations using


embedded C

6 LED Blinking using Arduino

7 Interfacing IR Sensor Using


Raspberry pi

8 Bluetooth interfacing Arduino.

9 LED Blinking using Raspberry


pi

10 Message transfer using Arduino


and raspberry pi

11 Setup a cloud platform to log the


data
12 Log Data using Raspberry PI
and upload to the cloud platform

4
Ex.No:1 Addition of two Numbers using assembly language
Date:

Aim: To write an assemble language program to add two numbers

Components Required:
 TASM Software
 PC

Algorithm:
 Initialize Ports P0 and P1 as input ports.

 Initialize Ports P2 and P3 as output ports.

 Initialize the R1 register.

 Move the contents from Port 0 to B register.

 Move the contents from Port 1 to A register.

 Add contents in A and B.

 If carry is present increment R1.

 Move contents in R1 to Port 2.

 Move the sum in step 6 to Port 3.

PROGRAM

ORG 0000H

MOV A, 00H

XX: MOV P1,A

CPL A

JMP XX

END

OUTPUT

Result: Thus, the program was successfully verified.

5
Ex.No:2 Data Transfer using assembly language
Date:

Aim: To write an assemble language program to Data Transfer using assembly


language.
Components Required:
 Keil software
 PC

Algorithm:
 Initialize Ports P0 and P1 as input ports

 Initialize Ports P2 and P3 as output ports

 Initialize the R1 register.

 Move the contents from Port 0 to B register

 Move the contents from Port 1 to A register

 Add contents in A and B.

 If carry is present increment R1.

 Move contents in R1 to Port 2.

 Move the sum in step 6 to Port 3.

PROGRAM

MOV R0, #30H

MOV R1, #50H

MOV R3, #05H

Back: MOV A, @R0

MOV@R1, A

INC R0

INC R1

DJNZ R3, BACK

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:

Aim: To write an assemble language program to addition, subtraction, multiplication,


division, of two numbers.
Components Required:
 Keil software
 PC

Algorithm:
 Initialize Ports P0 and P1 as input ports.

 Initialize Ports P2 and P3 as output ports.

 Initialize the R1 register.

 Move the contents from Port 0 to B register.

 Move the contents from Port 1 to A register.

 Add contents in A and B.

 If carry is present increment R1.

 Move contents in R1 to Port 2.

 Move the sum in step 6 to Port 3.

PROGRAM

ADD: ORG 00H

SJMP START

ORG 30H

START:

MOV A, #30H

MOV R0, #0P0H

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:

Aim: To write an assemble language program to addition, subtraction, multiplication,


division, of two numbers.
Components Required:
 Keil software
 PC

Algorithm:
 Initialize Ports P0 and P1 as input ports.

 Initialize Ports P2 and P3 as output ports.

 Initialize the R1 register.

 Move the contents from Port 0 to B register.

 Move the contents from Port 1 to A register.

 Store the contents to output port

Program:

MOV RO, #DSH

MOV R1, #SOH

MOV B, #05H

L1: ADD A,@R1

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:

Aim: To write an assemble language program using 8-bit arithmetic addition,


subtraction, multiplication and division.
Components Required:
 Keil software
 PC

Algorithm:
 Initialize Ports P0 and P1 as input ports.

 Initialize Ports P2 and P3 as output ports.

 Initialize the R1 register.

 Move the contents from Port 0 to B register.

 Move the contents from Port 1 to A register.

 ADD contents in A and B.

 Move the sum in step 6 to port 3.

Program:

#include<reg.51.h>

Void main (void)

Unsigned char s,p,q;

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>

Void main (void)

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:

AIM: To write a program for LED Blinking using Arduino

Hardware Requirements

 Arduino UNO Board


 USB cable
 Breadboard
 LED

Software Requirements

Arduino IDE

Algorithm

Step 1: Start a new sketch in the Arduino IDE

Step 2: Set the pinMode for Pin 13

Step 3: Set Pin 13 HIGH

Step 4: Compile the code

Step 5: Upload the code to Arduino

PROGRAM:

To interface LED/Buzzer with platform/Arduino


Void setup()
{
Pin mode(13,output);
}
Void loop()
{
Digital write(13,High);
Delay(1000);
Digitalwrite(13,High);
Delay(1000);
}
Result: Thus the program was successfully verified.

14
Ex.No:7 Interfacing IR Sensor Using Raspberry pi
DATE:

Aim: To write a program for Interfacing IR Sensor Using Raspberry pi.

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.

Circuit Diagram and Explanation:


The circuit diagram for connecting Raspberry Pi with IR sensor is shown below.
As you can see the circuit diagram is very simple. We have directly powered the IR
module from the 5V and Ground Pin of Raspberry Pi. The output pin of the IR
module is connected to the GPIO14. We have also used two LED (Green and Red) to
indicate the status of the object. These two LEDs are connected to GPIO3 and GPIO2
respectively. Since the GPIO pins of Raspberry Pi are 3.3V, a current limiting resistor
is not mandatory. However if desired a resistor of value 470 ohms can be added
between the ground pin of LEDs and Raspberry Pi. The whole circuit is powered by a
5V mobile charger through the micro USB port of the Raspberry pi.

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.

Programming your Raspberry Pi:


It using Python Programming language for programming Raspberry Pi. There are
many ways to program your Raspberry Pi using the Python 3 IDE, since it is the most
used one. The complete Python program is given at the end of this lab

15
Program:

Import RPi. GPIO as GPIO

Import time

GPIO.Set mode (GPIO . Board)

GPIO.Set up(8,GPIO>IN)

While true

If GPIO. input (8)==0:

Print f (“IR sensor detect the object”);

Time.sleep(0.1)

else

print f (“IR sensor not detect the object”);

time. sleep (0.1)

16
Output:

IR sensor detect the object

IR sensor not detect the object

Result: Thus, the program was successfully verified.

17
Ex.No:8 Bluetooth Interfacing Arduino
DATE:

Aim: To Write a program for Bluetooth interfacing using arduino

Components Required :

 Arduino Uno

 1 HC05 module

 Some male to female jumper cables

 Arduino IDE

 Connection cable

 LED (already built into the Arduino board)

Pin out and Connections

It start with the hardware part. Using jumper cables , connect the HC05 module to the

Arduino board using the diagram below as reference:

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

the Arduino board.

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

module is blinking, then to the right track.

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

properly recognized by Arduino IDE.

Note: remove +5V HC05 connection from the board before uploading the code

then reconnect it after the upload.

When everything is correct, see the built-in LED is blinking.

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:

 LED on HC05 module is blinking

 LED on Arduino board is blinking

 Serial monitor shows a transmission message

Program:

Void loop ()

If(BT serial .available())

BT_ data=BT serial. Read string ();

Serial .login (BT_ data);

If ( serial . Available ( ))

Arduino _ data= serial. read string( );

BT serial . print in ( Arduino _data);

20
}

Result: Thus, the program was successfully verified.

21
Ex .No: 9 LED Blinking using Raspberry pi
DATE:

Aim: To write a program for LED Blinking using Raspberry Pi

Components Required:

 Raspberry Pi 3 setup with monitor and USB Mouse & Keyboard


 Solderless breadboard
 Jumper wires
 Resistor
 Red LED
 Multimeter

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

Import RPI . GPIO


Import time
Def main ():
GPIO . cleanup ()
GPIO . set mode(GPIO.BOARD) #to use Raspberry pi board pin numbers
GPIO . set up(11,GPIO.OUT) #set up GPIO output channel
While True:
GPIO. output(!!,GPIO.LOW) #set RPI board pin 11 low. Turn off LED.
time.sleep(1)
GPIO.output(11,GPIO,HIGH) #set RPI board pin 11 high. Turn on LED.
time.sleep(2)
Main()

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;
}

Hardware setup for Serial communication


There are 2 ways to connect your Raspberry Pi and Arduino for Serial
communication.

Serial via USB


Arduino, will use the USB port that use to upload code from computer (with the
Arduino IDE) to board. Here the USB connector will depend on version . For boards
like Arduino Uno and Mega, the connector will be different from Arduino Nano, and
from Arduino Zero.

Serial via GPIOs

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:

Aim: To Setup a cloud platform and log the data

Components Required:
 PC
 WIFI or internet

Algorithm:
Steps to Setup a cloud platform to log the data
Step 1 - Confirm Google Operations Logs

Step 2 - Export Logs To Google Pub/Sub

Step 3 - Create Google Pub/Sub

Step 4 - Create Service Account

Step 5 - Configuring Log stash

Step 6 - Check Log it. Io For Your Logs

Step 7 - Google Operations Logging Overview

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.

It will be then be prompted for:

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.

Step 3 - Create Google Pub/Sub:

On your topic, click the ellipsis to the right.

28
Enter a suitable subscription ID and make sure delivery type is set to pull.

Scroll to the bottom of the page and press create.

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.

Select create a new service account.

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.

Click into the newly created service account.

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.

Project_id=>The complete ID of project

topic=> name of topic

subscription=> name of the subscription

json _key_file=> json key file

Step 6 - Check Log it. IO For Your Logs

to view your data

Step 7 - Google Operations Logging Overview

Logit.io provides an alternative log management solution that also extends to


managing not only GCP logs but also AWS, Azure & hundreds of other log data
sources.

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.

After clicking on signup fill personal details.

33
After this verify the E-mail id and click on continue.

Step 2: Create a Channel for Your Data


Once Sign in after account verification, Create a new channel by clicking “New
Channel” button

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy