Embedded System and IOT Record
Embedded System and IOT Record
AIM:
To write 8051 Assembly Language Program for an 8-bit addition using Keil simulator and
execute it.
SOFTWARE REQUIRED:
A simulator is software that will execute the program and show the results exactly to the
program running on the hardware, if the programmer finds any errors in the program while
simulating the program in the simulator, he can change the program and re-simulate the code and get
the expected result, before going to the hardware testing. The programmer can confidently dump the
program in the hardware when he simulates his program in the simulator and gets the expected results.
8051 controller is a most popular 8-bit controller which is used in a large number of embedded
applications and many programmers write programs according to their application. So testing their
programs in the software simulators is a way. Simulators will help the programmer to understand the
errors easily and the time taken for the testing is also decreased.
These simulators are very useful for students because they do need not to build the complete
hardware for testing their program and validate their program very easily in an interactive way.
1|Page
✓ It has an in-built source code editor, graphical notepad, ASCII charts, Assembly symbol
viewer, etc. It also supports several 8051 ICs like at89c51, A89S52, 8051, 8052, etc.
✓ It will support certain electronic simulations like LED, 7segment display, LCD etc. which
will help in giving the output when you interface these things to the hardware directly.
✓ It has tools like hex decimal editors, base converters, special calculator, file converters,
inbuilt hardware programmers, etc.
✓ It has syntax validation, pop base auto-completion etc.
You can download this tool from [Link]
2. EDSIM 51: This is a virtual 8051 interfaced with virtual peripherals like 7 segment display, motor,
keypad, UART etc. This simulator is exclusively for students developed by James Rogers,. The
features of this simulator are
✓ Have virtual peripherals like ADC, DAC with scope to display, comparator etc.
✓ Supports only assembly language
✓ IDE is completely written in JAVA and supports all the OS.
✓ Completely free and with user guide, examples, etc.
You can download this simulator from the [Link]
3. 8051 IDE: This simulation software is exclusively for the Windows operating system (98/xp).
The features of this simulator are
✓ Text editor, assembler, and software simulate in one single program.
✓ Has facilities like Breakpoint setter, execute to break point, predefined simulator watch
window, etc.
✓ It is available in both free version and paid version.
You can download this tool from [Link]
4. KEIL µVision: KEIL is the most popular software simulator. It has many features like
interactive IDE and supports both C and assembly languages for compilation and simulation.
2|Page
INSTALLATION OF KEIL SOFTWARE
Set up Keil IDE for Programming
Keil µVision IDE is a popular way to program MCUs containing the 8051 architectures. It supports
over 50 microcontrollers and has good debugging tools including logic analyzers and watch windows.
In this article, we will use the AT89C51ED2 microcontroller, which has:
• 64 KB FLASH ROM
• On-chip EEPROM
• 256 Bytes RAM
• In-System programming for uploading the program
• 3 Timer/counters
• SPI, UART, PWM
After saving the file, a new window will pop up asking you to select your microcontroller.
As discussed, we are using AT89C51/AT89C51ED2/AT89C52, so select this controller under the
Microchip section (as Atmel is now a part of Microchip).
3|Page
Select ‘Yes’ in the next pop-up, as we do not need this file in our project.
From here, we need to create a file where we can write our C code. Navigate to File —> New.
Once the file is created, save it with .c extension in the same project folder.
4|Page
Next, we have to add that .c or .asm file to our project workspace. Select Add Existing Files and
then select the created .c or .asm file to get it added.
5|Page
PROCEDURE
1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create New Project Select
Device for Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of simulation by clicking Run or step run.8.
PROGRAM:
org 0000h
mov a,#05h
mov b,a
mov a,#00h
mov a,#03h
add a,b
mov 20h,a
end
6|Page
OUTPUT:
RESULT:
.
7|Page
EXP NO: 2
Test data transfer between registers and memory
DATE
AIM:
To write and execute an Assembly language program to transfer data between registers and
memory.
SOFTWARE REQUIRED:
PROCEDURE
1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create a New Project Select Device for
the Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of the simulation by clicking Run or Step run.
8|Page
PROGRAM:
TYPE-I:
ORG 0000H
CLR C
MOV R0, #55H
MOV R1, #6FH
MOV A, R0
MOV 30H, A
MOV A, R1
MOV 31H, A
END
PROGRAM:
TYPE-II:
ORG 0000H
CLR C
MOV R0, #30H //source address
END
9|Page
OUTPUT:
TYPE 2
RESULT:
10 | P a g e
EXP NO: 3
ALU operations
DATE
AIM:
To write and execute the ALU program using the Keil simulator.
PROCEDURE
1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create New Project Select Device for
Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of simulation by clicking Run or step run.
11 | P a g e
PROGRAM:
ORG 0000H
CLR C
//ADDITION
MOV A, #20H
ADD A, #21H
MOV 41H, A
//SUBTRACTION
MOV A, #20H
SUBB A, #18H
MOV 42H, A
//MULTIPLICATION
MOV A, #03H
MOV B, #04H
MUL AB
MOV 43H, A
//DIVISION
MOV A, #95H
MOV B, #10H
DIV AB
MOV 44H, A
MOV 45H, B
//AND
MOV A, #25H
MOV B, #12H
ANL A, B
MOV 46H, A
//OR
MOV A, #25H
MOV B, #15H
ORL A, B
MOV 47H, A
//XOR
MOV A, #45H
MOV B, #67H
12 | P a g e
XRL A, B
MOV 48H, A
//NOT
MOV A, #45H
CPL A
MOV 49H, A
END
OUTPUT:
ADD
13 | P a g e
SUB
RESULT:
MUL
14 | P a g e
NOT
RESULT:
15 | P a g e
EXP NO: 4(a)
WRITE BASIC PROGRAMS USING EMBEDDED C
DATE
AIM:
To write a basic embedded C program to control a port 0 pin 0 connected to an 8051
microcontroller using a Keil simulator.
SOFTWARE REQUIRED:
PROCEDURE
1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create a New Project Select Device for
the Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of the simulation by clicking Run or Step run.
16 | P a g e
PROGRAM:
#include<REG51.h>
int i,j;
sbit LED = P2^0;
void main()
{
while(1)
{
LED = 0;
for(j=0;j<10000;j++);
LED = 1;
for(j=0;j<10000;j++);
}
}
RESULT:
17 | P a g e
EXP NO: 4(b)
ARITHMETIC PROGRAMS USING EMBEDDED C
DATE
AIM:
To write an embedded C program for addition, subtraction, multiplication, and division
using the Keil simulator.
SOFTWARE REQUIRED:
PROCEDURE
1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project and Create New Project Select Device for
Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with the .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of the simulation by clicking Run or Step run.
18 | P a g e
PROGRAM:
#include<REG51.H>
unsigned char a, b;
void main()
{
a=0x10;
b=0x04;
P0=a-b;
P1=a+b;
P2=a*b;
P3=a/b;
while(1);
}
OUTPUT:
Port P0=
Port P1=
Port P2=
Port P3=
RESULT:
19 | P a g e
BASICS OF ARDUINO UNO PLATFORM
AIM:
To study the basics of Arduino Uno board and Arduino IDE 2.0 software.
INTRODUCTION TO ARDUINO:
Arduino is a project, open-source hardware, and software platform used to design and build electronic
devices. It designs and manufactures microcontroller kits and single-board interfaces for building
electronics projects. The Arduino boards were initially created to help students with the non-technical
background. The designs of Arduino boards use a variety of controllers and microprocessors. Arduino
is an easy-to-use open platform for creating electronic projects. Arduino boards play a vital role in
creating different projects. It makes electronics accessible to non-engineers, hobbyists, etc.
The various components present on the Arduino boards are a Microcontroller, Digital Input/output
pins, USB Interface and Connector, Analog Pins, reset buttons, Power buttons, LEDs, Crystal
oscillators, and Voltage regulators. Some components may differ depending on the type of board. The
most standard and popular board used over time is Arduino UNO. The ATmega328 Microcontroller
present on the UNO board makes it rather powerful than other boards. There are various types of
Arduino boards used for different purposes and projects. The Arduino Boards are organized using the
Arduino (IDE), which can run on various platforms. Here, IDE stands for Integrated Development
Environment. Let's discuss some common and best Arduino boards.
20 | P a g e
TYPES OF ARDUINO BOARDS
1) Arduino UNO
Arduino UNO is based on an ATmega328P microcontroller. It is easy to use compared to other boards,
such as the Arduino Mega board, etc. The Arduino UNO includes 6 analog pin inputs, 14 digital pins,
a USB connector, a power jack, and an ICSP (In-Circuit Serial Programming) header. It is the most
used and of standard form from the list of all available Arduino Boards.
2) Arduino Nano
The Arduino Nano is a small Arduino board based on ATmega328P or ATmega628 Microcontroller.
The connectivity is the same as the Arduino UNO board. The Nano board is defined as a sustainable,
small, consistent, and flexible microcontroller board. It is small in size compared to the UNO board.
The devices required to start our projects using the Arduino Nano board are Arduino IDE and mini-
USB. The Arduino Nano includes an I/O pin set of 14 digital pins and 8 analog pins. It also includes
6 Power pins and 2 Reset pins.
3) Arduino Mega
The Arduino Mega is based on the ATmega2560 Microcontroller. The ATmega2560 is an 8-bit
microcontroller. We need a simple USB cable to connect to the computer and the AC to DC adapter
or battery to get started with it. It has the advantage of working with more memory space. The Arduino
Mega includes 54 I/O digital pins and 16 Analog Input/Output (I/O), ICSP header, a reset
21 | P a g e
button, 4 UART (Universal Asynchronous Reciever/Transmitter) ports, USB connection, and a power
jack.
4) Arduino Micro
The Arduino Micro is based on the ATmega32U4 Microcontroller. It consists of 20 sets of pins. The
7 pins from the set are PWM (Pulse Width Modulation) pins, while 12 pins are analog input pins. The
other components on board are a reset button, a 16MHz crystal oscillator, an ICSP header, and a
micro-USB connection. The USB is built in the Arduino Micro board.
5) Arduino Leonardo
The basic specification of the Arduino Leonardo is the same as the Arduino Micro. It is also based on
the ATmega32U4 Microcontroller. The components present on the board are 20 analog and digital
pins, a reset button, a 16MHz crystal oscillator, an ICSP header, and a micro USB connection.
6) Arduino Due
22 | P a g e
The Arduino Due is based on the 32-bit ARM core. It is the first Arduino board that has been
developed based on the ARM Microcontroller. It consists of 54 Digital Input/Output pins and 12
Analog pins. The Microcontroller present on the board is the Atmel SAM3X8E ARM Cortex-M3
CPU. It has two ports, namely, a native USB port and a Programming port. The micro side of the USB
cable should be attached to the programming port.
7) Arduino Lilypad
The Arduino LilyPad was initially created for wearable projects and e-textiles. It is based on the
ATmega168 Microcontroller. The functionality of Lilypad is the same as other Arduino Boards. It is
a round, lightweight board with a minimal number of components to keep the size of the board small.
The Arduino Lilypad board was designed by Sparkfun and Leah. It was developed by Leah Buechley.
It has 9 digital I/O pins.
8) Arduino Bluetooth
The Arduino Bluetooth board is based on ATmega168 Microcontroller. It is also named as Arduino
BT board. The components present on the board are 16 digital pins, 6 analog pins, reset button,
16MHz crystal oscillator, ICSP header, and screw terminals. The screw terminals are used for power.
The Arduino Bluetooth Microcontroller board can be programmed over the Bluetooth as a wireless
connection.
23 | P a g e
9) Arduino Diecimila
The Arduino Diecimila is also based on the ATmeg628 Microcontroller. The board consists of 6
analog pin inputs, 14 digital Input/Output pins, a USB connector, a power jack, an ICSP (In-Circuit
Serial Programming) header, and a reset button. We can connect the board to the computer using the
USB and can power on the board with the help of an AC to DC adapter. The Diecimila was initially
developed to mark the 10000 delivered boards of Arduino. Here, Diecimila means 10,000 in Italian.
24 | P a g e
11) Arduino Ethernet
The Arduino Ethernet is based on the ATmega328 Microcontroller. The board consists of 6 analog
pins, 14 digital I/O pins, crystal oscillator, reset button, ICSP header, a power jack, and an RJ45
connection. With the help of the Ethernet shield, we can connect our Arduino board to the internet.
25 | P a g e
13) Arduino Esplora
The Arduino Esplora boards allow easy interfacing of sensors and actuators. The outputs and inputs
connected on the Esplora board make it unique from other types of Arduino boards. The board
includes outputs, inputs, a small microcontroller, a microphone, a sensor, a joystick, an accelerometer,
a temperature sensor, four buttons, and a slider.
26 | P a g e
INTRODUCTION TO ARDUINO UNO:
The Arduino UNO is a standard board of Arduino. Here UNO means 'one' in Italian. It was named
UNO to label the first release of Arduino Software. It was also the first USB board released by
Arduino. It is considered a powerful board used in various projects. Arduino. cc developed the
Arduino UNO board. Arduino UNO is based on an ATmega328P microcontroller. It is easy to use
compared to other boards, such as the Arduino Mega board, etc. The board consists of digital and
analog Input/Output pins (I/O), shields, and other circuits. The Arduino UNO includes 6 analog pin
inputs, 14 digital pins, a USB connector, a power jack, and an ICSP (In-Circuit Serial Programming)
header. It is programmed based on IDE, which stands for Integrated Development Environment. It
can run on both online and offline platforms. The IDE is common to all available boards of Arduino.
27 | P a g e
o ATmega328 Microcontroller- It is a single-chip Microcontroller of the ATmel family. The processor
code inside it is of 8-bit. It combines Memory (SRAM, EEPROM, and Flash), Analog to Digital
Converter, SPI serial ports, I/O lines, registers, timers, external and internal interrupts, and
oscillator.
o ICSP pin - The In-Circuit Serial Programming pin allows the user to program using the firmware of
the Arduino board.
o Power LED Indicator- The ON status of the LED shows the power is activated. When the power is
OFF, the LED will not light up.
o Digital I/O pins- The digital pins have the value HIGH or LOW. The pins numbered from D0 to D13
are digital pins.
o TX and RX LED's- The successful flow of data is represented by the lighting of these LED's.
o AREF- The Analog Reference (AREF) pin is used to feed a reference voltage to the Arduino UNO
board from the external power supply.
o Reset button- It is used to add a Reset button to the connection.
o USB- It allows the board to connect to the computer. It is essential for the programming of the Arduino
UNO board.
o Crystal Oscillator- The Crystal oscillator has a frequency of 16MHz, which makes the Arduino UNO
a powerful board.
o Voltage Regulator- The voltage regulator converts the input voltage to 5V.
o GND- Ground pins. The ground pin acts as a pin with zero voltage.
o Vin- It is the input voltage.
o Analog Pins- The pins numbered from A0 to A5 are analog pins. The function of Analog pins is to
read the analog sensor used in the connection. It can also act as GPIO (General Purpose Input Output)
pin.
28 | P a g e
ARDUINO UNO PINOUT
The Arduino UNO is a standard board of Arduino, which is based on
an ATmega328P microcontroller. It is easier to use than other types of Arduino Boards.
The Arduino UNO Board, with the specification of pins, is shown below:
29 | P a g e
USB Interface: The USB Interface is used to plug-in the USB cable. It allows the board to connect to the
computer. It is essential for the programming of the Arduino UNO board.
RESET: It is used to add a Reset button to the connection.
SCK: It stands for Serial Clock. These are the clock pulses, which are used to synchronize the transmission
of data.
MISO: It stands for Master Input/ Slave Output. The save line in the MISO pin is used to send the data to
the master.
VCC: It is the modulated DC supply voltage, which is used to regulate the IC's used in the connection. It is
also called as the primary voltage for IC's present on the Arduino board. The Vcc voltage value can be negative
or positive with respect to the GND pin.
Crystal Oscillator- The Crystal oscillator has a frequency of 16MHz, which makes the Arduino UNO a
powerful board.
ICSP: It stands for In-Circuit Serial Programming. The users can program the Arduino board's firmware
using the ICSP pins. The program or firmware with the advanced functionalities is received by microcontroller
with the help of the ICSP header. The ICSP header consists of 6 pins.
The structure of the ICSP header is shown below:
SDA: It stands for Serial Data. It is a line used by the slave and master to send and receive data. It is called as
a data line, while SCL is called as a clock line.
SCL: It stands for Serial Clock. It is defined as the line that carries the clock data. It is used to synchronize
the transfer of data between the two devices. The Serial Clock is generated by the device and it is called as
master.
SPI: It stands for Serial Peripheral Interface. It is popularly used by the microcontrollers to communicate
with one or more peripheral devices quickly. It uses conductors for data receiving, data sending,
synchronization, and device selection (for communication).
MOSI: It stands for Master Output/ Slave Input. The MOSI and SCK are driven by the Master.
SS: It stands for Slave Select. It is the Slave Select line, which is used by the master. It acts as the enable line.
I2C: It is the two-wire serial communication protocol. It stands for Inter Integrated Circuits. The I2C is a serial
communication protocol that uses SCL (Serial Clock) and SDA (Serial Data) to receive and send data between
two devices. 3.3V and 5V are the operating voltages of the board.
30 | P a g e
INTRODUCTION TO ARDUINO IDE 2.0:
The Arduino IDE 2.0 is an open-source project, currently in its beta-phase. It is a big step from it's
sturdy predecessor, Arduino IDE 2.0, and comes with revamped UI, improved board & library
manger, autocomplete feature and much more.
In this tutorial, we will go through step by step, how to download and install the software.
Download the editor
Downloading the Arduino IDE 2.0 is done through the Arduino Software page. Here you will also
find information on the other editors available to use.
Requirements
• Windows - Win 10 and newer, 64 bits
• Linux - 64 bits
• Mac OS X - Version 10.14: "Mojave" or newer, 64 bits
Installation
Windows
Download URL: [Link]
To install the Arduino IDE 2.0 on a Windows computer, simply run the file downloaded from the
software page.
31 | P a g e
Follow the instructions in the installation guide. The installation may take several minutes.
You can now use the Arduino IDE 2.0 on your windows computer!
How to use the board manager with the Arduino IDE 2.0
The board manager is a great tool for installing the necessary cores to use your Arduino boards. In
this quick tutorial, we will take a look at how to install one, and choosing the right core for your board!
Requirements
• Arduino IDE 2.0 installed.
Why use the board manager?
The board manager is a tool that is used to install different cores on your local computer. So what
is a core, and why is it necessary that I install one?
Simply explained, a core is written and designed for specific microcontrollers. As Arduino have
several different types of boards, they also have different type of microcontrollers. For example,
an Arduino UNO has an ATmega328P, which uses the AVR core, while an Arduino
Nano 33 IoT has a SAMD21 microcontroller, where we need to use the SAMD core.
In conclusion, to use a specific board, we need to install a specific core.
Installing a core
Installing a core is quick and easy, but let's take a look at what we need to do.
1. Open the Arduino IDE 2.0.
2. With the editor open, let's take a look at the left column. Here, we can see a couple of icons.
Let's click the on the "computer chip" icon.
32 | P a g e
1. A list will now appear of all available cores. Now let's say we are using an Nano 33
IoT board, and we want to install the core. Simply enter the name in the search field, and the
right core (SAMD) will appear, where the Nano 33 IoT features in the description. Click on
the "INSTALL" button.
33 | P a g e
4. This will begin an installation process, which in some cases may take several minutes.
5. When it is finished, we can take a look at the core in the boards manager column, where it
should say "INSTALLED".
You have now successfully downloaded and installed a core on your machine, and you can start
using your Arduino board!
34 | P a g e
How to upload a sketch with the Arduino IDE 2.0
In the Arduino environment, we write sketches that can be uploaded to Arduino boards. In this
tutorial, we will go through how to select a board connected to your computer, and how to upload
a sketch to that board, using the Arduino IDE 2.0.
Requirements
• Arduino IDE 2.0 installed.
Verify VS Upload
There are two main tools when uploading a sketch to a board: verify and upload. The verify tool
simply goes through your sketch, checks for errors and compiles it. The upload tool does the same,
but when it finishes compiling the code, it also uploads it to the board.
A good practice is to use the verifying tool before attempting to upload anything. This is a quick
way of spotting any errors in your code, so you can fix them before actually uploading the code.
Uploading a sketch
Installing a core is quick and easy, but let's take a look at what we need to do.
1. Open the Arduino IDE 2.0.
2. With the editor open, let's take a look at the navigation bar at the top. At the very left, there is
a checkmark and an arrow pointing right. The checkmark is used to verify, and the arrow
is used to upload.
3. Click on the verify tool (checkmark). Since we are verifying an empty sketch, we can be sure
it is going to compile. After a few seconds, we can see the result of the action in the console
(black box in the bottom).
35 | P a g e
1. Now we know that our code is compiled, and that it is working. Now, before we can upload
the code to our board, we will first need to select the board that we are using. We can do this
by navigating to Tools > Port > {Board}. The board(s) that are connected to your computer
should appear here, and we need to select it by clicking it. In this case, our board is displayed
as COM44 (Arduino UNO).
5. With the board selected, we are good to go! Click on the upload button, and it will start
uploading the sketch to the board.
6. When it is finished, it will notify you in the console log. Of course, sometimes there are some
complications when uploading, and these errors will be listed here as well.
36 | P a g e
you have now uploaded a sketch to your Arduino board!
How to install and use a library with the Arduino IDE 2.0
A large part of the Arduino programming experience is the use of libraries. Thousands of libraries
can be found online, and the best-documented ones can be found and installed directly through the
editor. In this tutorial, we will go through how to install a library using the library manager in the
Arduino IDE 2.0. We will also show how to access examples from a library that you have installed.
Requirements
• Arduino IDE 2.0 installed.
Why use libraries?
Libraries are incredibly useful when creating a project of any type. They make our development
experience much smoother, and there almost an infinite amount out there. They are used to interface
with many different sensors, RTCs, Wi-Fi modules, RGB matrices and of course with other
components on your board.
Arduino has many official libraries, but the real heroes are the Arduino community, who develop,
maintain and improve their libraries on a regular basis.
Installing a library
Installing a library is quick and easy, but let's take a look at what we need to do.
1. Open the Arduino IDE 2.0.
2. With the editor open, let's take a look at the left column. Here, we can see a couple of icons.
Let's click the on the "library" icon.
37 | P a g e
3. A list will now appear of all available libraries, where we can also search for the library we
want to use. In this example, we are going to install the RTCZero library. Click on
the "INSTALL" button to install the library.
4. This process should not take too long, but allow up to a minute to install it.
38 | P a g e
5. When it is finished, we can take a look at the library in the library manager column, where it
should say "INSTALLED".
You have now successfully downloaded and installed a library on your machine.
39 | P a g e
Including a library
To use a library, you first need to include the library at the top of the
sketch.
Almost all libraries come with already made examples that you can use. These are accessible
through File > Examples > {Library} > {Example}. In this example, we are choosing
the RTCZero > SimpleRTC.
40 | P a g e
The chosen example will now open up in a new window, and you can start using it however
you want to.
41 | P a g e
EXP NO: 5
INTRODUCTION TO ARDUINO PROGRAMMING
DATE
AIM:
To write the Arduino program for Turn on a LED
5 Joystick Module 1
PROCEDURE:
42 | P a g e
CONNECTION:
PROGRAM:
DIGITAL WRITE:
void setup() {
pinMode(13,0UTPUT);
}
void loop() {
digita1Write(13,HIGH);
}
PROGRAM:
void setup() {
pinMode(13,0UTPUT);
}
void loop() {
digita1Write(13,HIGH);
delay(l 000);
digita1Write(13,LOW);
delay(l 000);
}
RESULT:
43 | P a g e
EXP NO: 6 Different communication methods with IoT devices
DATE (Zigbee, GSM, Bluetooth)
AIM:
To explore different communication methods with IoT devices (Zigbee, GSM, Bluetooth)
IoT devices require reliable and efficient communication methods to transmit data and interact
with other devices or systems. Here are three commonly used communication methods for
IoT devices:
Zigbee:
GSM is a widely used cellular network technology that enables IoT devices to connect to the
internet using SIM cards. It operates on various frequency bands and provides wide coverage,
making it suitable for applications that require long-range communication. GSM is commonly
used in applications such as asset tracking, remote monitoring, and smart cities.
Bluetooth:
Bluetooth is a short-range wireless communication technology that operates on the 2.4 GHz
frequency band. It is commonly used for connecting IoT devices to smartphones, tablets, and
other nearby devices. Bluetooth Low Energy (BLE) is a power-efficient version of Bluetooth
that is ideal for battery-powered IoT devices. Bluetooth is widely used in applications such as
wearable devices, healthcare monitoring, and home automation.
Each communication method has its advantages and limitations, and the choice depends on
the specific requirements of the IoT application. Factors to consider include range, power
consumption, data rate, security, and interoperability with other devices or systems.
44 | P a g e
EXP NO: 6(a)
BLUETOOTH COMMUNICATION
DATE
AIM:
To write a program for Electronics Notice Board using a Bluetooth module.
PROCEDURE
45 | P a g e
CONNECTIONS:
Note: DIP Switch S1 in 16X2 LCD Display Block should be all ON position.
PROGRAM:
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
// Bluetooth: TX → D2, RX → D3
SoftwareSerial BTSerial(2, 3);
void setup() {
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW); // start with relay off
[Link](9600);
[Link](9600);
// Initialize LCD
[Link](16, 2); // 16 columns, 2 rows
[Link]();
[Link](0, 0);
[Link]("Bluetooth Ctrl");
[Link](0, 1);
[Link]("Waiting...");
void loop() {
if ([Link]()) {
char command = [Link]();
[Link]();
[Link](0, 0);
[Link]("Relay ON");
[Link](0, 1);
[Link]("Bluetooth Ctrl");
}
else if (command == '0') { // relay OFF
digitalWrite(relayPin, LOW);
[Link]("Relay OFF");
[Link]("Relay OFF");
[Link]();
[Link](0, 0);
[Link]("Relay OFF");
[Link](0, 1);
[Link]("Bluetooth Ctrl");
}
// anything else is ignored
}
}
RESULT:
47 | P a g e
EXP NO: 6(b)
ZIGBEE COMMUNICATION
DATE
AIM:
To write the Arduino program for communication between two trainers and control the
led by switch.
HARDWARE & SOFTWARE TOOLS REQUIRED:
PROCEDURE
48 | P a g e
CONNECTIONS:
Note: DIP Switch S3 in PUSH Button Block switch7 should be ON position.
TRANSMITTER:
PROGRAM:
TRANSMITTER SIDE:
#include <SoftwareSerial.h>
const int buttonPin = 8;
int buttonState = 0;
void setup() {
[Link](9600);
[Link](9600);
pinMode(buttonPin, INPUT);
void loop()
{
buttonState = digitalRead(buttonPin);
//[Link](buttonState);
[Link](buttonState);
delay(1000);
}
49 | P a g e
CONNECTIONS:
RECEIVER:
RECEIVER SIDE:
#include <SoftwareSerial.h>
void setup() {
[Link](9600);
[Link](9600);
pinMode(ledPin, OUTPUT);
void loop()
{
while ([Link]())
{
LED_State = ([Link]());
//[Link](LED_State[0]);
if(LED_State[0] == '0')
{
digitalWrite(ledPin, LOW);
[Link]("LED_OFF");
}
else if(LED_State[0] == '1')
{
digitalWrite(ledPin, HIGH);
[Link]("LED_ON");
}
else{}
delay(3000);
50 | P a g e
RESULT:
51 | P a g e
EXP NO: 6(c)
GSM COMMUNICATION
DATE
AIM:
To write the Arduino program for detect the flame and send a sms.
PROCEDURE
52 | P a g e
CONNECTIONS:
PROGRAM:
##include <SoftwareSerial.h>
char sim800l[255];
int sim800lIndex = 0;
void setup()
[Link](9600);
[Link](9600);
[Link](200);
[Link](200);
53 | P a g e
[Link](" Command --> AT ");
[Link]("AT");
[Link]("\r");
delay(100);
while ([Link]())
sim800l[sim800lIndex] =
[Link]();
sim800lIndex++;
sim800lIndex = 0;
[Link]("");
[Link]("ATE0");
[Link]("\r");
delay(100);
while ([Link]())
sim800l[sim800lIndex] =
[Link]();
54 | P a g e
sim800lIndex++;
sim800lIndex = 0;
[Link]("");
[Link]("ATD8148911718;"); //
enter number ATD<number>
[Link]("\r");
while ( !([Link]()) );
while ([Link]())
{
sim800l[sim800lIndex] =
[Link]();
sim800lIndex++;
[Link]( sim800l[sim800lIndex - 1]);
}
sim800lIndex = 0;
[Link](" ");
[Link](" Enter 'ATH' command to
End the call ");
55 | P a g e
}
void loop()
{
while (1)
{
while ([Link]())
{
sim800l[sim800lIndex] = [Link]();
sim800lIndex++;
[Link]( sim800l[sim800lIndex -
1]);
}
while ([Link]())
{
sim800l[sim800lIndex] =
[Link]();
sim800lIndex++;
if (sim800l[sim800lIndex - 4] == 'R' &&
sim800l[sim800lIndex - 3] == 'I' &&
sim800l[sim800lIndex - 2] == 'N' &&
sim800l[sim800lIndex - 1] == 'G')
{
delay(8000);
[Link]("ATA"); // AT command
to answer the call.
[Link]("\r");
}
[Link]( sim800l[sim800lIndex - 1]);
}
}
}
56 | P a g e
RESULT:
57 | P a g e
INTRODUCTION TO THE RASPBERRY PI
PLATFORM
The Raspberry Pi Pico W is a compact and affordable microcontroller board developed by the
Raspberry Pi Foundation. Building upon the success of the Raspberry Pi Pico, the Pico W variant
brings wireless connectivity to the table, making it an even more versatile platform for embedded
projects. In this article, we will provide a comprehensive overview of the Raspberry Pi Pico W,
highlighting its key features and capabilities.
Features:
• RP2040 microcontroller with 2MB of flash memory
• On-board single-band 2.4GHz wireless interfaces (802.11n)
• Micro USB B port for power and data (and for reprogramming the flash)
• 40 pins 21mmx51mm ‘DIP’ style 1mm thick PCB with 0.1″ through-hole pins also with edge
castellations
• Exposes 26 multi-function 3.3V general purpose I/O (GPIO)
• 23 GPIO are digital-only, with three also being ADC-capable
• Can be surface mounted as a module
• 3-pin ARM serial wire debug (SWD) port
• Simple yet highly flexible power supply architecture
• Various options for easily powering the unit from micro-USB, external supplies, or batteries
• High quality, low cost, high availability
• Comprehensive SDK, software examples, and documentation
• Dual-core Cortex M0+ at up to 133MHz
• On-chip PLL allows variable core frequency
• 264kByte multi-bank high-performance SRAM
Raspberry Pi Pico W:
The Raspberry Pi Pico W is based on the RP2040 microcontroller, which was designed by Raspberry
Pi in-house. It combines a powerful ARM Cortex-M0+ processor with built-in Wi-Fi connectivity,
opening up a range of possibilities for IoT projects, remote monitoring, and wireless communication.
The Pico W retains the same form factor as the original Pico, making it compatible with existing Pico
accessories and add-ons.
58 | P a g e
RP2040 Microcontroller:
At the core of the Raspberry Pi Pico W is the RP2040 microcontroller. It features a dual-core ARM
Cortex-M0+ processor running at 133MHz, providing ample processing power for a wide range of
applications. The microcontroller also includes 264KB of SRAM, which is essential for storing and
manipulating data during runtime. Additionally, the RP2040 incorporates 2MB of onboard flash
memory for program storage, ensuring sufficient space for your code and firmware.
Wireless Connectivity:
The standout feature of the Raspberry Pi Pico W is its built-in wireless connectivity. It includes an
onboard Cypress CYW43455 Wi-Fi chip, which supports dual-band (2.4GHz and 5GHz) Wi-Fi
802.11b/g/n/ac. This allows the Pico W to seamlessly connect to wireless networks, communicate
with other devices, and access online services. The wireless capability opens up new avenues for IoT
projects, remote monitoring and control, and real-time data exchange.
59 | P a g e
Pico W is compatible with C/C++ programming, allowing experienced developers to leverage the rich
ecosystem of libraries and frameworks available.
60 | P a g e
The Raspberry Pi Pico W brings wireless connectivity to the popular Raspberry Pi Pico
microcontroller board. With its powerful RP2040 microcontroller, built-in Wi-Fi chip, extensive
GPIO capabilities, and compatibility with MicroPython and C/C++ programming, the Pico W offers
a versatile and affordable platform for a wide range of embedded projects. Whether you are a beginner
or an experienced developer, the Raspberry Pi Pico W provides a user-friendly and flexible platform
to bring your ideas to life and explore the exciting world of wireless IoT applications.
61 | P a g e
EXP NO: 7
INTRODUCTION TO PYTHON PROGRAMMING
DATE
What is MicroPython?
MicroPython is a Python 3 programming language re-implementation targeted for microcontrollers
and embedded systems. MicroPython is very similar to regular Python. Apart from a few exceptions,
the language features of Python are also available in MicroPython. The most significant difference
between Python and MicroPython is that MicroPython was designed to work under constrained
conditions.
Because of that, MicroPython does not come with the entire pack of standard libraries. It only includes
a small subset of the Python standard libraries, but it includes modules to easily control and interact
with the GPIOs, use Wi-Fi, and other communication protocols.
62 | P a g e
Thonny IDE:
Thonny is an open-source IDE which is used to write and upload MicroPython programs to
different development boards such as Raspberry Pi Pico, ESP32, and ESP8266. It is extremely
interactive and easy to learn IDE as much as it is known as the beginner-friendly IDE for new
programmers. With the help of Thonny, it becomes very easy to code in Micropython as it has
a built-in debugger that helps to find any error in the program by debugging the script line by
line.
You can realize the popularity of Thonny IDE from this that it comes pre-installed in
Raspian OS which is an operating system for a Raspberry Pi. It is available to install on r
Windows, Linux, and Mac OS.
63 | P a g e
3. Run the .exe file.
4. Follow the installation wizard to complete the installation process. You just need to click
“Next”.
64 | P a g e
5. After completing the installation, open Thonny IDE. A window as shown in the following
figure should open.
65 | P a g e
CONNECTIONS:
PROGRAM
# LED setup
led = Pin(15, [Link])
while True:
if [Link]():
data = [Link]()
if data:
message = [Link]('utf-8').strip()
print("Received:", message)
[Link](0.1)
RESULT:
66 | P a g e
EXP NO: 8
INTERFACING SENSORS WITH RASPBERRY PI
DATE
AIM:
To write the python program for Measure the obstacle distance in cm using Ultrasonic
Sensor with Raspberry Pico.
1 Thonny IDE 1
2 Raspberry Pi Pico Development Board 1
3 Jumper Wires few
4 Micro USB Cable 1
5 IR Sensor 1
6 Ultrasonic sensor 1
PROCEDURE
1. Click on Thonny.
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on run.
67 | P a g e
CONNECTIONS:
PROGRAM:
def ultra():
[Link]()
utime.sleep_us(2)
[Link]()
utime.sleep_us(5)
[Link]()
while [Link]() == 0:
signaloff = utime.ticks_us()
while [Link]() == 1:
signalon = utime.ticks_us()
while True:
ultra()
[Link](1)
RESULT:
.
68 | P a g e
EXP NO: 9 COMMUNICATE BETWEEN ARDUINO AND
DATE RASPBERRY PI
AIM:
To write the python program for communication between Arduino and Raspberry Pi
Using ZigBee Wireless Medium.
uoth)
1 Thonny IDE 1
2 Raspberry Pi Pico Development Board 1
3 Arduino Uno Development Board 1
4 Jumper Wires few
5 Micro USB Cable 1
6 Bluetooth Module 2
PROCEDURE
1. Click on Thonny.
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on run.
69 | P a g e
CONNECTIONS:
int buttonState = 0;
void setup() {
[Link](9600);
[Link](9600);
pinMode(buttonPin, INPUT);
void loop()
{
buttonState = digitalRead(buttonPin);
//[Link](buttonState);
[Link](buttonState);
delay(1000);
}
# ---------------------------
# LED setup
# ---------------------------
70 | P a g e
led = Pin(15, [Link]) # LED on GP15
# ---------------------------
# UART setup for HC-12
# ---------------------------
# UART1: TX=GP9, RX=GP8
uart = UART(1, baudrate=9600, tx=Pin(8), rx=Pin(9))
# ---------------------------
# Main loop
# ---------------------------
while True:
if [Link](): # Check if HC-12 sent data
data = [Link]() # Read one line
if data:
message = [Link]('utf-8').strip() # FIXED indentation
print("Received:", message)
if message == "1":
[Link](1)
elif message == "0":
[Link](0)
utime.sleep_ms(50)
RESULT:
.
71 | P a g e
EXP NO: 10
CLOUD PLATFORM TO LOG THE DATA
DATE
AIM:
To set up a cloud platform to log the data from IoT devices.
1 Thinkspeak Platform 1
CLOUD PLATFORM-
Think Speak:
72 | P a g e
3. Fill the following mandatory fields: User ID, E-mail, Time Zone, Password and Password
Confirmation
73 | P a g e
5. Click "Create New Channel".
74 | P a g e
7. Fill Fields 1 to 6 with the following values: Left Wheel, Right Wheel, Vacuum, Bumper, Cliff
and Battery.
75 | P a g e
[Link] the "API Key" tab to get the API key required by the installer.
76 | P a g e
RESULT:
77 | P a g e
EXP NO: 11 Log Data using Raspberry PI and upload it to the cloud
DATE Platform
AIM:
To write and execute the program Log Data using Raspberry PI and upload it to the cloud
platform
PROCEDURE
1. Click on Thonny.
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on run.
78 | P a g e
CONNECTIONS:
Note: See J13 Connector From left to right 3rd
PROGRAM:
import network
import urequests
import utime
from machine import Pin
import dht
# ---------------------------
# WiFi Setup
# ---------------------------
ssid = "velmurugan"
password = "12345678"
wlan = [Link](network.STA_IF)
[Link](pm=0) # disable power saving
[Link](True)
[Link](ssid, password)
# ---------------------------
# DHT11 Setup
# ---------------------------
sensor = dht.DHT11(Pin(0))
# ---------------------------
# ThingSpeak API
# ---------------------------
api_key = "CNW36GIY5MY6I8W5"
79 | P a g e
def send_to_cloud(temp, hum):
url = "[Link] + api_key + \
"&field1=" + str(temp) + "&field2=" + str(hum)
try:
response = [Link](url)
print("Cloud response:", [Link])
[Link]()
except Exception as e:
print("Error sending:", e)
# ---------------------------
# Main Loop
# ---------------------------
while True:
try:
[Link]()
temperature = [Link]()
humidity = [Link]()
send_to_cloud(temperature, humidity)
except OSError as e:
print("Sensor timeout/error:", e)
RESULT:
.
80 | P a g e
EXP NO: 12
Design an IOT-based system
DATE
AIM:
To design a Smart Home Automation IOT-based system
PROCEDURE
1. Click on Thonny.
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on run.
81 | P a g e
CONNECTIONS:
PROGRAM:
"Connection to Blynk"
# Initialize Blynk
blynk = [Link](BLYNK_AUTH)
RESULT:
83 | P a g e