You are on page 1of 50

CONTENTS

EX.NO DATE EXPERIMENTS Pg.No MARKS STAFF SIGN

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


Introduction to Keil Complier
 Embedded system refers to a combination of computer hardware and programmable
software designed for a specific mission, such as displaying a message on an LCD
screen. It involves both hardware (the 8051 microcontroller) and software (the assembly
language code).
 Embedded systems may be found in ticketing machines, vending machines, and
temperature control units in air conditioners, among other examples.
 Microcontrollers are useless without an embedded program. Loading the developed
software/program onto the microcontroller is a crucial step in the creation of an
embedded system.
 Typically, this is referred to as "burning software" onto the controller. Before "burning
a program" into a controller, we must perform a number of operations with the
program. This involves creating the program in assembly language or C language in a
text editor such as notepad, compiling the program with a compiler, and then generating
the hex code from the compiled program. Historically, these three duties were performed
using three separate programs.
 Writing was done in a text editor such as notepad/WordPad, compiling was performed
using a distinct software (likely a dedicated compiler for a specific controller such as
8051), converting assembly code to hex code was performed using yet another software,
etc. It takes a great deal of time and effort to perform each of these separately,
particularly when the task requires extensive error debugging and source code rework.
 Using the Keil development tools, the Vision IDE is the easiest method for the majority
of developers to create embedded applications. The new Keil Vision4 integrated
development environment (IDE) has been designed to increase developer productivity,
facilitating quicker and more efficient program development.
 Keil MicroVision is a free software that addresses many of the primary concerns of
embedded software developers. This software is an integrated development environment
(IDE), which incorporated a text editor to write programs, a compiler and it will convert
your source code to hex files too.
 Vision4 introduces a flexible window management system that enables the dragging and
dropping of individual windows anywhere on the visual surface and also supports
multiple monitors.
1.1 General Computing Systems Vs Embedded Systems

GENERAL PURPOSE COMPUTING EMBEDDED SYSTEM


SYSTEM
It is a combination of generic hardware It is combination of special purpose
and a general purpose operating system for hardware and embedded OS for executing
executing variety of applications. specific set of applications.
Contains a General Purpose Operating May or may not contain an OS for
Systems (GPOS). functioning
Applications are alterable Application-specific requirements ( Like
(Programmable) by the user. performance ,power, memory etc.,)
Response requirements are not time- Highly time-critical.
Critical

1.2 C51 Development Tools


 Keil development tools for the 8051 microcontroller family support every level of developer
from the professional applications engineer to the student just learning about embedded
software development.
 The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-time Kernels,
and Single-board Computers support ALL 8051-compatible derivatives and help us get our
projects completed on schedule.
 The C51 development tool chains are designed for the professional software developer, but
any level of programmer can use them to get the most out of the 8051 microcontroller
architecture.
 With the C51 tools, embedded applications can be generated for virtually every 8051 variant.
Refer to the μVision Device Database for a list of currently supported microcontrollers.
 The Keil C51 development tools offer numerous features and advantages that help us to
develop embedded applications quickly and successfully.
 Find out more about the supported devices and the possible tool combinations available for
the different 8051 variants.
 The μVision IDE is a window-based software development tool that combines project
management and a rich-featured editor with interactive error correction, option setup, make
facility, and on-line help.
 Use μVision to create source files and organize them into a project that defines your target
application.
 The following block diagram shows the components involved in the build process.

μVision Integrated Development Environment (IDE)


1.3 Procedure

Step1: Create new u vision project.


Step2: Select the folder (newly created) to save the project.

Step3: Save the project.


Step4: Select the vendor “Atmel” and device “AT89C51”.

Step 5: Addition of STARTUP.A51 to project folder.


Step 6: STARTUP.A51 is added.

Step 7: Type the Required Program


Step 8: Save the Program as Prgm.asm format.

Step 9: Prgm.asm is to be added to Source Group1.


Step 10: Select the file now it is added to Source Group1.

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.

SCREENSHOT OF SWAPPING OF DATA TRANSFER BETWEEN 40 & 50


SCREENSHOT OF SWAPPING OF DATA TRANSFER BETWEEN 41 & 51.

SCREENSHOT OF SWAPPING OF DATA TRANSFER BETWEEN 42 & 52.


RESULT:
EXP NO:3 Perform ALU operations.
DATE:
AIM:
To write an 8051 Assembly Language program and Perform ALU operations (Addition, subtraction,
Division and Multiplication) 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. 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

ORG 0000H ORG 000H


MOV A,#40H MOV A,#40H
MOV B,#41H MOV B,
ADD A,B #41H SUBB
MOV 42H,A A,B MOV
END 42H,A
END
MULTIPLICATION DIVISION
ORG 0000H ORG 000H
MOV A, #40H MOV A,
MOV B, #41H #40H MOV B,
MUL AB #41H DIV AB
MOV 42H,A MOV
MOV A,B 42H,A
MOV 43H,A MOV A,B
END MOV
43H,A
END

OUTPUT SCREENSHOT OF ADDITION


OUTPUT SCREENSHOT OF SUBTRACTION

OUTPUT SCREENSHOT OF MULTIPLICATION


OUTPUT SCREENSHOT OF DIVISION

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 peripheralsI/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

OUTPUT SCREENSHOT OF PARALLEL PORT 1 SUBTRACTION


OUTPUT SCREENSHOT OF PARALLEL PORT 2 MULTIPLICATION

OUTPUT SCR EENSHOT OF PARALLEL PORT 3 DIVISION


RESULT:
Introduction to Arduino Platform and Programming

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:

 Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller


platforms. The least expensive version of the Arduino module can be assembled by hand, and even
the pre-assembled Arduino modules cost very less.
 Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux
operating systems. Most microcontroller systems are limited to Windows.
 Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use for
beginners, yet flexible enough for advanced users to take advantage of as well. For teachers, it's
conveniently based on the Processing programming environment, so students learning to program in
that environment will be familiar with how the Arduino IDE works.
 Open source and extensible software - The Arduino software is published as open source tools,
available for extension by experienced programmers. The language can be expanded through C++
libraries, and people wanting to understand the technical details can make the leap from Arduino to
the AVR C programming language on which it's based. Similarly, you can add AVR-C code directly
into your Arduino programs if you want to.
 Open source and extensible hardware - The plans of the Arduino boards are published under a
Creative Commons license, so experienced circuit designers can make their own version of the
module, extending it and improving it. Even relatively inexperienced users can build the breadboard
version of the module in order to understand how it works and save money.

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

Screenshot of IDE’s Status messages


 Processing Power and Memory: The ESP32 is significantly more powerful and has more memory
than the Arduino Uno. This makes it capable of handling more complex tasks and managing multiple
operations simultaneously.
 Operating Voltage: Arduino Uno operates at 5V, while the ESP32 operates at 3.3V. This could
impact the selection of compatible components for your project.
 Built-in Connectivity: The ESP32 comes with built-in Wi-Fi and Bluetooth, making it an excellent
choice for IoT projects. On the other hand, Arduino Uno doesn't have built-in connectivity, but you
can add these capabilities using shields.
 Analog Input Pins: The ESP32 has more analog inputs, making it a better choice for projects
requiring multiple analog sensors.
 Ease of Use: Arduino is generally considered easier to get started with and has a vast community
and a lot of resources, which can be helpful for beginners.

Advantages of ESP 32 over Arduino:

 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.

Steps to install ESP32 board in your Arduino IDE. Simply by :

 Open your Arduino IDE, then go to File > Preferences


 Enter https://dl.espressif.com/dl/package_esp32_index.json into the “Additional Board Manager
URLs” field. Click OK
 Go to Tools > Board > Boards Manager open the Boards Managers
 Search “ESP 32” then press install button for “ESP32 by Espressif Systems”
 In the few seconds your ESP32 board installation should be done.

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

Next, you should:

 Plug ESP32 to your computer


 Open your Arduino IDE, then go Tools > Board menu.
 Select the Type of ESP board available.
EXP NO:5 Introduction to Arduino platform and programming
DATE :

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:

 PC with Arduino IDE


 Node MCU or ESP32
 Smart Phone (External device)
PROCEDURE:

1. Connect the ESP 32 kit to PC using USB.


2. Type the program in the IDE compiler.
3. Verify the program by compiling and upload it to ESP 32 by selecting the ports.
4. Turn on Bluetooth on your device.
5. Pair your device with the ESP32.
6. Open the Serial Bluetooth Terminal app on your device.
7. Click on the „link‟ icon on the top to connect to ESP32 Bluetooth Device.
8. Now any commands or data can be sent from ESP 32 to external device that can be viewed in the
serial monitor.
PROGRAM:
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) #error Bluetooth
is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT; void setup()
{
Serial.begin(115200);
SerialBT.begin();
Serial.println("Bluetooth Started! Ready to pair...");
}
void loop() {
if (Serial.available())
{
SerialBT.write(Serial.read());
}
if (SerialBT.available())
{
Serial.write(SerialBT.read());
}
delay(20);
}
SCREENSHOT OF OUTPUT IN THE SERIAL MONITOR

SCREENSHOT OF BLUETOOTH CONNECTION STATUS IN THE EXTERNAL DEVICE


RESULT:
Thus a program has been written for connecting the Bluetooth of ESP 32 controller to a
external Bluetooth device and it was implemented for sending and receiving data using Arduino IDE
platform.
Write a program to connect ESP 32 controller with Wi-Fi using inbuilt transceiver.
DATE

AIM:
Write a program to connect ESP 32 controller with Wi-Fi using inbuilt transceiver.

COMPONENTS REQUIRED:

1. PC with Arduino IDE


2. Node MCU or ESP32
3. Wi-Fi router or Smart phone

PROCEDURE
 We must include the WiFi.h library.

 Then we enter the name of the network and its password.

 We put the ESP32 in STATION mode with the function WiFi.mode(WIFI_STA)

 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

SCREENSHOT OF Wi-Fi CONNECTION STATUS IN THE EXTERNAL DEVICE

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);
}
}

OUTPUT IN SERIAL WINDOW


EX NO 9 Write a Program to connect ESP 32 controller for Getting the Call
Me Bot API KEY by IOT

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)
{

String url = "https://api.callmebot.com/whatsapp.php?phone=" + phoneNumber + "&apikey=" +


apiKey + "&text=" + urlEncode(message);
HTTPClient http;
http.begin(url);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");

int httpResponseCode = http.POST(url);


if (httpResponseCode == 200){
Serial.print("Message sent successfully");
}
else{
Serial.println("Error sending the message");
Serial.print("HTTP response code: ");
Serial.println(httpResponseCode);
}

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

You might also like