Professional Documents
Culture Documents
Cs3691 Embedded Systems and Iot Laboratory Record..
Cs3691 Embedded Systems and Iot Laboratory Record..
and memory
Using Embedded C.
programming
GSM, Bluetooth)
medium
Step 11: Build the target, if there are no errors, debug the target.
Step 12: New window evaluation mode appeared. Click ok.
Step 13: Verify the program output by clicking step option or F11.Output can be viewed in the
register window and also in memory window based on the type of the program.
EXP NO:1 Write 8051 Assembly Language experiments using simulator.
DATE
AIM:
To write an 8051 Assembly Language program to move a hexadecimal integer to the
Accumulator and validate the results in the register window using the Keil simulator.
PROCEDURE:
1. Create new u vision project.
2. Select the folder (newly created) to save the project.
3. Save the project.
4. Select the vendor “Atmel” and device “AT89C51”.
5. Addition of STARTUP.A51 to project folder.
6. STARTUP.A51 is added.
7. Type the Required Program.
8. Save the Program as Prgm.asm format.
9. Prgm.asm is to be added to Source Group1.
10. Select the file now it is added to Source Group1.
11. Build the target and then debug the target.
12. New window evaluation mode appeared. Click ok
13. Verify the program output by clicking step option or F11.Output can be viewed in the
register windo
PROGRAM:
org 0000h
mov a, #2h
mov r0,#4h
mov a,r0
end
OUTPUT SCREENSHOT:
RESULT:
EXP NO :2 Test data transfer between registers and memory
DATE:
AIM:
To write an assembly language program to test the data transfer between registers and memory
using Keil Simulator.
PROCEDURE:
1. Create new u vision project.
2. Select the folder (newly created) to save the project.
3. Save the project.
4. Select the vendor “Atmel” and device “AT89C51”.
5. Addition of STARTUP.A51 to project folder.
6. STARTUP.A51 is added.
7. Type the Required Program.
8. Save the Program as Prgm.asm format.
9. Prgm.asm is to be added to Source Group1.
10. Select the file now it is added to Source Group1.
11. Build the target and then debug the target.
12. New window evaluation mode appeared. Click ok.
13. Modify the memory address by right clicking at the particular hexadecimal number and
give the appropriate data to the memory address.
14. Verify the program output by clicking step option or F11.Output can be viewed in the
register window and in memory window at the bottom.
PROGRAM:
ORG 0000H
MOV R0,#40H
MOV R1,#50H
MOV R3,#03H
BACK:MOV A,@R0
MOV B,@R1
MOV @R0,B
MOV @R1,A INC R0
INC R1
DJNZ R3,BACK
END
SCREENSHOT ASSIGNING DATA IN MEMORY ADDRESS OF 40, 41, 42 & 50, 51, 52.
PROCEDURE:
1. Create new u vision project.
2. Select the folder (newly created) to save the project.
3. Save the project.
4. Select the vendor “Atmel” and device “AT89C51”.
5. Addition of STARTUP.A51 to project folder.
6. STARTUP.A51 is added.
7. Type the Required Program.
8. Save the Program as Prgm.asm format.
9. Prgm.asm is to be added to Source Group1.
10. Select the file now it is added to Source Group1.
11. Build the target and then debug the target.
12. New window evaluation mode appeared. Click ok
13. Verify the program output by clicking step option or F11.Output can be viewed in the
register window and in memory window at the bottom (only for multiplication and division
operations).
PROGRAM:
ADDITION SUBTRACTION
RESULT:
EXP NO:4 Write Basic and arithmetic Programs Using Embedded C.
DATE:
AIM:
To write a basic arithmetic program (for performing Addition, subtraction, Division and
Multiplication) using Embedded C in Keil Simulator.
PROGRAM:
# include<reg51.h> void
main(void)
{
unsigned char x,y,z, a,b,c; //define variables
x=0x12; //first 8-bit number
y=0x34; //second 8-bit number
P0=0x00; //declare port 0 as output port
P1=0x00; //declare port 1 as output port
P2=0x00; //declare port 2 as output port
P3=0x00; //declare port 3 as output port
z=x+y; // perform addition
P0=z; //display result of addition on port 0
a=y-x; //perform subtraction
P1=a; // display result of subtraction on port 1
b=x*y; // perform multiplication
P2=b; //display result of multiplication on port 2
c=y/x; //perform division
P3=c; // display result of division on port 3
while(1);
}
PROCEDURE:
1. Create new u vision project.
2. Select the folder (newly created) to save the project.
3. Save the project.
4. Select the vendor “Atmel” and device “AT89C51”.
5. Addition of STARTUP.A51 to project folder.
6. STARTUP.A51 is added.
7. Type the Required Program.
8. Save the Program as Prgm.C format.
9. Prgm.C is to be added to Source Group1.
10. Select the file now it is added to Source Group1.
11. Build the target and then debug the target.
12. New window evaluation mode appeared. Click ok
13. Verify the program output by clicking step option or F11.Output can be viewed in the
register window
14. In peripheralsI/O Ports Port 0 displays result Addition
Port 1 displays result Subtraction
Port 2 displays result of multiplication
Port 3 displays result of division
OUTPUT SCREENSHOT OF PARALLEL PORT 0 ADDITION
Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino
boardsare able to read inputs - light on a sensor, a finger on a button, or a Twitter message and turn it into an
output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do
by sending a set of instructions to the microcontroller on the board. To do so you use theArduino programming
language (based on Wiring), and the Arduino Software (IDE), based on Processing.Arduino also simplifies the
process of working with microcontrollers, but it offers some advantage for teachers, students, and interested
amateurs over other systems:
Arduino IDE:
A toolchain is a set of programming tools that is used to perform a complex set of operations.In the
Arduino Software (IDE) the toolchain is hidden from the user, but it is used to compile and upload the user
Sketch. It includes compiler, assembler, linker and Standard C & math libraries.
The Arduino Integrated Development Environment (IDE) is a software application used to write,
compile, and upload code to Arduino-compatible microcontroller boards. It provides a user-friendly interface for
programming and prototyping electronic projects.
Arduino UNO board
Screenshot of Arduino IDE
More Processing Power: ESP32 has a more powerful CPU. It features a dual-core TensilicaXtensa
LX6, which can run up to 240 MHz, while the Arduino Uno runs an ATmega328P at 16 MHz and
the Mega runs an ATmega2560 at 16 MHz.
More Memory: ESP32 comes with significantly more RAM (520KB) compared to typical Arduino
boards (2KB for Uno, 8KB for Mega). This allows for more complex applications.
Wireless Connectivity: One of the major advantages of the ESP32 is the built-in Wi-Fi and
Bluetooth 4.2 (including BLE), which is crucial for IoT projects. Arduino boards don't have built-in
wireless connectivity, requiring additional components or shields.
More GPIO: The ESP32 has more general-purpose input/output (GPIO) pins, allowing it to
interface with a larger number of sensors and devices. The ESP32 has 34 GPIO pins, while the
Arduino Uno has 14, and the Mega has 54.
Analog Inputs and Outputs: ESP32 has more analog input channels and also features two 8-bit
DAC channels, which Arduino Uno lacks.
Lower Operating Voltage: ESP32 operates at a voltage of 3.3V, which is beneficial when working
with sensors or devices that also operate at 3.3V.
Deep Sleep Mode: The ESP32 has a deep sleep mode for power saving, consuming less than 10uA,
which makes it a better choice for battery-powered projects.
The choice between Arduino and ESP32 depends on the specific requirements of your project. For simple
tasks and ease of use, an Arduino could be a good choice. But for tasks requiring more processing power,
memory, or built-in Wi-Fi and Bluetooth, the ESP32 would be a more fitting choice.
Now, we can go to the next step which is setting communication port, as ESP32 board has USB to UART
converter that needs to be installed for serial data communication between ESP32 and your computer. You
may want to download it fromhttps://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers
AIM:
Write a program to flash an LED using Arduino IDE platform and implement the same using ESP32.
Components Required:
LED
PC with Arduino IDE
Node MCU or ESP32
PROCEDURE:
1. Give the connections as per the circuit diagram.
2. Connect the ESP 32 kit to PC using USB.
3. Type the program in the IDE compiler.
4. Verify the program by compiling and upload it to ESP 32 by selecting the ports.
5. Now the LED may blink as per the delay given in the coding.
PROGRAM:
intledPin = 2;
voidsetup()
{
pinMode(ledPin, OUTPUT);
}
voidloop(){ digitalWrite(ledPin, HIGH);
delay(1000); digitalWrite(ledPin, LOW);
delay(1000);
}
CONNECTION DIAGRAM:
RESULT:
EXP NO: 6 (a) Explore different communication methods with IoT devices (Bluetooth)
DATE :
AIM:
Write a program for connecting the Bluetooth of ESP 32 controller to an external Bluetooth device
and implement it for sending and receiving data using Arduino IDE platform.
Components Required:
AIM:
Write a program to connect ESP 32 controller with Wi-Fi using inbuilt transceiver.
COMPONENTS REQUIRED:
PROCEDURE
We must include the WiFi.h library.
The ESP32 tries to connect to the Wi-Fi network using the function WiFi.begin(ssid, password)
The connection is not instantaneous! It is therefore necessary to regularly check the connection status:
as long as the ESP32 is not connected to the network, we will remain blocked inside the while loop.
We add a slight delay to avoid constantly checking the status.
Once the connection has been established, the local IP address of the ESP32 on this network will be
displayed.
PROGRAM:
#include <ESP8266WiFi.h>
const char* ssid = "Home";
const char* password = "Password123"; void setup()
{
Serial.begin(115200); delay(10);
Serial.println('\n');
WiFi.begin(ssid, password);
Serial.print("Connecting to ");
Serial.print(ssid); Serial.println(" ..."); int i = 0;
while (WiFi.status() != WL_CONNECTED)
{
delay(1000);
Serial.print(++i); Serial.print(' ');
}
Serial.println('\n');
Serial.println("Connection established!"); Serial.print("IP address:\
t");
Serial.println(WiFi.localIP());
}
void loop() { }
SCREENSHOT OF OUTPUT IN THE SERIAL MONITOR
RESULT:
EX NO: 8 Write a program to connect ESP 32 controller with Wi-Fi using inbuilt
transceiver zprogram to connect PIR sensor with ESP 32 controller.
DATE
AIM:
To Write a program to connect ESP 32 controller with Wi-Fi using inbuilt transceiver Program
to connect PIR sensor with ESP 32 controller.
PROCEDURE:
1. Read the PIR sensor output and check it is LOW or HIGH
2. If the sensor pin is low, then print No object in sight on the serial monitor
3. If the sensor pin is high, then print Object detected on the serial monitor
4. Now upload the code. (While uploading the code make sure your ESP32 board is in boot
mode.)
5. After uploading the code open the serial monitor and set the baud rate to 115200 to see the
output.
PROGRAM
const int PIR_SENSOR_OUTPUT_PIN = 13; /* PIR sensor O/P pin */ int
warm_up;
void setup() {
pinMode(PIR_SENSOR_OUTPUT_PIN, INPUT);
Serial.begin(115200); /* Define baud rate for serial communication */
Serial.println("Waiting For Power On Warm Up");
delay(20000); /* Power On Warm Up Delay
*/ Serial.println("Ready!");
}
void loop() {
int sensor_output;
sensor_output = digitalRead(PIR_SENSOR_OUTPUT_PIN);
if( sensor_output == LOW )
{
if( warm_up == 1 )
{
Serial.print("Warming Up\n\n");
warm_up = 0;
delay(2000);
}
Serial.print("No object in sight\n\n");
delay(1000);
}
else
{
Serial.print("Object detected\n\n");
warm_up = 1;
delay(1000);
}
}
AIM
To Write a Program to connect ESP 32 controller for Getting the Call Me Bot API KEY by IOT
PROCEDURE
1. First, include the necessary libraries:
2. Insert your network credentials on the following variables
3. We create a function called sendMessage() that you can call later to send messages to
WhatsApp. This function accepts as an argument the message you want to send.
4. Inside the function, we prepare the URL for the request with your information, phone
number, API key, and message.
5. As we’ve seen previously, the message needs to be URL encoded. We’ve included
the UrlEncode library to do that. It contains a function called urlEncode() that encodes
whatever message we pass as argument (urlEncode(message)).
PROGRAM
#include <WiFi.h>
#include <HTTPClient.h>
#include <UrlEncode.h>
const char* ssid = "Home";
const char* password = "Password123"; String
phoneNumber = "your phone number"; String
apiKey = "4500719";
void sendMessage(String message)
{
http.end();
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED)
{ delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address:
"); Serial.println(WiFi.localIP());
sendMessage("Hello from ESP32!");
}
void loop() {
}
OUTPUT IN SERIAL WINDOW