ES&IOT Labmanual - Merged - Removed
ES&IOT Labmanual - Merged - Removed
SEMESTER :
AGNI COLLEGE OF TECHNOLOGY
(Approved by AICTE& Affiliated to Anna University)
Old Mahabalipuram Road, Thalambur, Chennai – 600 130
BONAFIDE CERTIFICATE
Register Number :
INDEX
S.NO NAME OF THE DATE PAGE SIGNATURE
EXPERIMENT NO
4
Ex.No:1 Program for Complement Operation
Date:
Components Required:
• Keil software
• PC
Algorithm:
❖ Initialize input ports
PROGRAM
ORG 0000H
MOV A, 00H
CPL A
JMP XX
END
OUTPUT
Result: Thus, the program to Complement 8 bit number was successfully verified.
5
Ex.No:2 Data Transfer using assembly language
Date:
Components Required:
• Keil software
• PC
Algorithm:
❖ Initialize input ports
PROGRAM
ORG 000H
MOV@R1, A
INC R0
INC R1
END
OUTPUT:
Result: Thus the program using store average of n – bytes was executed
successfully and output is verified.
6
Ex.No:3 ALU operation using assembly Language
Date:
Components Required:
• Keil software
• PC
Algorithm:
❖ Initialize Ports P0 and P1 as input ports.
PROGRAM
Mov a,#25h
Mov b,#12h
Add a,b
Mov 40h,a
Mov a,#25h
Sub a,b
Mov 41h,a
Mov a,#25h
Mul a, b
Mov 42h,a
Mov 43h,b
7
Mov a,#25h
Mov b,#12h
Div ab
Mov 44h,a
Mov 45h,b
Mov a,#25h
Inc a
Mov 46h,a
Dec a
Mov 47h,a
end
OUTPUT:
Components Required:
• Keil software
• PC
Algorithm:
❖ Initialize Ports P0 and P1 as input ports.
Program:
MOV R1,#50H
MOV A,#00H
MOV B,#05H
L1:ADD A,@R1
INC R1
DJNZ R0,L1
DIV AB
MOV @RO,A
END
Output:
10
Result: Thus the program using program to store Average of n – bytes was
executed successfully verified.
11
Ex.No:5 Arithmetic operation using embedded C
Date:
Components Required:
• Keil software
• PC
Algorithm:
❖ Initialize Ports P0 and P1 as input ports.
Program:
#include<reg.51.h>
Void main(void)
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;
12
While(1);
Program:
#include<reg.51.h>
Void main(void)
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 8-bit arithmetic addition, subtraction, multiplication
and division was executed successfully verified.
13
Ex.No:6 LED Blinking using Arduino
DATE:
Hardware Requirements:
Software Requirements:
Arduino IDE
Algorithm
PROGRAM:
15
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, Gndand
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.
16
Program:
Import time
GPIO.Setmode(GPIO.Board)
GPIO.Setup(8,GPIO>IN)
While true
If GPIO.input(8)==0:
Time.sleep(0.1)
else
17
time.sleep(0.1)
Output:
18
Ex.No:8 Bluetooth Interfacing Arduino
DATE:
Components Required :
• Arduino Uno
• 1 HC05 module
• Arduino IDE
• Connection cable
• LED (already built into the Arduino board)
It start with the hardware part. Using jumper cables, connect the HC05 module to the
19
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
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
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:
20
CONNECTIONS:
Program:
Void loop ()
BT_data=BTserial.Readstring();
Serial.login(BT_data);
If(serial. Available ( ))
BTserial.printin(Arduino_data);
21
Ex.No: 9 LED Blinking using Raspberry pi
DATE:
Components Required:
CIRCUITCONNECTIONS
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.
PROGRAM:
Turn LED on for 2 seconds and off for 1 second, loop forever. Code is given below
Import RPI.GPIO
Import time
Defmain():
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD) #to use Raspberry pi board pin numbers
GPIO.setup(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()
22
Result: Thus the program for 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 Logstash 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 Logit.
To configure the Logstash 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 ThingSpeak
For creating the channel on ThingSpeak first need to sign up on ThingSpeak. In case
if already have an account on ThingSpeak 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.
Afterthisclick on save channel button to save the details.
Step 3: Getting API Key in ThingSpeak
To send data to ThingSpeak, we need an unique API key, which we will use later in our
python code to upload our CPU data to ThingSpeak 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 runsproperly 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 ThingSpeak site for Data Logging
After completing these steps open the channel and will see the CPU temperature data
is updating into ThingSpeak website.
36
It can send any sensor data connected with Raspberry pi to the ThingSpeak Cloud. Then
to connect LM35 temperature sensor with Raspberry Pi and send the temperature data
to ThingSpeak, which can be monitored from anywhere.
Program:
import httplib
import urllib
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 = 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()
except:
print "connection failed"
break
if name == " main ":
while True:
thermometer()
Result: Thus the log data using raspberry pi and upload the cloud platform was
verified successfully.
37