0% found this document useful (0 votes)
38 views34 pages

Es and Iot Lab Manual Own+Megatronics

Es and lot ppt

Uploaded by

anithakannan2209
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)
38 views34 pages

Es and Iot Lab Manual Own+Megatronics

Es and lot ppt

Uploaded by

anithakannan2209
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/ 34

SALEM COLLEGE

OF ENGINEERING AND TECHNOLOGY


(Approved by AICTE and Affiliated to ANNA University Chennai)
NH-68, Salem-Attur Main Road, Mettupatty, Perumapalayam, Selliamman Nagar,
Salem, Tamil Nadu 636111.

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING

CS3961/EMBEDDED SYSTEMS AND IoT LABAROTARY


(Anna University Regulation 2021)

PREPARED BY VERIFIED BY APPROVED BY


(S.DHILIBAN AP/ECE)

SYLLABUS

LIST OF EXPERIMENTS
1. Write 8051 Assembly Language experiments using simulator.

2. Test data transfer between registers and memory.

3. Perform ALU operations.

4. Write Basic and arithmetic Programs Using Embedded C.

5. Introduction to Arduino platform and programming

6. Explore different communication methods with IoT devices (Zigbee, GSM, Bluetooth)

7. Introduction to Raspberry PI platform and python programming

8. Interfacing sensors with Raspberry PI

9. Communicate between Arduino and Raspberry PI using any wireless medium

10. Setup a cloud platform to log the data

11. Log Data using Raspberry PI and upload to the cloud platform

12. Design an IOT based system

Exp.No:1 ASSEMBLY LANGUAGE PROGRAM USING EDSIM51 SIMULATOR

Date:

AIM:

To perform Assembly Language Program using Edsim51 Simulator.


SOFTWARE REQUIRED:

 Edsim51 Simulator
 Personal Computer

PROCEDURE:

Step 1: First start EDSIM51 software

Step 2: Type ALP program

Step 3: Save the program

Step 4: Run the program

PROGRAM:

a) ADDITION

ORG 0000H

MOV A,#20H

MOV B,#4BH

ADD A,B

MOV R0,A

END

b) SUBTRACTION

ORG 0000H

MOV A,#20H

MOV B,#10H

SUBB A,B

MOV R1,A

END

RESULT:

Thus the Assembly Language Program using Edsim51 Simulator was executed successfully.

Exp.No:2 DATA TRANSFER BETWEEN REGISTERS AND MEMORY

Date:

AIM:

To test data transfer between registers and memory.


SOFTWARE REQUIRED:

 Keil μvision 5(C51)


 Personal Computer

PROCEDURE:

Step 1: First start KEIL IDE software

Step 2: Go to new project

Step 3: Give name of the project(do not add any .asm or .c extension)

Step 4: Now save the project after that select your microcontroller,here I am using ATMEL 89C51

Step 5: Now go to file and select new file

Step 6: Now save this editor file in the same folder where u have saved your project

Step 7: Now write your program code here and save it.

Step 8: Now add this file (save it with extension .c) in the project i.e. in source group 1;

Step 9: Now right click on source group and click on build target.

Step 10: Now go to debug section and click on start/stop

Step 11: Now run the project and you will get output.

PROGRAM:

org 00

MOV R0,#20H

MOV R1,#40H
MOV R3,#10

UP: MOV A,@R0

MOV @R1,A

INC R0

INC R1

DJNZ R3,UP

END

INPUT:

 Type I:0X20 in memory1 window.


 Then double click and enter 10 number like 20h:10, 21h:20, 22h:30, 23h:40, 24h:50, 25h:60, 26h:70,
27h:80, 28h:90, 29h:95

OUTPUT:

 Type I:0X40 in memory1 window.


 Data transfer in 40h:10, 41h:20, 42h:30, 43h:40, 44h:50, 45h:60, 46h:70, 47h:80, 28h:90, 49h:95

RESULT:

Thus the testing of data transfer between registers and memory using Embedded C was executed
and verified successfully.

Exp.No:3 ALU OPERATIONS

Date:

AIM:

To Perform ALU operations.


SOFTWARE REQUIRED:

 Keil μvision 5(C51)


 Personal Computer

PROCEDURE:

Step 1: First start KEIL IDE software

Step 2: Go to new project

Step 3: Give name of the project(do not add any .asm or .c extension)

Step 4: Now save the project after that select your microcontroller,here I am using ATMEL 89C51

Step 5: Now go to file and select new file

Step 6: Now save this editor file in the same folder where u have saved your project

Step 7: Now write your program code here and save it.

Step 8: Now add this file (save it with extension .c) in the project i.e. in source group 1;

Step 9: Now right click on source group and click on build target.

Step 10: Now go to debug section and click on start/stop

Step 11: Now run the project and you will get output.

PROGRAM:

mov a,#45h //1st number 0100 0101

mov r0,#67h //2nd number 0110 0111

anl a,r0 //AND logic 0100 0101


mov 20h,a //saving and resultwith 20h memory

mov a,#45h

orl a,r0 //OR Logic 0110 0111

mov 21h,a

mov a,#45h

xrl a,r0 //XOR Logic 0010 0010

mov 22h,a

mov a,#45h

cpl a //NOT Logic 1011 1010

mov 23h,a

end

INPUT:

 Type I:0X20 in memory1 window.


 a=45h[0100 0101]
 b=67h[0110 0111]

OUTPUT:

20h:45, 21h:67, 22h:22, 23h:BA

RESULT:

Thus the ALU operations using Embedded C was executed and verified successfully.

Exp.No:4 BASIC AND ARITHMETIC PROGRAMS

Date:

AIM:

To write Basic and arithmetic programs using Embedded C.


SOFTWARE REQUIRED:

 Keil μvision 5(C51)


 Personal Computer

PROCEDURE:

Step 1: First start KEIL IDE software

Step 2: Go to new project

Step 3: Give name of the project(do not add any .asm or .c extension)

Step 4: Now save the project after that select your microcontroller,here I am using ATMEL 89C51

Step 5: Now go to file and select new file

Step 6: Now save this editor file in the same folder where u have saved your project

Step 7: Now write your program code here and save it.

Step 8: Now add this file (save it with extension .c) in the project i.e. in source group 1;

Step 9: Now right click on source group and click on build target.

Step 10: Now go to debug section and click on start/stop

Step 11: Now run the project and you will get output.

PROGRAM:

mov a,#25h

mov b,#12h

add a,b
mov 40h,a

mov a,#25h

subb a,b

mov 41h,a

mov a,#25h

mul ab

mov 42h,a

mov 43h,b

mov a,#25h

div ab

mov 44h,a

mov 45h,b

mov a,#25h

inc a

mov 46h,a

dec a

mov 47h,a

end

INPUT:

a=25h

b=12h
OUTPUT:

RESULT:

Thus the basic and arithmetic programs using Embedded C was executed and verified
successfully.

Exp.No:5 ARUDUINO PROGRAMMING

AIM:

To explore Arduino Uno Programming using Embedded C.


APPARTUS REQUIRED:

 Personal Computer
 Arduino Uno Software Version 1.8
 Arduino Uno Kit
 Usb To Printer Interface Cable

PROCEDURE :

Kindly download the Arduino software for the following link.

https://www.arduino.cc/en/software

Step 1 - Install Arduino Software

Step 2 – Select Tools and Boards

Step 3 – Select Tools and Port


PROGRAM:

unsigned int
_delay; char
data;
void setup()
{ pinMode(
3,
OUTPUT);
Serial.begin
(9600);
}
void loop()
{ if(Serial.
available()
)
{
data =
(int)Serial.read();
if((data != 10) &&
(data != 13))
{ _delay = data - 48;
} Serial.println(_delay*1000);
}

digitalWrit
e(3,
HIGH);
delay(_dela
y*1000);
digitalWrit
e(3, LOW);
delay(_dela
y*1000);
}

RESULT:
Thus the Arduino Uno Programming using Embedded C was explored

CONNECTION DIAGRAM:
Exp.No:6.A DIFFERENT COMMUNICATION METHODS WITH IOT
DEVICES- BLUETOOTH

AIM:

To explore different communication methods with IoT devices-Bluetooth using Embedded


C.

APPARTUS REQUIRED:

 Personal Computer
 Arduino Uno Software Version 1.8
 Arduino Uno Kit
 USB To Printer Interface Cable
 Bluetooth Module HC-05

THEORY:

HC-05 Bluetooth Module

HC-05 is a Bluetooth device used for wireless communication with Bluetooth enabled devices (like
smartphone).

It communicates with microcontrollers using serial communication (USART).


Default settings of HC-05 Bluetooth module can be changed using certain AT commands.

As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V level,
so, there is no need to shift TX voltage level of HC-05 module. But we need to shift the transmit
voltage level from microcontroller to RX of HC-05 module.

PROCEDURE:

 Send Message using Bluetooth HC-05 With Arduino.


 Here, we will transmit data from Smartphone via Bluetooth to the Arduino Uno and
display it on Serial Monitor of PC.
 Download and install a Bluetooth terminal application on your phone and use it to
connect to the HC-05 Bluetooth module.
 Data is sent from the Smartphone using the Bluetooth terminal application.
PROGRAM:
#include "SoftwareSerial.h"
SoftwareSerial mySerial(2, 3); //RX, TX
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
mySerial.begin(9600);
pinMode(13,OUTPUT);
}
void loop()
{
String str;;
if (mySerial.available()){
str = mySerial.readString();
Serial.println(str);
if((str[0] == 'o') && (str[1] == 'n'))
{
digitalWrite(13,HIGH);
}
if((str[0] == 'o') && (str[1] == 'f')&& (str[2] == 'f'))
{
digitalWrite(13,LOW);
}
}
if (Serial.available())
mySerial.write(Serial.read());
}

RESULT:
Thus the data send and received from Bluetooth module was explore
Exp.No:6.B DIFFERENT COMMUNICATION METHODS WITH IOT
DEVICES- GSM

AIM:

To explore different communication methods with IoT devices-GSM using Embedded C.

APPARTUS REQUIRED:

 Personal Computer
 Arduino Uno Software Version 1.8
 Arduino Uno Kit
 USB To Printer Interface Cable
 GSM Module

PROGRAM:

#include <SoftwareSerial.h>
SoftwareSerial Sim(2, 3);
void setup()
{
Sim.begin(9600); // Setting the baud rate of Sim Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
}
void loop()
{
if (Serial.available()>0)
{
switch(Serial.read()) // Read data given in Serial Monitor
{
case 's': // If data is 's', goto SendMessage() function
SendMessage();
break;
case 'r': // If data is 'r', goto ReceiveMessage() function
ReceiveMessage();
break;
}
}
if (Sim.available()>0)
{
Serial.write(Sim.read()); // If SIM module sendsmessages, print it to Serial monitor
}
}
void SendMessage()
{
Sim.println("AT+CMGF=1"); // Sets the Sim Module in send SMS mode
delay(1000); // Delay of 1 second
Sim.println("AT+CMGS=\"+916383917274\"\r"); // Replace x with mobile number
delay(1000); // Delay of 1 second
Sim.println("I am SMS from Sim Module"); // Type in the SMS text you want to send
delay(100); // Delay of 0.1 second
Sim.println((char)26); // ASCII code of CTRL+Z (to exit out)
delay(1000); // Delay of 1 second
}
void ReceiveMessage()
{
Sim.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000); // Delay of 1 second
}

RESULT:
Thus the data send and received from GSM module was explored.
CIRCUIT CONNECTION DIAGRAM:
Exp.No:7 INTRODUCTION TO RASPBERRY PI PLATFORM AND
PYTHON PROGRAMMING

AIM:

To explore Raspberry Pi Platform and Python Programming

APPARTUS REQUIRED:

 Personal Computer
 Raspberry Pi 3 Model B
 SD card

PROGRAM:

import sys
import RPi.GPIO as IO
import time
led_pin = 16 #36 board pin
IO.setwarnings(False)
IO.setmode(IO.BCM)
IO.setup(led_pin, IO.OUT)
while True:
IO.output(led_pin,True)
time.sleep(2)
IO.output(led_pin,False)
time.sleep(1)

RESULT:

Thus the Raspberry Pi Platform and Python Programming was explored


sussessfullty.
CIRCUIT DIAGRAM CONNECTION:
Exp.No:8 INTERFACING IR SENSOR WITH RASPBERRY PI (IR SENSOR )

AIM:

To Interface IR sensors with Raspberry PI

APPARTUS REQUIRED:

 Personal Computer
 Raspberry Pi 3 Model B
 IR Sensor
 5V Buzzer
 Mini Breadboard
 Connecting Wires
 Power Supply
 Computer

PROGRAM:
import RPi.GPIO as IO
import busio
import board
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
import time
buzzer_pin = 12 #32 buzzer IO.setwarnings(False)
IO.setmode(IO.BCM)
IO.setup(buzzer_pin, IO.OUT)
# Initialize the I2C interface
i2c = busio.I2C(board.SCL, board.SDA)
# Create an ADS1115 object ads = ADS.ADS1115(i2c)
# Define the analog input channel
channel = AnalogIn(ads, ADS.P0)
while True:
ir_value = int(channel.value)
print('IR_value',ir_value)
if(ir_value > 10000):
IO.output(buzzer_pin,True)
else:
IO.output(buzzer_pin,False)

time.sleep(1)

RESULT:
Thus the Interfacing IR sensors with Raspberry PI was constructed and object
detected successfully.
CIRCUIT CONNECTION:
Exp.No:9 COMMUNICATE BETWEEN ARDUINO AND RASPBERRY PI USING
ANY WIRELESS MEDIUM

AIM:

To Interface IR sensors with Raspberry PI

APPARATUS REQUIRED:

 Bluetooth Sensor
 Arduino uno
 Rasberrypi

PROGRAM:

# 00:22:04:00:EF:3E //**TERMINAL REFERENCE COMMAND


import serial
import time
btSerial = serial.Serial("/dev/rfcomm0", baudrate=9600, timeout=0.5)
print("Here")
while True:
msg = input("Enter:")
msg = msg.encode()
btSerial.write(msg)
print(btSerial.readline())
time.sleep(1)
**TERMINAL COMMAND
sudo bluetoothctl
power on
discoverable on
agent on
default-agent
scan on
pair xx:xx:xx:xx:xx:xx
Device xx:xx:xx:xx:xx:xx Connected: yes
Request PIN code
[agent] Enter PIN code: 1234 ENTER
exit
sudo rfcomm --raw connect 0 xx:xx:xx:xx:xx:xx 1

ARUDINO PROGRAM:
#include "SoftwareSerial.h"
SoftwareSerial mySerial(2, 3); //RX, TX
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
mySerial.begin(9600);
pinMode(13,OUTPUT);
}
void loop()
{
String str;;
if (mySerial.available()){
str = mySerial.readString();
Serial.println(str);
if(str == "on")
{
digitalWrite(13,HIGH);
}
if(str == "off")
{
digitalWrite(13,LOW);
}
}
if (Serial.available())
mySerial.write(Serial.read());
}

RESULT:
Thus the communication between arduino and raspberry pi using any wireless medium was
performed.
CONNECTION DIAGRAM:
Exp.No:10 SETUP A CLOUD PLATFORM TO LOG THE DATA

AIM:

To Setup a cloud platform to log the data.

APPARATUS REQUIRED:

 DHT11 Sensor
 Arduino uno
 Rasberrypi
 Node MCU WiFi module

PROGRAM:

#include "ThingSpeak.h"
#include <ESP8266WiFi.h>
#include "dht11.h"
#define DHT11PIN 5
//----------- Enter you Wi-Fi Details---------//
char ssid[] = "raspberry_pi"; //SSID
char pass[] = "123456789"; // Password
//-------------------------------------------//
WiFiClient client;
unsigned long myChannelNumber = 1831217; // Channel ID here
const int FieldNumber = 1;
const char * myWriteAPIKey = "P47FDNAYU6MRM9WH"; // Your Write API Key here
dht11 DHT11;
float temp;
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client);
}
void loop() {
if (WiFi.status() != WL_CONNECTED)
{
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED)
{
WiFi.begin(ssid, pass);
Serial.print(".");
delay(1000);
}
Serial.println("\nConnected.");
}
int chk = DHT11.read(DHT11PIN);
temp = (float)DHT11.temperature;
Serial.print("Temperature (C): ");
Serial.println(temp, 2);
ThingSpeak.writeField(myChannelNumber, FieldNumber, temp, myWriteAPIKey);
delay(1500);
}

RESULT:
Thus the cloud platform to log the data setup completed successfully.
CONNECTION DIAGRAM:
Exp.No:11 LOG DATA USING RASPBERRY PI AND UPLOAD TO THE CLOUD
PLATFORM

AIM:

To Log Data using Raspberry PI and upload to the cloud platform.

APPARATUS REQUIRED:

 LDR Sensor
 Arduino uno
 Rasberrypi
 PI ADC

PROGRAM:

import sys
import board
import time
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
import urllib.request
api_key = 'ZJKXZD7N27OSO0V5'
# Initialize the I2C interface
i2c = busio.I2C(board.SCL, board.SDA)
# Create an ADS1115 object
ads = ADS.ADS1115(i2c)
# Define the analog input channel
channel = AnalogIn(ads, ADS.P0)
# main() function
def main():
while True:
ldr_value = int(channel.value)
print("ldr Value: ", ldr_value)
baseURL = 'https://api.thingspeak.com/update?api_key=%s' % api_key
f = urllib.request.urlopen(baseURL+"&field1=%s" % (ldr_value))
print(f.read())
f.close()
time.sleep(15)
# call main
if __name__ == '__main__':
main()

RESULT:
Thus the Logging of Data using Raspberry PI and upload to the cloud platform was
successfully completed.
CONECTION DIAGRAM:
Exp.No:12 DESIGN AN IOT BASED SYSTEM

AIM:

To design an iot based system

APPARATUS REQUIRED:

 LDR Sensor
 Arduino uno
 Rasberrypi
 Node MCU

PROGRAM:

#include "ThingSpeak.h"
#include <ESP8266WiFi.h>
const int LDR_pin = A0;
//----------- Enter you Wi-Fi Details---------//
char ssid[] = "raspberry_pi"; //SSID
char pass[] = "123456789"; // Password
//-------------------------------------------//
WiFiClient client;
unsigned long myChannelNumber = 1831217; // Channel ID here
const int FieldNumber = 1;
const char * myWriteAPIKey = "P47FDNAYU6MRM9WH"; // Your Write API Key here
unsigned short ADC;
unsigned char LDR_percentage;
void setup()

{
Serial.begin(115200);
pinMode(2,OUTPUT);
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client);
}
void loop()
{
if (WiFi.status() != WL_CONNECTED)
{
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED)
{
WiFi.begin(ssid, pass);
Serial.print(".");
delay(5000);
}
Serial.println("\nConnected.");
}
ADC = analogRead(LDR_pin); // Reading LDR Input.
LDR_percentage = map(ADC, 0, 1023, 0, 100);
Serial.print("LDR Percentage = ");
Serial.print(LDR_percentage);
Serial.println(" %");
if(LDR_percentage >70)
{
digitalWrite(2,HIGH);
}
else{
digitalWrite(2,LOW);
}
ThingSpeak.writeField(myChannelNumber,FieldNumber,LDR_percentage, myWriteAPIKey);
delay(15000);
}

RESULT:

Thus the iot based system was implemented successfully.

You might also like