Es and Iot Lab Manual Own+Megatronics
Es and Iot Lab Manual Own+Megatronics
SYLLABUS
LIST OF EXPERIMENTS
1. Write 8051 Assembly Language experiments using simulator.
6. Explore different communication methods with IoT devices (Zigbee, GSM, Bluetooth)
11. Log Data using Raspberry PI and upload to the cloud platform
Date:
AIM:
Edsim51 Simulator
Personal Computer
PROCEDURE:
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.
Date:
AIM:
PROCEDURE:
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 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 11: Now run the project and you will get output.
PROGRAM:
org 00
MOV R0,#20H
MOV R1,#40H
MOV R3,#10
MOV @R1,A
INC R0
INC R1
DJNZ R3,UP
END
INPUT:
OUTPUT:
RESULT:
Thus the testing of data transfer between registers and memory using Embedded C was executed
and verified successfully.
Date:
AIM:
PROCEDURE:
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 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 11: Now run the project and you will get output.
PROGRAM:
mov a,#45h
mov 21h,a
mov a,#45h
mov 22h,a
mov a,#45h
mov 23h,a
end
INPUT:
OUTPUT:
RESULT:
Thus the ALU operations using Embedded C was executed and verified successfully.
Date:
AIM:
PROCEDURE:
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 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 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.
AIM:
Personal Computer
Arduino Uno Software Version 1.8
Arduino Uno Kit
Usb To Printer Interface Cable
PROCEDURE :
https://www.arduino.cc/en/software
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:
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 is a Bluetooth device used for wireless communication with Bluetooth enabled devices (like
smartphone).
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:
RESULT:
Thus the data send and received from Bluetooth module was explore
Exp.No:6.B DIFFERENT COMMUNICATION METHODS WITH IOT
DEVICES- GSM
AIM:
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:
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:
AIM:
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:
APPARATUS REQUIRED:
Bluetooth Sensor
Arduino uno
Rasberrypi
PROGRAM:
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:
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:
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:
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: