Esiot Lab Manual (All Experiments)
Esiot Lab Manual (All Experiments)
LABORATORY MANUAL
NAME :
REGISTER NUMBER :
YEAR/SEMESTER :
BRANCH :
Prepared By: G.Vijaykumar M.E (Ph.D)., AP/BME
ABOUT OBSERVATION NOTES & PREPARATION OF RECORD
❖ This Observation contains the basic diagrams of the circuits enlisted in the syllabus of the
CS3691 EMBEDDED SYSTEMS AND IOT course, along with the design of various
components of the circuit and controller.
❖ The aim of the experiment is also given at the beginning of each experiment. Once the student
can design the circuit as per the circuit diagram, he/she is supposed to go through the instructions
carefully and do the experiments step by step.
❖ They should note down the readings (observations) and tabulate them as specified.
❖ It is also expected that the students prepare the theory relevant to the experiment referring to
prescribed reference books/journals in advance, and carry out the experiment after understanding
thoroughly the concept and procedure of the experiment.
❖ They should get their observations verified and signed by the staff within two days and prepare &
submit the record of the experiment when they come to the laboratory in the subsequent week.
❖ The record should contain experiment No., Date,Aim, Apparatus required, Theory, Procedure,
and result on one side(i.e., Right-hand side, where rulings are provided) and Circuit diagram,
Design, Model Graphs, Tabulations, and Calculations on the other side (i.e., Left-hand side,
where no rulings are provided)
❖ All the diagrams and table lines should be drawn in pencil
❖ The students are directed to discuss & clarify their doubts with the staff members as and when
required. They are also directed to follow strictly the guidelines specified.
CS3691 EMBEDDED SYSTEMS AND IOT
SYLLABUS
COURSE OBJECTIVES:
LIST OF EXPERIMENTS
OUTCOMES:
REGISTER NO.
Certified that this is the bonafide record of work done by Mr/Ms …………………….
Aim:
SOFTWARE REQUIRED:
Theory:
Let N = 06
Result:
Result:
Result:
Result:
Thus the 8051 assembly language experiments using Keil IDE was
executed and simulation results were verified.
EXP. NO: 02 DATE:
Aim:
To write 8051 assembly language program to test data transfer between register
and memory
SOFTWARE REQUIRED:
Theory:
Thus the 8051 Assembly Language Programs to test the data transfer
between memory and Registers were executed successfully.
EXP. NO: 03 DATE:
Aim:
SOFTWARE REQUIRED:
Theory:
/program to add 16bit numbers and storing the result in 40h and 41h location
// 1173
/// +2493
/// --------
// 3606
org 00h
mov a, #73h
mov r0, #93h
add a, r0
mov 41h,a
mov a, #11h
mov r0, #24h
add a, r0
mov 40h,a
end
Result:
Before Execution:
After Execution:
c. Write an assembly language program to perform the multiplication of
two 16-bit numbers.
Result:
Output:
void setup() {
// Initialize serial communication for debugging (optional)
Serial.begin(57600);
}
void loop() {
// Define two variables to hold the numbers
int num1 = 10;
int num2 = 20;
// Do nothing for a short period to avoid spamming the Serial Monitor (optional)
delay(5000);
}
Output:
void setup() {
// Initialize serial communication for debugging (optional)
Serial.begin(9600);
}
void loop() {
// Define three variables to hold the numbers
int num1 = 10;
int num2 = 20;
int num3 = 30;
// Do nothing for a short period to avoid spamming the Serial Monitor (optional)
delay(5000);
}
Output:
Program to Find the Maximum of Two Numbers:
void setup() {
// Initialize serial communication for debugging (optional)
Serial.begin(57600);
}
void loop() {
// Define two variables to hold the numbers
int num1 = 10;
int num2 = 20;
// Do nothing for a short period to avoid spamming the Serial Monitor (optional)
delay(5000);
}
Output:
Pre-lab questions
Thus the embedded C programs to perform basic and arithmetic Programs are verified.
EXP.NO: 05 DATE:
Aim:
To study the Arduino platform and write the Arduino program to blink
the LED.
COMPONENTS NEEDED:
1. Arduino UNO development board
2. LED
3. 220Ω resistor
4. Arduino to PC power cable
5. Breadboard
6. Connecting wires
Theory:
TECHNICAL SPECIFICATIONS OF ARDUINO UNO:
Microcontroller - ATmega328
Operating Voltage - 5V
Supply Voltage (recommended) - 7-12V
Maximum supply voltage (not recommended) - 20V
Digital I/O Pins - 14(of which 6 provide PWM o/p)
Analog Input Pins – 6
DC Current per I/O Pin - 40 mA
DC Current for 3.3V Pin - 50 mA
Flash Memory - 32 KB (ATmega328) of which 0.5KB Used by Bootloader
SRAM - 2 KB (ATmega328)
EEPROM - 1 KB (ATmega328)
Clock Speed - 16 MHz
Component Explanations:
Analog input pins – pins (A0-A5) that take-in analog values to be
converted to be represented with a number range 0-1023 through an
Analog to Digital Converter (ADC).
ATmega328 chip – 8-bit microcontroller that processes the sketch you
programmed.
Built-in LED – an on board LED to pin 13.
Crystal Oscillator – clock that has a frequency of 16MHz
DC Jack – where the power source (AC-to-DC adapter or battery)
should be connected. It is limited to input values between 6-20V but
recommended to be around 7-12V.
Digital I/O pins – input and output pins (0-13) of which 6 of them (3, 5,
6, 9, 10 and 11) also provide PWM (Pulse Width Modulated) output by
using the analogWrite() function. Pins (0 (RX) and 1 (TX)) are also used
to transmit and receive serial data.
ICSP Header – pins for “In-Circuit Serial Programming” which is
another method of programming.
ON indicator – LED that lights up when the board is connected to a
power source.
Power Pins – pins that can be used to supply a circuit with values VIN
(voltage from DC Jack), 3.3V and 5V.
Reset Button – A button that is pressed whenever you need to restart the
sketch programmed in the board.
USB port – allows the user to connect with a USB cable the board to a
PC to upload sketches or provide a voltage supply to the board. This is
also used for serial communication through the serial monitor from the
Arduino software.
Integrated Development Environment (IDE):
Once the board is installed, it’s time to open the Arduino IDE.
CONNECTION DIAGRAM:
PROCEDURE:
1. Arduino development board is connected to PC through USB cable
2. Open “Arduino” icon from the computer desktop
3. Select tools menu to choose Arduino board type
4. Select tools menu to choose Arduino board COM port
5. Select file menu to choose new and type program
6. Click Verify icon to once compilation done to upload the program to Arduino
controller by clicking Upload icon
7. The circuit connections were given as shown in connection diagram.
8. When the given LED glows with a respective time delay.
Result:
Thus the study of the Arduino platform and the Arduino program to blink
LED has been studied and verified successfully.
the serial monitor to the Zigbee module.
OUTPUT:
#include <SoftwareSerial.h>
void setup() {
Serial.begin(9600);
gsm.begin(9600);
delay(2000);
gsm.println("AT+CMGF=1"); // Set SMS mode to text
delay(1000);
gsm.println("AT+CMGS=\"+1234567890\""); // Replace with desired phone number
delay(1000);
gsm.println("Hello from Arduino!"); // Replace with desired message
delay(1000);
gsm.println((char)26); // Send Ctrl+Z to end the message
}
void loop() {
// Empty loop
}
Procedure
This program uses SoftwareSerial to establish communication between an Arduino and a GSM module. It
sends an SMS message containing a predefined message to a specified phone number.
OUTPUT:
Bluetooth Communication:
#include <SoftwareSerial.h>
void setup() {
Serial.begin(9600);
bluetooth.begin(9600);
}
void loop() {
if (bluetooth.available()) {
char receivedData = bluetooth.read();
Serial.print("Received data: ");
Serial.println(receivedData);
}
if (Serial.available()) {
char sendData = Serial.read();
bluetooth.print(sendData);
}
}
Procedure
This program establishes communication between an Arduino and a Bluetooth module using
SoftwareSerial. It reads data from the Bluetooth module and prints it to the serial monitor, and it also allows
data to be sent from the serial monitor to the Bluetooth module.
Make sure to adjust the pins used for SoftwareSerial communication and modify the specific settings based
on your IoT devices' requirements. Additionally, ensure that you have the necessary libraries installed for
Zigbee, GSM, or Bluetooth communication.
OUTPUT:
Pre-lab questions:
1. What is the purpose of using Zigbee, GSM, and Bluetooth modules in Arduino projects?
2. How can you establish communication between an Arduino and a Zigbee module?
3. Which library is commonly used for Zigbee communication in Arduino programs? How do you use it?
4. How can you send and receive data between an Arduino and a Zigbee module?
5. Can you explain the process of establishing GSM communication with an Arduino?
1. What are the AT commands used for GSM communication in Arduino programs?
2. How can you send an SMS message using an Arduino and a GSM module?
3. Which library is commonly used for GSM communication in Arduino programs? How do you use it?
4. How do you establish Bluetooth communication between an Arduino and a Bluetooth module?
5. What are the key functions used for Bluetooth communication in Arduino programs?
Result:
Thus the Arduino programs to communicate with IoT devices (Zigbee, GSM, Bluetooth) are written and
verified for its execution
EXP.NO: 07 DATE:
Aim:
Components Required:
1. Raspberry Pi kit
2. HDMI to VGA cable
3. MicroSD card with Raspbian image loaded on it
4. Mouse and Keyboard
5. MicroUSB power supply
6. Bred board
7. LED
8. Jumper wire
9. Raspberry Pi IDE Platform
Circuit Connection:
Theory: Introduction to Raspberry PI
Procedure:
Step 1: On the desktop, go the Start Menu and choose for the PYTHON 3, as
shown in figure below
Step 2: After that, PYTHON will run and you will see a window as shown in
below figure.
Step 3: After that, click on New File in File Menu, you will see a new window
Open
Step 7: After that write the program for blinky as given below and execute the
program by clicking on “RUN” on “DEBUG” option.
Step 6: Verify the LED blinking status with the respective time delay given by
the program
Program:
import Rpi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40.GPIO.OUT)
While True:
GPIO.output(40,True)
time.sleep(1)
GPIO.output(40,False)
time.sleep(1)
OUTPUT:
LED ON
LED OFF
Result:
Thus the development of Raspberry Pi platform and Python programming to
implement LED blinking applications was executed successfully and the output
was verified.
EXP.NO: 08 DATE:
Aim:
Components Required:
1. Raspberry Pi kit
2. IR Sensor or LDR Sensor or Touch Sensor
3. HDMI to VGA cable
4. Mouse and Keyboard
5. MicroUSB power supply
6. Bred board
7. LED (red & green)
8. Jumper wire
9. Raspberry Pi IDE Platform
Circuit Connection:
Theory: IR Sensor Module
IR (Infrared) Sensor IR (Infrared) Sensor works by emitting infrared
signal/radiation and receiving of the signal when the signal bounces back from
any obstacle. In other words, the IR Sensor works by continuously sending
signal (in a direction) and continuously receive signal, if comes back by
bouncing on any obstacle in the way.
Components:
IR Sensor Emitter: This component continuously emits the infrared signal
Receiver: It waits for the signal which is bounced back by obstacle
Indicator: On board LED to signal if obstacle is deducted by the sensor
Output: Could be used as Input for further processing of the signal
Ground: Ground/Negative point of the circuit
Voltage: Input 3.3V In this tutorial we will learn how we can Interface an IR
sensor with Raspberry pi.
These sensors are most commonly use in small robots like line follower robot,
Edge avoiding robot etc.. Simply putting, it can detect the presence of objects
before it and also differentiate between white and black colour. So lets learn
how to interface this sensor with Raspberry Pi. In this experiment, when there is
no object in front of IR sensor then the Red LED remains turned on and soon as
we put something in front of IR sensor then red LED turns off and Green LED
turn on. This circuit can also serve as Security Alarm Circuit.
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 used in this
assignment is 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.
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.
PROGRAM:
import RPi.GPIO as IO
import time
IO.setwarnings(False)
IO.setmode(IO.BCM)
while 1:
Procedure:
Step 1: Connections are made as per the circuit diagram.
Step 2: On the desktop, go the Start Menu and choose for the PYTHON 3
Step 3: After that, PYTHON will run and you will see a programming window
Step 4: Click on New File in File Menu, you will see a new window
Step 5: After that write the program for IR sensor module and execute the
program by clicking on “RUN” on “DEBUG” option.
Step 6: Verify the LED’s blinking status with respect to the program.
Result:
Thus the interfacing sensor with Raspberry Pi platform was executed and the
output was verified successfully.
EXP.NO: 09 DATE:
Components Required:
1. Raspberry Pi kit
2. Arduino UNO Board
3. HC-05 Bluetooth Module
4. LED
5. Jumper Wires
Connection Diagram:
Theory:
Wireless communication is swiftly replacing the wired connection when it
comes to electronics and communication. Designed to replace cable connections
HC-05 uses serial communication to communicate with the electronics. Usually,
it is used to connect small devices like mobile phones using a short-range
wireless connection to exchange files. It uses the 2.45GHz frequency band. The
transfer rate of the data can vary up to 1Mbps and is in range of 10 meters.
The HC-05 module can be operated within 4-6V of power supply. It supports
baud rate of 9600, 19200, 38400, 57600, etc. Most importantly it can be
operated in Master-Slave mode which means it will neither send or receive data
from external sources.
Description of pins
Enable - This pin is used to set the Data Mode or and AT command mode (set
high).
VCC - This is connected to +5V power supply.
Ground - Connected to ground of powering system.
Tx (Transmitter) - This pin transmits the received data Serially.
Rx (Receiver) - Used for broadcasting data serially over bluetooth.
State -Used to check if the bluetooth is working properly.
Modes of Operation
The HC-05 Bluetooth Module can be used in two modes of operation:
Command Mode and Data Mode.
Command Mode
In Command Mode, you can communicate with the Bluetooth module through
AT Commands for configuring various settings and parameters of the Module
like get the firmware information, changing Baud Rate, changing module name,
it can be used to set it as master or slave.
Data Mode
Coming to the Data Mode, in this mode, the module is used for communicating
with other Bluetooth device i.e. data transfer happens in this mode.
Name: HC-05
Type: Slave
Mode: Data
Baud Rate: 9600 with 8 data bits, no parity and 1 stop bit
int led=13;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(led,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()){
int a=Serial.parseInt();
Serial.println(a);
if(a==100)
{
digitalWrite(led,HIGH);
}
if (a==200)
{
digitalWrite(led,LOW);
}
}
}
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:
Input from Raspberry Pi:
enter:100
Output from Arduino UNO:
100
LED ON
Input from Raspberry Pi:
enter:200
Output from Arduino UNO:
200
LED OFF
Procedure:
Step 1: Connections are made as per the circuit Diagram.
Step 2: Install ‘Pi Apps’ to the Raspbian environment.
Step 3: Click the ‘Pi Apps’ icon select the Arduino and Install the Arduino
IDE.
Step 4: Click the Rasbian icon and select the programming option then select
Arduino IDE and write the program, verify the code and upload.
Step 5: Click the Rasbian icon and select the programming option then select
Thonny Python IDE and write the Program.
Step 6: Execute the program by clicking on “RUN” on “DEBUG” option.
Step 7: Enter the respective command from Raspberry PI and verify the
corresponding output to Arduino Uno with LED ON/OFF.
Result:
Thus the communication between Arduino and Raspberry PI using HC-05
Bluetooth medium was executed and the output was verified successfully.
CS3691 EMBEDDED SYSTEMS AND IOT
EXP NO: 10
CLOUD PLATFORM TO LOG THE DATA
DATE
AIM:
To set up a cloud platform to log the data from IoT devices.
1 Blynk Platform 1
CLOUD PLATFORM-BLYNK:
Blynk is a smart platform that allows users to create their Internet of Things applications without the
need for coding or electronics knowledge. It is based on the idea of physical programming & provides
a platform to create and control devices where users can connect physical devices to the Internet and
control them using a mobile app.
Step 1: Visit blynk.cloud and create a Blynk account on the Blynk website. Or you can simply sign
in using the registered Email ID.
Step 3: Give any name to the Template such as Raspberry Pi Pico W. Select ‘Hardware Type’ as
Other and ‘Connection Type’ as WiFi.
Select the device from a template that you created earlier and also give any name to the device. Click
on Create.
A new device will be created. You will find the Blynk Authentication Token Here. Copy it as it is
necessary for the code.
CS3691 EMBEDDED SYSTEMS AND IOT
From the widget box drag a switch and place it on the dashboard screen.
CS3691 EMBEDDED SYSTEMS AND IOT
Step 6:
On the switch board click on Settings and here you need to set up the Switch. Give any title to it and
Create Datastream as Virtual Pin.
Configure the switch settings as per the image below and click on create.
CS3691 EMBEDDED SYSTEMS AND IOT
With this Blynk dashboard set up, you can now proceed to program the Raspberry Pi Pico W board
to control the LED.
Step 7:
CS3691 EMBEDDED SYSTEMS AND IOT
To control the LED with a mobile App or Mobile Dashboard, you also need to setup the Mobile
Phone Dashboard. The process is similarly explained above.
Install the Blynk app on your smartphone The Blynk app is available for iOS and Android. Download
and install the app on your smartphone. then need to set up both the Mobile App and the Mobile
Dashboard in order to control the LED with a mobile device. The process is explained above.
RESULT:
lOMoARcPSD|32279070
AIM:
To write a program how logs to Google Cloud Logging and how to check the logs in the Logs
Explorer.
SOFTWAREREQUIREMENTS:
Google cloud platform
PROCEDURE:
Step4: Click the name of the service account to open the settings. Then click “KEYS” => “ADD
KEY” => “Create new key” => “JSON” to create a key.
Step5:installiPython:
(base)$condacreate--namegcp_loggingpython=3.10
(base)$condaactivategcp_logging(gcp_logging)
$pipinstall-Ugoogle-cloud-logging(gcp_logging)
$pipinstallipython
Step7: the following query expressions will all find our log:
# Noequalsignor colon:
lOMoARcPSD|32279070
logName:"python"
Step8: use the log_struct method:
json_payload = {"message": "This is a warning from
'python_application_name'!"}
logger.log_struct(json_payload,severity=severity.WARNING)
PROGRAM:
*setup_logging*
importlogging
importgoogle.cloud.logging
client=google.cloud.logging.Client()
# Alternatively, but not recommended. It's helpfulwhen you can't set anenvironmentvariable.
service_key_path="/home/lynn/Downloads/temp-project-for-logging-ff33f97cf72f.json"client
= google.cloud.logging.Client.from_service_account_json(service_key_path)
client.setup_logging()
logging.warning("Thisisawarning!")
*built-inloggingmoduleandaddthehandlerstoaloggercreatefromit*
importlogging
importgoogle.cloud.logging
lOMoARcPSD|32279070
fromgoogle.cloud.logging.handlersimport CloudLoggingHandlerlog_name=
"python_application_name"
# Create a handler for Google Cloud Logging. gcloud_logging_client =
google.cloud.logging.Client()gcloud_logging_handler=CloudLoggingHandler(
gcloud_logging_client, name=log_name
)
#Createastreamhandlerto logmessagestotheconsole.stream_handler =
logging.StreamHandler() stream_handler.setLevel(logging.WARNING)
#Nowcreatealogger and addthehandlers:
logger = logging.getLogger(log_name) logger.setLevel(logging.DEBUG)
logger.addHandler(gcloud_logging_handler)logger.addHandler(stream_handler)
*GoogleLogging:*
In[1]:logger.info("ThisisDEBUG.")In[2]:logger.info("ThisisINFO.") In [3]: logger.warning("This
is WARNING.")# This is WARNING.
In[4]:logger.error("ThisisERROR.")#ThisisERROR.
OUTPUT:
All messages were sent to Google Logging, but only some are printed in the console.
RESULT:
lOMoARcPSD|32279070
To write a program to log data using Raspberry pi and upload to the cloud platform.
HARDWARE REQUIREMENTS:
RaspberryPi
Power Cable
SOFTWARE REQUIREMENTS:
Raspberry PI
Thing speak IOT platform
PROCEDURE:
Step 2: Create a Channel for Your Data. Once you Sign in after your account verification, Create a
new channel by clicking “New Channel” button.
Step 3: 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. After this, click on the save channel button to save your details.
Step 4: Getting API Key in Thing Speak. Click on “API Keys” button to get your unique API key
for uploading your CPU data.
Now copy your “Write API Key”. We will use this API key in our code.
lOMoARcPSD|32279070
Step 5: Python Code for Raspberry Pi. Run the python file anytime using the below command:
python /path/filename.py
Assuming you already installed python in Raspberry Pi using this command: sudo apt-get install
python
Step6: If you are using monitor screen then just use the given code. Now install all libraries:
sudoapt-getinstallhttplib
sudo apt-get install urllib
PROGRAM:
import httplib
import urllib
import time
def thermometer():
while True:
# Calculate CPU temperature of Raspberry Pi in degrees Celsius
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-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn = httplib.HTTPConnection("api.thingspeak.com:80")
try:
lOMoARcPSD|32279070
OUTPUT:
See the CPU temperature data is updating into Thing Speak website.
RESULT:
EXP.NO: 12 DATE:
COMPONENTS NEEDED:
1. Arduino board
2. Moisture sensor
3. Connecting wires
HARDWARE CONNECTIONS:
Moisture sensor To Arduino
Vcc --- 5v
GND --- GND
A0 --- A0 (Analog Pin of Arduino)
CONNECTION DIAGRAM:
PINOUT DIAGRAM:
Program:
void setup()
{
Serial.begin(9600);
pinMode(sensor_pin, INPUT);
}
void loop()
{
int sensor_data = analogRead(sensor_pin);
Serial.print("Sensor_data:");
Serial.print(sensor_data);
Serial.print("\t | ");
delay(100);
}
PROCEDURE:
1. Arduino development board is connected to PC through USB cable
2. Open “Arduino” icon from the computer desktop
3. Select tools menu, choose Arduino board type
4. Select tools menu, choose Arduino board COM port
5. Select file menu, choose new and type program
6. Click Verify icon, once compilation done to upload the program to Arduino controller by
clicking Upload icon
7. The circuit connections were given as shown in connection diagram.
8. Verify the sensor output.
Output:
RESULT:
Thus the design of Smart Agriculture for agro meteorological measurements has been
verified.