EIOT Lab Manual (2024-2025)
EIOT Lab Manual (2024-2025)
LAB MANUAL
ODD SEMESTER
CS3691 EMBEDDED SYSTEMS AND IOT
PRACTICAL EXERCISES:
4. Enter the name for project and click Save in the dialogue box.
5. Select the target device(microcontroller) from Device for target ‘Target1’
dialogue, here I select 8051AH from Intel, then click Ok.
6. Select ‘Yes’ in the next pop-up, as we do not need this file in our project.
7. 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.
8. 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.
The workspace and project file are ready.
9. Write a program on the editor window and save it with .asm extension.
10. Add this source file to Group and click on “Build Target” or F7.
11. Go to debugging mode to see the result of simulation by clicking Run(F5)
or step run(F11).
1. Write 8051 Assembly Language experiments using simulator.
Aim:
Instruction set:
Exercise: What are the contents of registers A, R0, R7 and memory locations 30H
and 31H after the following code runs: -
MOV A, #5
MOV R7, #40H
MOV R0, #30H
MOV 31H, #14H
MOV @RO, A
INC R0
MOV A, @R0
Output:
RESULT:
2. Test data transfer between registers and memory.
Aim:
To write an assembly language program to transfer data between registers
and memory.
Algorithm:
Transfer data fro ROM to RAM through Memory
1. Initialize address for ROM in data pointer, address RAM in registers R0
and register R7 as counter.
2. Store the data values in data block db.
3. loop, until read all the data from data block
a. Move the data from ROM to register.
b. Move the data from register to RAM.
c. Increment data pointer and R0 for read next data in data block.
d. Clear the accumulator for read next data.
e. Decrement the count.
Program:
org 0000h
mov dptr,#600h //initialize address for ROM
mov r0,#60h //initialize address for RAM
mov r7,#06 //initialize counter
back:movc a,@a+dptr
mov @r0,a
inc dptr
inc r0
clr a
djnz r7,back
org 600h
db 23h,34h,46h,54h,62h,75h
end
Output:
For, first data from the data block are read and move to accumulator as
given above. Similarly for all data move through accumulator and stored
in memory.
RESULT:
3. Perform ALU operations.
Aim:
To write an assembly language program to perform arithmetic and logic
operation in 8051 microcontrollers.
Algorithm:
1.ARITHMATIC OPERATION
Addition:
1) Move data1 to register/Accumulator
2) Move data2 to register/Accumulator
3) Add two data using ADD instruction
4) Move the resultant value in the address of 40H in memory.
Subtraction:
1) Move data1 to register/Accumulator
2) Move data2 to register/Accumulator
3) Subtract value of data2 from value of Data1 using SUB instruction
4) Move the resultant value in the address of 41H in memory.
Multiplication:
1) Move data1(Multiplicand) to register/Accumulator
2) Move data2(Multiplier) to register/Accumulator
3) Multiply two data using MUL instruction
4) Store the LSB from resultant value in the address of 42H in memory using
MOV instruction.
5) Store the MSB from resultant value in the address of 43H in memory using
MOV instruction.
Division:
1) Move data1(Dividend) to register/Accumulator
2) Move data2(Divider) to register/Accumulator
3) Divide them by using DIV instruction
4) Store the quotient from resultant value in the address of 44H in memory
using MOV instruction.
5) Store the reminder from resultant value in the address of 45H in memory
using MOV instruction.
PROGRAM:
//ADDITION
MOV A,#25H
MOV B,#12H
ADD A,B
MOV 40H,A
//SUBTRACTION
MOV A,#25H
SUBB A,B
MOV 41H,A
//MULTIPLICATION
MOV A,#25H
MUL AB
MOV 42H,A
MOV 43H,B
//DIVISION
MOV A,#25H
DIV AB
MOV 44H,A
MOV 45H,B
MOV A,#25H
INC A
MOV 46H,A
MOV A,#25H
DEC A
MOV 47H,A
END
OUTPUT:
2.LOGICAL OPERATION
AND:
1) Move data1 to register/Accumulator
2) Move data2 to register/Accumulator
3) Perform logical AND operation between the two data using ANL
instruction
4) Move the resultant value in the address of 20H in memory.
OR:
1) Move data1 to register/Accumulator
2) Move data2 to register/Accumulator
3) Perform logical OR operation between the two data using ORL instruction
4) Move the resultant value in the address of 21H in memory.
XOR:
1) Move data1 to register/Accumulator
2) Move data2 to register/Accumulator
3) Perform logical XOR operation between the two data using XRL
instruction
4) Move the resultant value in the address of 22H in memory.
NOT:
1) Move data1 to register/Accumulator
2) Perform logical NOT operation to get compliment of the data using CPL
instruction
3) Move the resultant value in the address of 23H in memory.
PROGRAM:
//AND
MOV A,#45H
MOV B,#67H
ANL A,B
MOV 20H,A
//OR
MOV A,#45H
ORL A,B
MOV 21H,A
//XOR
MOV A,#45H
XRL A,B
MOV 22H,A
//NOT
MOV A,#45H
CPL A
MOV 23H,A
END
OUTPUT:
RESULT:
4. Write Basic and arithmetic Programs Using Embedded C.
AIM:
To write an Arithmetic program to add, Subtract, multiply and divide two
8-bit numbers using C Programming for 8051 microcontroller.
ALGORITHM:
PROGRAM:
# include<reg51.h> void main(void)
{
unsigned char x,y,z, a,b,c, d,e,f, p,q,r; //define variables
//addition
x=0x03; //first 8-bit number
y=0x04; //second 8-bit number
P0=0x00; //declare port 0 as output port
z=x+y; // perform addition
P0=z; //display result on port 0
//subtraction
a=0x03; //first 8-bit number
b=0x04; //second 8-bit number
P1=0x00; //declare port 1 as output port
c=b-a; // perform subtraction
P1=c; //display result on port 1
//multiplication
d=0x03; //first 8-bit number
e=0x04; //second 8-bit number
P2=0x00; //declare port 2 as output port
f=e*d; // perform multiplication
P2=f; //display result on port 2
//division
p=0x03; //first 8-bit number
q=0x04; //second 8-bit number
P3=0x00; //declare port 3 as output port
r=q/p; // perform division
P3=r; //display result on port 3
while(1);
}
OUTPUT:
PORT0
PORT1
PORT2
PORT3
RESULT:
EXP NO:
INTRODUCTION TO THE ARDUINO PLATFORM
DATE
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.
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.
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.
The Arduino IDE 2.0 is an open-source project, currently in its beta-phase. It is a big step from it'ssturdy
predecessor, Arduino IDE 2.0, and comes with revamped UI, improved board & librarymanger,
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 alsofind
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: https://www.arduino.cc/en/software
To install the Arduino IDE 2.0 on a Windows computer, simply run the file downloaded from the
software page.
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. Inthis
quick tutorial, we will take a look at how to install one, and choosing the right core for yourboard!
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 whatis 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 ArduinoNano
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.
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.
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 startusing
your Arduino board!
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 thistutorial,
we will go through how to select a board connected to your computer, and how to uploada 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 toolsimply
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 quickway
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, thereis a
checkmark and an arrow pointing right. The checkmark is used to verify, and thearrow 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).
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 aresome
complications when uploading, and these errors will be listed here as well.
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 librariescan be
found online, and the best-documented ones can be found and installed directly through theeditor. In this
tutorial, we will go through how to install a library using the library manager in theArduino 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 interfacewith
many different sensors, RTCs, Wi-Fi modules, RGB matrices and of course with othercomponents
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.
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.
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.
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 accessiblethrough
File > Examples > {Library} > {Example}. In this example, we are choosing the RTCZero >
SimpleRTC.
The chosen example will now open up in a new window, and you can start using it however you want
to.
RESULT:
EXP NO:
INTRODUCTION TO ARDUINO PROGRAMMING
DATE
AIM:
To write and execute different Arduino programming for analog, digital signals and serial
communication.
5 Joystick Module 1
PROCEDURE:
DIGITAL WRITE:
CONNECTION:
DIGITAL WRITE:
void setup()
{
pinMode(2, OUTPUT);
}
void loop()
{
digitalWrite(2, HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);
}
DIGITAL READ
CONNECTION:
ANALOG READ:
void setup()
{
pinMode(2, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int joystick=analogRead(A0);
Serial.println(joystick);
if(joystick>800)
digitalWrite(2, HIGH);
else
digitalWrite(2, LOW);
delay(500);
}
ANALOG WRITE:
CONNECTION:
PROGRAM
ANALOG WRITE:
void setup()
{
pinMode(3, OUTPUT);
}
void loop()
{
for(int i=0; i<256;i++)
{
analogWrite(3,i);
delay(15);
}
for(int i=255; i>=0;i--)
{
analogWrite(3,i);
delay(15);
}
}
SERIAL COMMUNICATION
CONNECTION:
SERIAL COMMUNICATION:
void setup()
{
Serial.begin(9600);
pinMode(0, OUTPUT);
}
void loop()
{
if(Serial.available()>0)
{
char data=Serial.read();
if(data=='1')
{
Serial.println(data);
digitalWrite(0,HIGH);
}
else if(data=='2')
{
digitalWrite(0,LOW);
}
}
}
RESULT:
EXP NO: Different communication methods with IoT devices
DATE (Zigbee, GSM, Bluetooth)
AIM:
To Explore different communication methods with IoT devices (Zigbee, GSM, Bluetooth).
Zigbee:
Zigbee is a low-power wireless communication protocol designed for short-range communication
between devices. It operates on the 2.4 GHz frequency band and supports mesh networking, allowing
devices to communicate with each other through intermediate nodes. Zigbee is commonly used in home
automation, industrial control, and smart energy applications.
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.
EXP NO:
BLUETOOTH COMMUNICATION
DATE
AIM:
To write a program to control an LED using a Bluetooth module.
PROCEDURE
CONNECTIONS:
PROGRAM:
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3); //rx,tx void
setup() { mySerial.begin(9600);
Serial.begin(9600);
pinMode(4, OUTPUT);
}
void loop() {
if(mySerial.available()>0)
{
char data=mySerial.read();
Serial.println(data); if(data=='1'){
digitalWrite(4,HIGH);
Serial.println("LED ON");
}
else if(data=='2'){
digitalWrite(4,LOW);
Serial.println("LED OFF");
}
}
RESULT:
EXP NO:
ZIGBEE COMMUNICATION
DATE
AIM:
To write a program to control an LED using a Zigbee module.
5 Zigbee Module 2
PROCEDURE
CONNECTIONS:
TRANSMITTER:
PROGRAM: TRANSMITTER
SIDE:
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3); //rx,tx void
setup() {
mySerial.begin(9600);
Serial.begin(9600);
}
void loop() {
mySerial.write('A'); Serial.println('A'); delay(100); mySerial.write('B'); Serial.println('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() {
mySerial.begin(9600);
Serial.begin(9600); pinMode(4,
OUTPUT);
}
void loop() {
if(mySerial.available()>0)
{
char data=mySerial.read();
Serial.println(data);
if(data=='A')
digitalWrite(4,HIGH); else
if(data=='B')
digitalWrite(4,LOW);
}
}
RESULT:
EXP NO: INTRODUCTION TO THE RASPBERRY PI
DATE 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.
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.
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.
RESULT:
EXP NO:
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.
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.
5. After completing the installation, open Thonny IDE. A window as shown in the following figure
should open.
ONNECTIONS:
PROGRAM
LED:
from machine import Pin import
time
LED = Pin(16, Pin.OUT)
while True:
LED.value(1)
time.sleep(1)
LED.value(0)
time.sleep(1)
CONNECTIONS:
PROGRAM
RGB:
from machine import Pin
from time import sleep_ms,sleep
r=Pin(16,Pin.OUT) y=Pin(17,Pin.OUT)
g=Pin(18,Pin.OUT)
RESULT:
EXP NO:
INTERFACING SENSORS WITH RASPBERRY PI
DATE
AIM:
To interface the IR sensor and 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
CONNECTIONS:
PROGRAM:
IR Sensor:
from machine import Pin from
time import sleep
buzzer=Pin(16,Pin.OUT)
ir=Pin(15,Pin.IN)
while True:
ir_value=ir.value() if
ir_value== True:
print("Buzzer OFF")
buzzer.value(0)
else:
print("Buzzer ON")
buzzer.value (1)
sleep(0.5)
CONNECTIONS:
ULTRASONIC SENSOR:
from machine import Pin, PWM import
utime
trigger = Pin(14, Pin.OUT) echo
= Pin(15, Pin.IN) buzzer =
Pin(16, Pin.OUT)
def measure_distance():
trigger.low()
utime.sleep_us(2)
trigger.high()
utime.sleep_us(5)
trigger.low()
while echo.value() == 0: signaloff =
utime.ticks_us()
while echo.value() == 1: signalon =
utime.ticks_us()
while True:
dist = measure_distance()
print(f"Distance : {dist} cm") if dist
<= 10:
buzzer.value(1)
utime.sleep(0.01)
else:
buzzer.value(0)
utime.sleep(0.01)
utime.sleep(0.5)
RESULT:
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)
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
CONNECTIONS:
MASTER
ARDUINO:
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3); //rx,tx void
setup() {
mySerial.begin(9600);
}
void loop() {
mySerial.write('A');
delay(1000);
mySerial.write('B');
delay(1000);
}
CONNECTIONS:
while True:
if uart.any() > 0: data =
uart.read() print(data)
if "A" in data: led.value(1)
print('LED on \n')
uart.write('LED on \n')
elif "B" in data: led.value(0)
print('LED off \n')
uart.write('LED off \n')
RESULT:
EXP NO:
CLOUD PLATFORM TO LOG THE DATA
DATE
AIM:
To set up a cloud platform to log the data from IoT devices.
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.
Step 1: Visit blynk.cloud and create a Blynk account on the Blynk website. Or you can simply sign in
using the registered Email ID.
A new device will be created. You will find the Blynk Authentication Token Here. Copy it as it is
necessary for the code.
Step 5: Now go to the dashboard and select ‘Web Dashboard’.
From the widget box drag a switch and place it on the dashboard screen.
Step 6:
On the switch board click on Settings and here you need to set up the Switch. Give any title to it and
Create Datastream as Virtual Pin.
Configure the switch settings as per the image below and click on create.
Configure the final steps again.
With this Blynk dashboard set up, you can now proceed to program the Raspberry Pi Pico W board to
control the LED.
Step 7:
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.
RESULT:
EXP NO: 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
CONNECTIONS:
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 = machine.ADC(4)
i2c=I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
I2C_ADDR=i2c.scan()[0]
lcd=I2cLcd(i2c,I2C_ADDR,2,16)
wlan = network.WLAN()
wlan.active(True)
wlan.connect("Wifi_Username","Wifi_Password")
BLYNK_AUTH = 'Your_Token'
# connect the network wait
= 10
while wait > 0:
if wlan.status() < 0 or wlan.status() >= 3: break
wait -= 1
print('waiting for connection...')
time.sleep(1)
"Connection to Blynk"
# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
lcd.clear()
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)
lcd.putstr("Temp:")
lcd.putstr(str(round(temperature_celcius,2)))
lcd.putstr("C ")
lcd.move_to(0,1)
lcd.putstr("Temp:")
lcd.putstr(str(round(temp_fahrenheit,2))) lcd.putstr("F")
time.sleep(5)
blynk.virtual_write(3, temperature_celcius)
blynk.virtual_write(4, temp_fahrenheit)
blynk.log_event(temperature_celcius)
blynk.run()
time.sleep(5)
RESULT:
EXP NO:
Design an IOT-based system
DATE
AIM:
To design a Smart Home Automation IOT-based system
5 LED or Relay 1
PROCEDURE
CONNECTIONS:
wlan = network.WLAN()
wlan.active(True)
wlan.connect("Wifi_Username","Wifi_Password")
BLYNK_AUTH = 'Your_Token'
"Connection to Blynk"
# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
RESULT:
EXTRA PROGRAMS
LCD DISPLAY:
Connection
while True:
for position in range(1000,9000,50):
pwm.duty_u16(position) sleep(0.01)
for position in range(9000,1000,-50):
pwm.duty_u16(position) sleep(0.01)
Connection
sequence = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
while True:
for step in sequence:
for i in range(len(pins)): pins[i].value(step[i])
sleep(0.001)
Connection