0% found this document useful (0 votes)
21 views79 pages

8051 Assembly & Arduino Programming Guide

The document outlines a series of experiments related to programming and interfacing with microcontrollers, specifically using 8051 Assembly Language, Embedded C, Arduino, and Raspberry Pi. It includes detailed procedures, aims, and results for each experiment, covering topics such as data transfer, ALU operations, and IoT communication methods. Additionally, it discusses the advantages of Arduino and ESP32 platforms, including installation steps for the ESP32 board in the Arduino IDE.

Uploaded by

radhalakshmi4422
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)
21 views79 pages

8051 Assembly & Arduino Programming Guide

The document outlines a series of experiments related to programming and interfacing with microcontrollers, specifically using 8051 Assembly Language, Embedded C, Arduino, and Raspberry Pi. It includes detailed procedures, aims, and results for each experiment, covering topics such as data transfer, ALU operations, and IoT communication methods. Additionally, it discusses the advantages of Arduino and ESP32 platforms, including installation steps for the ESP32 board in the Arduino IDE.

Uploaded by

radhalakshmi4422
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

DATE EXPERIMENTS PG

[Link] MARKS STAFF SIGN


NO

Write 8051 Assembly Language


1.
experiments using simulator.

Test data transfer between registers


2.
and memory

3. Perform ALU operations.

Write Basic and arithmetic Programs


4.
Using Embedded C.

Introduction to Arduino platform and


5.
programming

Explore different communication

6. methods with IoT devices (Zigbee,

GSM, Bluetooth)

Introduction to Raspberry PI platform


7.
and python programming

8. Interfacing sensors with Raspberry PI

Communicate between Arduino and

9. Raspberry PI using any wireless

medium

10. Setup a cloud platform to log the data

Log Data using Raspberry PI and


11.
upload to the cloud platform

12. Design an IOT based system


EXPNO:1 WRITE 8051 ASSEMBLY LANGUAGE EXPERIMENTS USING SIMULATOR.
DATE

AIM:
To write an 8051AssemblyLanguageprogramtomove a hexadecimal integer to the
Accumulator and validate the results in the register window using the Keil simulator.

PROCEDURE:
1. Createnewuvisionproject.
2. Selectthefolder (newlycreated) to savetheproject.
3. Savetheproject.
4. Selectthevendor “Atmel”anddevice“AT89C51”.
5. AdditionofSTARTUP.A51toprojectfolder.
6. STARTUP.A51isadded.
7. TypetheRequiredProgram.
8. SavetheProgram [Link].
9. Prgm.asmistobeaddedtoSourceGroup1.
10. Selectthefilenow it isadded toSourceGroup1.
11. Buildthetargetandthen debugthetarget.
12. Newwindowevaluationmodeappeared. Clickok
13. Verify the program output by clicking step option or [Link] can be viewed in
theregisterwindo
PROGRAM:
org 0000h
mov a, #2h
mov r0,#4h
mova,r0
end

OUTPUTSCREENSHOT:
RESULT:

Thus the 8051 Assembly language for an 8 bit Addition using Keil Simulator is executed
successfully.
EXPNO :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. Createnewuvisionproject.
2. Selectthefolder (newlycreated) to savetheproject.
3. Savetheproject.
4. Selectthevendor “Atmel”anddevice“AT89C51”.
5. AdditionofSTARTUP.A51toprojectfolder.
6. STARTUP.A51isadded.
7. TypetheRequiredProgram.
8. SavetheProgram [Link].
9. Prgm.asmistobeaddedtoSourceGroup1.
10. Selectthefilenow it isadded toSourceGroup1.
11. Buildthetargetandthen debugthetarget.
12. Newwindowevaluationmodeappeared. Clickok.
13. Modifythememoryaddressbyrightclickingattheparticularhexadecimalnumberandgivetheap
propriate datato thememoryaddress.
14. [Link]
owand in memorywindow at thebottom.
PROGRAM:
ORG 0000HMOV
R0,#40H
MOV R1,#50H
MOVR3,#03H
BACK:MOV A,@R0
MOVB,@R1
MOV @R0,B
MOV @R1,AINCR0
INCR1
DJNZ R3,BACK
END
SCREENSHOTASSIGNINGDATA IN MEMORYADDRESSOF40,41, 42&50,51, 52.

SCREENSHOTOFSWAPPINGOFDATA TRANSFER BETWEEN40&50


SCREENSHOTOFSWAPPINGOFDATA TRANSFER BETWEEN41&51.

SCREENSHOTOFSWAPPINGOFDATATRANSFERBETWEEN42 &52.
RESULT:
Thus the Assembly language Program to transfer data between register and memory was
executed successfully.
EXP NO:3 PERFORM ALU OPERATIONS.
DATE:
AIM:
To write an 8051 Assembly Language program and Perform ALU operations (Addition,
subtraction,Divisionand Multiplication) usingKeil simulator.

PROCEDURE:
1. Createnewuvisionproject.
2. Selectthefolder (newlycreated) to savetheproject.
3. Savetheproject.
4. Selectthevendor “Atmel”anddevice“AT89C51”.
5. AdditionofSTARTUP.A51toprojectfolder.
6. STARTUP.A51isadded.
7. TypetheRequiredProgram.
8. SavetheProgram [Link].
9. Prgm.asmistobeaddedtoSourceGroup1.
10. Selectthefilenow it isadded toSourceGroup1.
11. Buildthetargetandthen debugthetarget.
12. Newwindowevaluationmodeappeared. Clickok
13. Verify the program output by clicking step option or [Link] can be viewed in
theregister window and in memory window at the bottom (only for multiplication and
divisionoperations).
PROGRAM:

ADDITION SUBTRACTION

ORG ORG
0000HMOVA 000HMOV
,#40HMOV A,#40HMOV
B,#41HADD B,#41HSUBB
A,BMOV42H A,BMOV42H
,A ,A
END END
MULTIPLICATION DIVISION
ORG ORG
0000HMOVA, 000HMOV A,
#40HMOV B, #40HMOV B,
#41HMUL #41HDIVAB
ABMOV MOV
42H,AMOV 42H,AMOV
A,BMOV43H, A,BMOV43
A H,A
END END

OUTPUTSCREENSHOTOFADDITION
OUTPUTSCREENSHOTOFSUBTRACTION

OUTPUTSCREENSHOTOFMULTIPLICATION
OUTPUTSCREENSHOTOFDIVISION

RESULT:
Thus we executed the Perform ALU operations
EXPNO:4 WRITE BASIC AND ARITHMETIC PROGRAMS USING EMBEDDED C.
DATE:

AIM:
Towrite a basic arithmetic program (for performing Addition, subtraction, Division and
Multiplication) using Embedded C in Keil Simulator.
PROGRAM:
#
include<reg51.h>voidmain(v
oid)
{
unsigned charx,y,z,a,b,c; //define
variablesx=0x12; //first8-bitnumber
y=0x34; //second8-bitnumber
P0=0x00; //declareport0asoutputport
P1=0x00; //declareport1asoutputport
P2=0x00; //declareport2asoutputport
P3=0x00; //declareport3asoutputport
z=x+y; //performaddition
P0=z; //displayresult of addition on port 0
a=y-x; //performsubtraction
P1=a; //displayresultof subtraction onport 1
b=x*y; //performmultiplication
P2=b; //displayresultof multiplicationon port2
c=y/x; //performdivision
P3=c; // display result of division on port
3while(1);
}
PROCEDURE:
1. Createnewuvisionproject.
2. Selectthefolder (newlycreated) to savetheproject.
3. Savetheproject.
4. Selectthevendor “Atmel”anddevice“AT89C51”.
5. AdditionofSTARTUP.A51toprojectfolder.
6. STARTUP.A51isadded.
7. TypetheRequiredProgram.
8. [Link].
9. Prgm.CistobeaddedtoSourceGroup1.
10. Selectthefilenow it isadded toSourceGroup1.
11. Buildthetargetandthen debugthetarget.
12. Newwindowevaluationmodeappeared. Clickok
13. Verify the program output by clicking step option or [Link] can be viewed in
theregisterwindow
14. InperipheralsI/OPorts Port0displaysresultAddition
Port1displaysresultSubtraction
Port2displaysresultofmultiplication
Port3displaysresultofdivision
OUTPUTSCREENSHOTOFPARALLEL PORT0ADDITION

OUTPUTSCREENSHOTOFPARALLEL PORT1SUBTRACTION
OUTPUTSCREENSHOTOFPARALLEL PORT2MULTIPLICATION

OUTPUTSCREENSHOTOFPARALLEL PORT3DIVISION
RESULT:
Thus the Basic and arithmetic Programs Using Embedded C was Executed successfully.
INTRODUCTION TO ARDUINO PLATFORM AND PROGRAMMING

Arduino is an open-source electronics platform based on easy-to-use hardware and software.


Arduinoboardsare able to read inputs - light on a sensor, a finger on a button, or a Twitter message and turn
itinto an output - activating a motor, turning on an LED, publishing something online. You can tell yourboard
what to do by sending a set of instructions to the microcontroller on the board. To do so you usethe Arduino
programming language (based on Wiring), and the Arduino Software (IDE), based [Link] also
simplifies the process of working with microcontrollers, but it offers someadvantage forteachers, students,
andinterestedamateurs over other systems:

 Inexpensive-Arduinoboardsarerelativelyinexpensivecomparedtoothermicrocontrollerplatforms. The
least expensive version of the Arduino module can be assembled by hand, and eventhepre-assembled
Arduino modules costveryless.
 Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX,
andLinuxoperatingsystems. Most microcontroller systemsarelimited toWindows.
 Simple,clearprogrammingenvironment-TheArduinoSoftware(IDE)iseasy-to-useforbeginners, yet
flexible enough for advanced users to take advantage of as well. For teachers, it'sconveniently based
on the Processing programming environment, so students learning to program inthatenvironment will
be familiarwith how theArduinoIDEworks.
 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
tothe AVR C programming language on which it's based. Similarly, you can add AVR-C code
directlyintoyour Arduino programs ifyou wantto.
 Open source and extensible hardware - The plans of the Arduino boards are published under
aCreative Commons license, so experienced circuit designers can make their own version of
themodule, extending it and improving it. Even relatively inexperienced users can build the
breadboardversionofthe moduleinorder tounderstand howit works and savemoney.

ArduinoIDE:
A toolchain is a set of programming tools that is used to perform a complex set of [Link] the
Arduino Software (IDE) the toolchain is hidden from the user, but it is used to compile
[Link],assembler, linkerandStandardC&mathlibraries.
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.
ArduinoUNOboard
ScreenshotofArduinoIDE

ScreenshotofIDE’sStatusmessages
 Processing Power and Memory: The ESP32 is significantly more powerful and has more
memorythan the Arduino Uno. This makes it capable of handling more complex tasks and managing
multipleoperationssimultaneously.
 Operating Voltage: Arduino Uno operates at 5V, while the ESP32 operates at 3.3V. This
couldimpacttheselection ofcompatiblecomponents for your project.
 Built-in Connectivity: The ESP32 comes with built-in Wi-Fi and Bluetooth, making it an
excellentchoice for IoT projects. On the other hand, Arduino Uno doesn't have built-in connectivity,
but youcanadd thesecapabilities usingshields.
 Analog Input Pins: The ESP32 has more analog inputs, making it a better choice for
projectsrequiringmultiple analog sensors.
 EaseofUse:Arduinoisgenerallyconsideredeasiertogetstartedwithandhasavastcommunityandalot of
resources,which can behelpful forbeginners.

AdvantagesofESP32 overArduino:

 More Processing Power: ESP32 has a more powerful CPU. It features a dual-core
TensilicaXtensaLX6,whichcanrunupto240MHz,whiletheArduinoUnorunsanATmega328Pat16MHza
ndtheMegarunsan ATmega2560 at 16 MHz.
 More Memory: ESP32 comes with significantly more RAM (520KB) compared to typical
Arduinoboards(2KBfor Uno, 8KBfor Mega).This allows formore complexapplications.
 WirelessConnectivity:OneofthemajoradvantagesoftheESP32isthebuilt-inWi-FiandBluetooth 4.2
(including BLE), which is crucial for IoT projects. Arduino boards don't have built-
inwirelessconnectivity, requiringadditional components or shields.
 MoreGPIO:TheESP32hasmoregeneral-purposeinput/output(GPIO)pins,allowingittointerface with a
larger number of sensors and devices. The ESP32 has 34 GPIO pins, while theArduinoUno has 14,
andthe Megahas 54.
 Analog Inputs and Outputs: ESP32 has more analog input channels and also features two 8-
bitDACchannels, whichArduino Uno lacks.
 Lower Operating Voltage: ESP32 operates at a voltage of 3.3V, which is beneficial when
workingwithsensors ordevices that also operateat 3.3V.
 Deep Sleep Mode: The ESP32 has a deep sleep mode for power saving, consuming less than
10uA,whichmakes it abetter choiceforbattery-powered projects.

The choice between Arduino and ESP32 depends on the specific requirements of your project. For
simpletasks 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, theESP32 would beamore fittingchoice.

StepstoinstallESP32boardin [Link]:

 OpenyourArduinoIDE, thengotoFile>Preferences
 Enter[Link] the “Additional Board
ManagerURLs” field. Click OK
 GotoTools >Board >Boards Manager open theBoards Managers
 Search“ESP32”then pressinstallbutton for“ESP32by Espressif Systems”
 Inthe fewsecondsyour ESP32boardinstallationshouldbedone.

Now, we can go to the next step which is setting communication port, as ESP32 board has USB to
UARTconverter that needs to be installed for serial data communication between ESP32 and your
computer. Youmaywanttodownloaditfrom[Link]
drivers

Next,youshould:

 PlugESP32toyourcomputer
 OpenyourArduinoIDE, thengoTools>Boardmenu.
 SelecttheTypeofESPboardavailable.
EXP NO: INTRODUCTION TO ARDUINO PLATFORM AND PROGRAMMING
DATE:

AIM:
To write and execute different Arduino programming for analog, digital signals and serial
communication.

HARDWARE & SOFTWARE TOOLS REQUIRED:

[Link] Hardware & Software Requirements Quantity


1 Arduino IDE 2.0 1
2 Arduino UNO Development Board 1
3 Jumper Wires few
4 Arduino USB Cable 1

5 Joystick Module 1

PROCEDURE:
1. Give the connections as per the circuit diagram.
2. Connect the ESP32kitto PC using USB.
3. Type the program in the IDE compiler.
4. Verify the program by compiling and upload it to ESP32 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:

Arduino UNO Pin Arduino Development Board


2 LED
5 S1 (SW 1)

DIGITAL READ:
void setup() { pinMode(2,
OUTPUT);
pinMode(5, INPUT_PULLUP);
}
void loop() {
int sw=digitalRead(5);
if(sw==1)
{
for(int i=0; i<5; i++)
{
digitalWrite(2, HIGH);
delay(1000); digitalWrite(2,
LOW); delay(1000);
}
}
else
{
digitalWrite(2, LOW);
}
CONNECTION:

Arduino UNO Pin Arduino Development Board Joystick Module


2 LED
VCC or 5V +5V
GND GND
A0 VRx or VRy

ANALOG READ:
void setup() {
pinMode(2, OUTPUT);
[Link](9600);
}
void loop() {
int joystick=analogRead(A0);
[Link](joystick);

if(joystick>800)
digitalWrite(2, HIGH);
else
digitalWrite(2, LOW);

delay(500);
}
CONNECTION:

Arduino UNO Pin Arduino Development Board


3 LED

PWM Pins: 3, 5, 6, 9, 10, 11

ANALOG WRITE:
void setup() { pinMode(3,
OUTPUT);
}
void loop() {
for(int i=0; i<256;i++) {
analogWrite(3,i); delay(20);
}
for(int i=255; i>=0;i--) {
analogWrite(3,i); delay(20);
}
}
CONNECTION:

Arduino UNO Pin Arduino Development Board


4 LED

SERIAL COMMUNICATION:
void setup() {
[Link](9600);
pinMode(4, OUTPUT);
}

void loop() {
if([Link]()>0)
{
char data=[Link]();
[Link](data);
if(data=='1'){
digitalWrite(4,HIGH);
}
else if(data=='2'){
digitalWrite(4,LOW);
}
}
}
RESULT:
Thus the Arduino programming written for analog, digital signals and serial
communication was excuted.
EXP NO: 6 (a) EXPLORE DIFFERENT COMMUNICATION METHODS WITH IOT DEVICES
DATE : (BLUETOOTH)

AIM: To write a program to control an LED using a Bluetooth module.

HARDWARE & SOFTWARE TOOLS REQUIRED:

[Link] Hardware & Software Requirements Quantity


1 Arduino IDE 2.0 1
2 Arduino UNO Development Board 1
3 Jumper Wires few
4 Arduino USB Cable 1

5 HC-05 Bluetooth Module 1

PROCEDURE:

1. Connect the ESP 32kittoPC using USB.


2. Type the program in the IDE compiler.
3. Verify the program by compiling and upload it to ESP 32byselectingtheports.
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. Clickonthe„link‟icononthetoptoconnecttoESP32BluetoothDevice.
8. Now any commands or data can be sent from ESP 32 to external device that can be viewed in the
serial monitor.

CONNECTIONS:

Arduino UNO Pin Bluetooth Module Arduino Development Board


VCC 5V -
GND GND -
2 Tx -
3 Rx -
4 - LED
PROGRAM:

#include<SoftwareSerial.h> SoftwareSerial
mySerial(2,3); //rx,tx void setup() {
[Link](9600); [Link](9600);
pinMode(4, OUTPUT);
}

void loop() {
if([Link]()>0)
{
char data=[Link]();
[Link](data); if(data=='1'){
digitalWrite(4,HIGH);
[Link]("LED ON");
}
else if(data=='2'){
digitalWrite(4,LOW);
[Link]("LED OFF");
}
}
}
RESULT:
Thus a program has been written for connecting the Bluetooth of ESP32 controller to a external Bluetooth
device and it was implemented for sending and receiving data using Arduino IDE platform
EXP NO:6(B)
ZIGBEE COMMUNICATION
DATE

AIM:
To write a program to control an LED using a Zigbee module.

HARDWARE & SOFTWARE TOOLS REQUIRED:

[Link] Hardware & Software Requirements Quantity


1 Arduino IDE 2.0 1
2 Arduino UNO Development Board 2
3 Jumper Wires few
4 Arduino USB Cable 2

5 Zigbee Module 2

PROCEDURE

1. Connect the ESP 32kittoPC using USB.


2. Type the program in the IDE compiler.
3. Verify the program by compiling and upload it to ESP 32byselectingtheports.
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. Clickonthe„link‟icononthetoptoconnecttoESP32BluetoothDevice.
8. Now any commands or data can be sent from ESP 32 to external device that can be
viewed in the serial monitor.

CONNECTIONS:

TRANSMITTER:

Arduino UNO Pin Zigbee Module


VCC 5V
GND G
2 Tx
3 Rx
PROGRAM:
TRANSMITTER SIDE:

#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3); //rx,tx
void setup() {
[Link](9600);
[Link](9600);
}

void loop() {
[Link]('A');
[Link]('A');
delay(100);
[Link]('B');
[Link]('B');
delay(100);
}
CONNECTIONS:

RECEIVER:
Arduino UNO Pin Zigbee Module Arduino Development Board
- 5V 5V
- G GND
2 Tx -
3 Rx -
4 - LED1

RECEIVER SIDE:
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3); //rx,tx
void setup() {
[Link](9600);
[Link](9600);
pinMode(4, OUTPUT);
}

void loop() {
if([Link]()>0)
{
char data=[Link]();
[Link](data);
if(data=='A')
digitalWrite(4,HIGH);
else if(data=='B')
digitalWrite(4,LOW);
}
}
.

RESULT:
Thus a program has been written for connecting the zigbee of ESP32 controller to a
external zigbee device and it was implemented for sending and receiving data using Arduino
IDE platform
EXP NO: INTRODUCTION TO THE RASPBERRY PI
DATE PLATFORM

Introduction to Raspberry Pi Pico W:

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.

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.

GPIO and Peripherals:


Similar to the Raspberry Pi Pico, the Pico W offers a generous number of GPIO pins, providing
flexibility for interfacing with external components and peripherals. It features 26 GPIO pins, of
which 3 are analog inputs, and supports various protocols such as UART, SPI, I2C, and PWM. The
Pico W also includes onboard LED indicators and a micro-USB port for power and data
connectivity.

MicroPython and C/C++ Programming:


The Raspberry Pi Pico W can be programmed using MicroPython, a beginner-friendly
programming language that allows for rapid prototyping and development.
Programmable Input/Output (PIO) State Machines:
One of the unique features of the RP2040 microcontroller is the inclusion of Programmable Input/Output
(PIO) state machines. These state machines provide additional processing power and flexibility for
handling real-time data and timing-critical applications. The PIO state machines can be programmed to
interface with custom protocols, generate precise waveforms, and offload tasks from the main processor,
enhancing the overall performance of the system.

Open-Source and Community Support


As with all Raspberry Pi products, the Pico W benefits from the vibrant and supportive Raspberry Pi
community. Raspberry Pi provides extensive documentation, including datasheets, pinout diagrams, and
programming guides, to assist developers in understanding the board’s capabilities. The community offers
forums, online tutorials, and project repositories, allowing users to seek help, share knowledge, and
collaborate on innovative projects.

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.
EXP NO:
INTRODUCTION TO PYTHON PROGRAMMING
DATE

Getting Started with Thonny MicroPython (Python) IDE:


If you want to program your ESP32 and ESP8266 with MicroPython firmware, it’s very handy to
use an IDE. you’ll have your first LED blinking using MicroPython and Thonny IDE.

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 Micro Python was designed to work under
constrained conditions.

Because of that, Micro Python 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.
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.
A) Installing Thonny IDE – Windows PC
Thonny IDE comes installed by default on Raspbian OS that is used with the Raspberry Pi board.
To install Thonny on your Windows PC, follow the next instructions:
1. Go to [Link]
2. Download the version for Windows and wait a few seconds while it downloads.
3. Run the .exe file.

4. Follow the installation wizard to complete the installation process. You just need to click “Next”.

5. After completing the installation, open Thonny IDE. A window as shown in the following figure
should open.
CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


Pin Development Board
GP16 LED
PROGRAM

LED:
from machine import Pin
import time
LED = Pin(16, [Link])
while True:
[Link](1)
[Link](1)
[Link](0)
[Link](1)
CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


Pin Development Board
(RGB)
GP16 R
GP17 G
GP18 B
GND COM

RGB:
from machine import Pin
from time import sleep_ms,sleep
r=Pin(16,[Link])
y=Pin(17,[Link])
g=Pin(18,[Link])

while True:
[Link](1)
sleep_ms(1000)
[Link](0)
sleep_ms(1000)
[Link](1)
sleep(1)
[Link](0)
sleep(1)
[Link](1)
sleep(1)
[Link](0)
sleep(1)
CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


Pin Development Board
GP16 LED
GP15 SW1

PROGRAM:

SWITCH CONTROLLED LED:


from machine import Pin
from time import sleep
led=Pin(16,[Link])
sw=Pin(15,[Link])
while True:
bt=[Link]()
if bt== True:
print("LED ON")
[Link](1)
sleep(2)
[Link] (0)
sleep(2)
[Link] (1)
sleep(2)
[Link](0)
sleep(2)
else:
print("LED OFF")

sleep(0.5)
\

RESULT:
Thus the Raspberry Pi and phython program was studied and written.
EXP NO:
INTERFACING SENSORS WITH RASPBERRY PI
DATE

AIM:
To interface the IR sensor and Ultrasonic sensor with Raspberry Pi.

HARDWARE & SOFTWARE TOOLS REQUIRED:

[Link] Hardware & Software Requirements Quantity

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

CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


IR Sensor Module
Pin Development Board
GP16 BUZZER -
GP15 - OUT
- 5V VCC
- GND GND

PROGRAM:
IR Sensor:
from machine import Pin
from time import sleep
buzzer=Pin(16,[Link])
ir=Pin(15,[Link])
while True:
ir_value=[Link]()
if ir_value== True:
print("Buzzer OFF")
[Link](0)
else:
print("Buzzer ON")
[Link] (1)
sleep(0.5)
CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


Ultrasonic Sensor Module
Pin Development Board
GP16 BUZZER -
GP15 - ECHO
GP14 - TRIG
- 5V VCC
- GND GND
ULTRASONIC SENSOR:
from machine import Pin, PWM
import utime
trigger = Pin(14, [Link])
echo = Pin(15, [Link])
buzzer = Pin(16, [Link])

def measure_distance():
[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()

timepassed = signalon - signaloff


distance = (timepassed * 0.0343) / 2
return distance

while True:
dist = measure_distance()
print(f"Distance : {dist} cm")
if dist <= 10:
[Link](1)
[Link](0.01)
else:
[Link](0)
[Link](0.01)
[Link](0.5)
RESULT:
Thus the IR sensor and Ultrasonic sensor with Raspberry Pi was interfaced.
EXP NO: COMMUNICATE BETWEEN ARDUINO AND
DATE RASPBERRY PI

AIM:
To write and execute the program to Communicate between Arduino and Raspberry PI
using any wireless medium (Bluetooth)

HARDWARE & SOFTWARE TOOLS REQUIRED:

[Link] Hardware & Software Requirements Quantity

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

CONNECTIONS:

Arduino UNO Pin Arduino Development Board Bluetooth Module


2 - Tx
3 - Rx
- GND GND
- 5V 5V
PROGRAM:

MASTER
ARDUINO:
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3); //rx,tx
void setup() {
[Link](9600);
}

void loop() {
[Link]('A');
delay(1000);
[Link]('B');
delay(1000);
}
CS3691 EMBEDDED SYSTEMS AND IOT

CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


Bluetooth Module
Pin Development Board
GP16 LED -
VCC - +5V
GND - GND
GP1 - Tx
GP0 - Rx

SLAVE
RASPBERRY PI PICO
from machine import Pin, UART
uart = UART(0, 9600)
led = Pin(16, [Link])

while True:
if [Link]() > 0:
data = [Link]()
print(data)
if "A" in data:
[Link](1)
print('LED on \n')
[Link]('LED on \n')
elif "B" in data:
[Link](0)
print('LED off \n')
[Link]('LED off \n')
CS3691 EMBEDDED SYSTEMS AND IOT

RESULT:
Thus the program was written and to Communicate between Arduino and Raspberry PI
using any wireless medium was excuted.
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
CLOUD PLATFORM TO LOG THE DATA
DATE
AIM:
To set up a cloud platform to log the data from IoT devices.

HARDWARE & SOFTWARE TOOLS REQUIRED:

[Link]. Software Requirements Quantity

1 Blynk Platform 1

CLOUD PLATFORM-BLYNK:

Blynk is a smart platform that allows users to create their Internet of Things applications without
the need for coding or electronics knowledge. It is based on the idea of physical programming &
provides a platform to create and control devices where users can connect physical devices to the
Internet and control them using a mobile app.

Setting up Blynk 2.0 Application


To control the LED using Blynk and Raspberry Pi Pico W, you need to create a Blynk project and
set up a dashboard in the mobile or web application. Here’s how you can set up the dashboard:

Step 1: Visit [Link] and create a Blynk account on the Blynk website. Or you can simply
sign in using the registered Email ID.

Step 2: Click on +New Template.


CS3691 EMBEDDED SYSTEMS AND IOT

Step 3: Give any name to the Template such as Raspberry Pi Pico W. Select ‘Hardware Type’ as
Other and ‘Connection Type’ as WiFi.

So a template will be created now.


CS3691 EMBEDDED SYSTEMS AND IOT

Step 4: Now we need to add a ‘New Device’ now.

Select a New Device from ‘Template’.


CS3691 EMBEDDED SYSTEMS AND IOT

Select the device from a template that you created earlier and also give any name to the device.
Click on Create

A new device will be created. You will find the Blynk Authentication Token Here. Copy it as it
is necessary for the code
CS3691 EMBEDDED SYSTEMS AND IOT

Step 5: Now go to the dashboard and select ‘Web Dashboard’.


CS3691 EMBEDDED SYSTEMS AND IOT

To control the LED with a mobile App or Mobile Dashboard, you also need to setup the Mobile
Phone Dashboard. The process is similarly explained above.

Install the Blynk app on your smartphone The Blynk app is available for iOS and Android.
Download and install the app on your smartphone. then need to set up both the Mobile App and the
Mobile Dashboard in order to control the LED with a mobile device. The process is explained
above.

1. Open Google Play Store App on an android phone


CS3691 EMBEDDED SYSTEMS AND IOT
2. Open [Link]
3. Log In to your account (using the same email and password)
4. Switch to Developer Mode
5. Find the “Raspberry Pi Pico Pico W” template we created on the web and tap on it
6. Tap on the “Raspberry Pi Pico Pico W” template (this template automatically comes because we
created it on our dashboard).
7. tap on plus icon on the left-right side of the window
8. Add one button Switch
9. Now We Successfully Created an android template
10. it will work similarly to a web dashboard template
CS3691 EMBEDDED SYSTEMS AND IOT

RESULT:
Thus the cloud platform to log the data from IoT devices was settuped..
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO: LOG DATA USING RASPBERRY PI AND UPLOAD


DATE IT TO THE CLOUD
PLATFORM

AIM:
To write and execute the program Log Data using Raspberry PI and upload it to the cloud
platform

HARDWARE & SOFTWARE TOOLS REQUIRED:

[Link] Hardware & Software Requirements Quantity


1 Thonny IDE 1
2 Raspberry Pi Pico Development Board few
3 Jumper Wires 1

4 Micro USB Cable 1

CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


LCD Module
Pin Development Board
- 5V VCC
- GND GND
GP0 - SDA
GP1 - SCL
CS3691 EMBEDDED SYSTEMS AND IOT

PROGRAM:
from machine import Pin, I2C, ADC
from utime import sleep_ms
from pico_i2c_lcd import I2cLcd
import time
import network
import BlynkLib

adc = [Link](4)
i2c=I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
I2C_ADDR=[Link]()[0]
lcd=I2cLcd(i2c,I2C_ADDR,2,16)

wlan = [Link]()
[Link](True)
[Link]("Wifi_Username","Wifi_Password")

BLYNK_AUTH = 'Your_Token'

# connect the network


wait = 10
while wait > 0:
if [Link]() < 0 or [Link]() >= 3:
break
wait -= 1
print('waiting for connection...')
[Link](1)

# Handle connection error


if [Link]() != 3:
raise RuntimeError('network connection failed')
else:
print('connected')
ip=[Link]()[0]
print('IP: ', ip)

"Connection to Blynk"
# Initialize Blynk
CS3691 EMBEDDED SYSTEMS AND IOT

blynk = [Link](BLYNK_AUTH)

[Link]()
while True:
ADC_voltage = adc.read_u16() * (3.3 / (65536))
temperature_celcius = 27 - (ADC_voltage - 0.706)/0.001721
temp_fahrenheit=32+(1.8*temperature_celcius)
print("Temperature in C: {}".format(temperature_celcius))
print("Temperature in F: {}".format(temp_fahrenheit))

lcd.move_to(0,0)
[Link]("Temp:")
[Link](str(round(temperature_celcius,2)))
[Link]("C ")
lcd.move_to(0,1)
[Link]("Temp:")
[Link](str(round(temp_fahrenheit,2)))
[Link]("F")
[Link](5)

blynk.virtual_write(3, temperature_celcius)
blynk.virtual_write(4, temp_fahrenheit)
blynk.log_event(temperature_celcius)

[Link]()

[Link](5)
CS3691 EMBEDDED SYSTEMS AND IOT

RESULT:
Thus the the program was written and Log Data using Raspberry PI and upload it to the
cloud platform was excuted.
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
Design an IOT-based system
DATE

AIM:
To design a Smart Home Automation IOT-based system

HARDWARE & SOFTWARE TOOLS REQUIRED:

[Link] Hardware & Software Requirements Quantity


1 Thonny IDE 1
2 Raspberry Pi Pico Development Board few
3 Jumper Wires 1

4 Micro USB Cable 1

5 LED or Relay 1

CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


Pin Development Board
GP16 LED 1

PROGRAM:

import time
import network
import BlynkLib
from machine import Pin
CS3691 EMBEDDED SYSTEMS AND IOT

led=Pin(16, [Link])

wlan = [Link]()
[Link](True)
[Link]("Wifi_Username","Wifi_Password")
BLYNK_AUTH = 'Your_Token'

# connect the network


wait = 10
while wait > 0:
if [Link]() < 0 or [Link]() >= 3:
break
wait -= 1
print('waiting for connection...')
[Link](1)

# Handle connection error


if [Link]() != 3:
raise RuntimeError('network connection failed')
else:
print('connected')
ip=[Link]()[0]
print('IP: ', ip)

"Connection to Blynk"
# Initialize Blynk
blynk = [Link](BLYNK_AUTH)

# Register virtual pin handler


@[Link]("V0") #virtual pin V0
def v0_write_handler(value): #read the value
if int(value[0]) == 1:
[Link](1) #turn the led on
else:

[Link](0) #turn the led off


while True:
[Link]()
CS3691 EMBEDDED SYSTEMS AND IOT

RESULT:
Thus the Smart Home Automation IOT-based system was designed.
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

You might also like