Lab Manual
Lab Manual
LAB MANUAL
NAME : DINESH P
DEPARTMENT : CSE
REGULATION : 2021
PRACTICAL EXERCISES:
11. Log Data using Raspberry PI and upload to the cloud platform
30 PERIODS
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
ALGORITHM
Step 2: Set P1.0 HIGH, Set P1.0 = 1 (Turn ON LED or send HIGH
output). Step 3: Call Delay Subroutine, Call the Delay function to introduce
a delay.
Step 4: Set P1.0 LOW, Clear P1.0 = 0 (Turn OFF LED or send LOW
output).
Step 5: Call Delay Subroutine Again, Call the Delay function again to introduce a
delay.
Step 6: Repeat the Process Infinitely, Jump back to Step 2 to continue toggling P1.0.
Step 10: Once both counters reach 0, return to the main program.
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
PROGRAM
ORG 0H
START:
SETB
P1.0
CALL
Delay CLR
P1.0
CALL
Delay
SJMP
START
Delay:
MOV R2, #5
DelayLoop1:
MOV R1, #5
DelayLoop2:
NOP
DJNZ R1,
DelayLoop2
DJNZ R2,
DelayLoop1 RET
END
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
Output
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
RESULT
Thus the LED Blinking Assembly Language Program has been executed and verified
using Edsim51d Simulator
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
AIM:
Write an Assembly language programming for 8-bit Arithmetic operations using Edsim51d
simulator
ALGORITHM
➢ Clear carry.
➢ Load accumulator A with any desired 8-bitdata.
➢ Add accumulator with 8-bitnumbers.
➢ Store the result using DPTR.
➢ Stop the program.
➢ Clear carry.
➢ Load accumulator A with any desired 8-bitdata.
➢ Subtractaccumulatorwith8-bitnumbers.
➢ Store the result using DPTR.
➢ Stop the program.
Addition program
MOV A, #07
MOV B, #03 ADD A, B MOV R0,A
HERE: SJMP HERE
Subtract program
MOV A, #07
MOV B, #03 SUBB A, B MOV R1,A
HERE: SJMP HERE
Multiplication program
MOV A,#0FFH MOV B,#03 MUL AB
MOV R3,A MOV R4,B
HERE: SJMP HERE
Division program
MOV A,#13 MOV B,#03 DIV AB MOV R3,A
MOV R4,B
HERE: SJMP HERE
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
Output:
Addition Program
Subtraction Program
R1 = 04H (Decimal 4)
Multiplication Program
R4 = 02H (Decimal 2)
Division Program
RESULT
Thus the 8051 Assembly Language program for 8-bit Arithmetic operations is executed and
verified using Edsim51d simulator
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
Simulator
AIM:
To perform an Assembly Language logical operation Program using 8051
Microcontroller AND, OR &EX-OR.
ALGORITHM
OR OPERATION PROGRAM
CLR C
MOV A, #07
ORL A, #03
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
MOV R1, A
HERE: SJMP HERE
XOR OPERATION PROGRAM
CLR C
MOV A, #07
XRL A, #03 MOV R2, A
HERE: SJMP HERE
Output:
1. AND Operation
R0 = 03H (Decimal 3)
2. OR Operation
R1 = 07H (Decimal 7)
3. XOR Operation
R2 = 04H (Decimal 4)
4. 1’s Complement
5. 2’s Complement
RESULT
Thus the 8051 Assembly Language program for AND, OR & EX-OR.is executed and
verified Using Edsim51d Simulator
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
AIM:
APPARATUS REQUIRED:
ALGORITHM
PROGRAM
ORG 00H
MOV A, #54H
MOV 01H, A
MOV R2, A
MOV 07H, A
MOV R1, #00H
MOV 02H,#00H
|HALT: SJMP HALT
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
OUPUT
A(ACCCUMULATO 54
R)
R2 54
R1 0
01H(RAM) 54
07H(RAM) 54
02H(RAM) 0
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
RESULT
Thus the 8051 Assembly Language program for data transfer between registers and
memory Program has been executed and verified Using Edsim51d Simulator
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
AIM:
To write an Assembly Language program to compare two numbers in 8051 using stimulator.
ALGORITHM:
PROGRAM:
ORG
0000H;
MOV
A,#10H;
MOV
B,#15H;
CJNE
A,B,NOT_EQUAL
; SJMP
END_PROGRAM;
NOT_EQUAL;
END_PROGRAM;
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
Output
RESULT:
Thus the comparison 2 numbers in Assembly Language program using stimulator has been
done successfully and executed
Department of Computer Science and
Engineering Anjalai Ammal-Mahalingam
Engineering College Kovilvenni-614 403
(NAAC Accredited with B Grade)
Algorithm
EMBEDDED C PROGRAM
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=0x12; //first 8-bit number
y=0x34; //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=0x12; //first 8-bit number
b=0x34; //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=0x12; //first 8-bit number
e=0x34; //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=0x12; //first 8-bit number
q=0x34; //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
Operation Hex Calculation Decimal Output Port
Calculation
Addition 0x12 + 0x34 = 0x46 18 + 52 = 70 P0 = 0x46 (70)
Subtraction 0x34 - 0x12 = 0x22 52 - 18 = 34 P1 = 0x22 (34)
Multiplication 0x12 * 0x34 = 0x03E8 18 * 52 = 936 P2 = 0xE8 (Last byte of 936)
Division 0x34 / 0x12 = 0x02 52 / 18 = 2 P3 = 0x02 (2)
RESULT:
Thus the basic arithmetic operations like addition, subtraction, multiplication and division
has been executed and verified Using Keil uVision5 Software
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
Algorithm
EMBEDDED C PROGRAM
#include <reg51.h>
void main(void)
{
// Perform bitwise operations and assign to ports
Output
RESULT:
Thus the logical operations Embedded C Program has been executed and verified Using
Keil uVision5 Software
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
AIM:
To study the basics of Arduino Unoboard and Arduino IDE 2.0 software.
Introduction to Arduino
Arduino is an open-source hardware and software platform widely used for designing
and developing electronic devices. It offers microcontroller-based kits and single-board
interfaces, making it easier to build various electronics projects. Initially developed to
support students without a technical background, Arduino has now become a popular
tool among hobbyists, educators, and professionals.
Arduino boards are built using different microcontrollers and processors, depending on
the type and purpose of the board. One of the main advantages of Arduino is its
simplicity and ease of use, which makes electronics more accessible to beginners and
non-engineers.
The Arduino UNO is the most commonly used and popular board, primarily because of its
reliable ATmega328 microcontroller. Different Arduino boards are available to suit various
project requirements. These boards are programmed using the Arduino IDE (Integrated
Development Environment), which is compatible with multiple operating systems.
TYPESOFARDUINO BOARDS
1) Arduino UNO
The Arduino UNO is one of the most commonly used and standard boards in the Arduino
family.It is based on the ATmega328P microcontroller.Compared to other boards like the
Arduino Mega, it is simpler and more beginner-friendly.The board includes 14 digital
input/output pins and 6 analog input pins.It also features a USB connector, a power jack, and
an ICSP (In-Circuit Serial Programming) header. Because of its ease of use and reliability, the
Arduino UNO remains the most popular choice among all Arduino boards.
2) Arduino Nano
The Arduino Nano is a compact Arduino board based on the ATmega328P or ATmega628
microcontroller.It offers the same connectivity features as the Arduino UNO board.
The Nano is known for being a sustainable, compact, reliable, and versatile micro controller
board. Compared to the UNO, it is smaller in size, making it ideal for space-constrained
projects. To begin working with the Arduino Nano, you need the Arduino IDE and a mini-
USB cable. The board features a set of 14 digital input/output pins and 8 analog
input pins. It also includes 6 power pins and 2 reset pins for additional functionality.
3) Arduino Mega
The Arduino Mega is a powerful board based on the ATmega2560 microcontroller. The
ATmega2560 is an 8-bit microcontroller that offers enhanced performance and more features.To
get started, a simple USB cable is used to connect the board to a computer, along
with an AC to DC adapter or a battery for power supply.One of the main advantages of the
Arduino Mega is its larger memory capacity, making it suitable for more complex projects. The
board features 54 digital input/output (I/O) pins, 16 analog input/output pins, an ICSP (In-Circuit
Serial Programming) header, and a reset button for added functionality.
4) Arduino Micro
The basic specification of the Arduino Leonardo is the same as the Arduino Micro. It is also
based on the ATmega 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.
5. Arduino Due
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.
6) Arduino Lilypad
The Arduino LilyPad was initially created for wearable projects and e-textiles. It is based on
the ATmega168Microcontroller.The functionality of Lilypad is the same as other Arduino
Boards.It is around, light weight board with a minimal number of components to keep the size
of the board small. The Arduino Lilypad board was designed by Spark fun and Leah. It was
developed by LeahBuechley. It has 9 digital I/O pins.
7) Arduino Bluetooth
The Arduino Bluetooth board is based on ATmega 168 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.
8) 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 are set 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 Diecimil a was initially developed to mark the10000 delivered boards of
Arduino.Here,Diecimila means10,000 in Italian.
9) Arduino Robot
The Arduino Robotis called as the tiny computer. It is widely used in robotics. The board
comprises of the speaker, five-button, color screen, two motors, an SD card reader, a digital
compass, two potentiometers, and five floor sensors. The Robot Library can be used to contr ol
the actuators and the sensors.
10) 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.
The Arduino Zero is generally called as the 32-bit extension of the Arduino UNO. It is based
on ATmel's SAM21 MCU. The board consists of 6 analog pin inputs, 14 digital Input
Output pins, a USB connector ,a power jack, and an ICSP(In-Circuit Serial Programming)
header, UART port pins, a power header, and AREF button. The Embedded debugger of
Atmel is also supported by the Arduino Zero. The function of Debugger is to provide a full
debug interface, which does not require additional hardware.
12) 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.
13) Arduino Pro Micro
The structure of Arduino Pro Micro is similar to the Arduino Mini board, except the
Microcontroller ATmega 32U4. The board consists of 12digital Input/output pins, 5
PWM(Pulse Width Modulation) pins, Tx and Rx serial connections, and 10-bit ADC (Analog
to Digital Converter).
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
The Arduino IDE 2.0 is the latest and improved version of the Arduino Integrated Development
Environment (IDE), designed to provide a more powerful and user-friendly interface for coding,
compiling, and uploading programs to Arduino boards.
Unlike the classic Arduino IDE, version 2.0 comes with several enhanced features aimed at
improving the overall development experience for both beginners and advanced users. It
combines the simplicity of the original IDE with modern functionalities, making it more
efficient and feature-rich.
Arduino IDE 2.0 is built using Eclipse Theia, a modern open-source framework, and offers a
more responsive and intuitive interface. It is available for Windows, macOS, and Linux, and
supports a wide range of Arduino boards.
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.
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
Result
Thus the study of various Arduino board types was studied Arduino IDE 2.0 software
was successfully installed.
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
AIM:
To write a LED Blink Program using Arduino Kit
ALGORITHM
Use delay(1000); to keep the LED OFF for 1 second before repeating the cycle.
PROGRAM
void setup()
{
pinMode(2, OUTPUT);
}
void loop() {
digitalWrite(2,
HIGH); delay(1000);
digitalWrite(2,
LOW); delay(1000);
}
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
Output
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
Result
The LED Blink program was successfully executed and verified using the Arduino board.
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
AIM:
To write a LED Fade Program using Arduino Kit
Procedure
Write the current brightness value to the LED pin using analogWrite() function.
Increment the brightness value by the fade amount.
Check the brightness limits:
o If brightness is ≤ 0 or ≥ 255, reverse the fade direction by changing the
sign of fadeAmount.
Wait for 30 milliseconds using delay()to visualize the fade effect.
Repeat the loop continuously.
5) End.
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
Program
/*
LED Fade Program
void setup()
{
pinMode(led, OUTPUT); // Set the LED pin as OUTPUT
}
void loop()
{
analogWrite(led, brightness); // Set LED brightness using PWM
Output
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)
Result
The LED Fade program was successfully executed and verified using the Arduino board.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
AIM:
To communicate with Arduino using Bluetooth model.
APPARATUS REQUIRED:
Arduino Development Board
Arduino IDE Software
Bluetooth Module
BLUETOOTH MODULE:
HC-05 is a Bluetooth device used for wireless communication with Bluetooth enabled devices
(like smartphone). It communicates with microcontrollers using serial communication (USART).
There is a simple example of establishing a serial connection between the HC-05 and the Smart
Phone and send/receive message.
We will use pins 2and 3 of the Arduino to connect the HC-05 and use the Software Seria l library
to communicate with the module. The Hardware serial port on arduino is used to send/receive
messages from the computer to the Arduino.
paired,the LED on HC05 module will blink intermittently. To pair: Go to the smartphone
Bluetooth settings and find nearby available Bluetooth devices. In this list you will find HC05,
select it and then it requires a password which is by default set as 1234 or 0000 enter the password
2) Go to Google Play store and download the “Bluetooth terminal” app from it
3) Open the Bluetooth terminal app and search for the paired device and select it. Now, click on
the connect button that appears on the top right of your screen. Wait for the 5 seconds till you get
Now you just need to send data from the app which will be transmitted by phones BT through the
antenna and received by the HC05 antenna then HC05 transmit this data from its Tx to RX of the
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
arduino, but data should be a character (integers are also characters in ASCII) not string here the
Serial.print() will transmit data from Arduino Tx to Rx of BT and then BT transmits it to the
smartphone through its antenna and that’s how the two-way communication works.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
PROGRAM:
#include<SoftwareSerial.h>
/* Create object named bt of the class SoftwareSerial */
SoftwareSerial bt(2,3); /* (Rx,Tx) */
void setup() {
bt.begin(9600); /* Define baud rate for software serial communication */
Serial.begin(9600); /* Define baud rate for serial communication */
}
void loop() {
if (bt.available()) /* If data is available on serial port */
{
Serial.write(bt.read()); /* Print character received on to the serial
monitor */
}
}
Output
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
RESULT:
Thus the communication was established between Arduino and Bluetooth Module. The data is
transmitted from Bluetooth to Arduino.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
AIM:
APPARATUS REQUIRED:
Arduino Development Board
Arduino IDE Software
Zigbee modules
ZIGBEE MODULE:
Zigbee is a wireless communication protocol targeted for battery powered devices (it has both
low
power and low cost). It generally operates in the 2.4GHz range and supports data ranges from 20 to
250kbits/s. Digi International developed the XBee modules, a family of wireless communication
devices. These modules support various wireless communication protocols, including Zigbee, Wi-
Fi, and cellular, and they can communicate over UART (Universal Asynchronous Receiver-
Transmitter) interfaces. These modules utilize Zigbee communication, which is a low-power
wireless communication protocol commonly used in home automation, industrial control, and
sensor networks. XBee Zigbee modules are capable of forming mesh networks, making them
suitable for applications where reliability and long-range communication are essential.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Program
#include <SoftwareSerial.h>
SoftwareSerial zigbeeSerial(2, 3); // RX (pin 1), TX (pin 2)
void setup()
{
// Initialize the Hardware Serial interface (usually connected to your
computer)
Serial.begin(9600); // Use the appropriate baud rate
// Initialize the Software Serial interface (for the Zigbee module)
zigbeeSerial.begin(9600); // Use the same baud rate as your Zigbee module
}
void loop()
{
// Read data from Zigbee
}
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
}
if (zigbeeSerial.available())
{
char receivedChar = zigbeeSerial.read();
Serial.print("Received: ");
Serial.println(receivedChar); // Print received data to the Serial Monitor
}
// Send data to Zigbee
zigbeeSerial.print("Hello, Zigbee!"); // Send a message to the Zigbee module
delay(1000); // Add a delay to control message
transmission rate
}
OUTPUT:
e
l
l
o
zigbee…
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
RESULT:
Thus the communication was established between Arduino and Zigbee Module. The data is
transmitted from Zigbee to Arduino.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
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,
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
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Raspberry Pi Pico W:
The Raspberry Pi Pico W is based on the RP2040 microcontroller, which was designed by
Raspberry Piin-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 Picoaccessories and add-ons.
RP2040 Microcontroller:
At the core of the Raspberry Pi Pico W is the RP2040 microcontroller. It features a dual-core
ARMCortex-M0+ processor running at 133MHz, providing ample processing power for a wide
range ofapplications. 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
anonboard Cypress CYW43455 Wi-Fi chip, which supports dual-band (2.4GHz and 5GHz) Wi
Fi802.11b/g/n/ac. This allows the Pico W to seamlessly connect to wireless networks,
communicate withother 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
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
flexibility for interfacing with external components and peripherals. It features 26 GPIO pins, of
which3 are analog inputs, and supports various protocols such as UART, SPI, I2C, and PWM.
The Pico Walso 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
programminglanguage that allows for rapid prototyping and development. MicroPython provides
a simplified syntax and high-level abstractions, making it easy for newcomers to get started.
RESULT:
Thus the study of Raspberry Pi has been done and ensured its composition with internal features
specifically.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
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 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.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Thonny IDE:
Thonny is an open-source IDE which is used to write and upload MicroPython programs to
differentdevelopment boards such as Raspberry Pi Pico, ESP32, and ESP8266. It is extremely
interactive andeasy to learn IDE as much as it is known as the beginner-friendly IDE for new
programmers. With thehelp of Thonny, it becomes very easy to code in Micropython as it has a
built-in debugger that helps tofind 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.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
CONNECTIONS:
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:
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)
while True: r.value(1)
sleep_ms(1000)
r.value(0)
sleep_ms(1000)
y.value(1) sleep(1)
y.value(0) sleep(1)
g.value(1) sleep(1)
g.value(0) sleep(1)
CONNECTIONS:
RESULT:
Thus the study of Python programming has been done and ensured its composition with internal
features specifically.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
AIM:
To interface IR sensor with Raspberry PI
APPARATUS REQUIRED:
Raspberry Pi
IR Sensor
Connecting cables
IR SENSOR:
An IR sensor or infrared sensor is a type of electronic device that emits light in order to detect
certain aspects of its surroundings. The sensor module is ambient light-adaptable, with a pair of
infrared emitting and receiving tubes. At a specific frequency, the transmitting tubes emit
infrared. When the direction of an obstacle is detected (reflective surface), the receiving tube
receives the infrared reflected. After a comparator circuit processing, the green light turns on.
And the signal output interfaces a digital signal (a low-level signal). The sensor’s effective
distance range is 2 ~ 30cm. The sensor’s detection range can be adjusted by adjusting the
potentiometer.
PROGRAM:
import RPi.GPIO as
GPIO import time
sensor=3
GPIO.setmode(GPIO.
BOARD)
GPIO.setup(sensor,
GPIO.PIN) print “IR
sensor detected”
print “”
Try:
While True:
If GPIO.input(sensor):
print(“object
not detected”)
While
GPIO.input(Sen
sor):
time.sle
ep(0.2)
Else:
print(“object
detected”)
Except
KeyboardInterru
pt:
GPIO.cleanup()
Result
Thus the IR sensor is interfaced with Raspberry Pi and the obstacle detection was monitored
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
AIM:
To communicate between Arduino and Raspberry Pi and forward a message from Arduino to
Raspberry Pi.
APPARATUS REQUIRED:
Arduino UNO Board
Raspberry Pi
Connecting Cables
Diagram
Step 5: Now connect the arduino to the raspberry pi again and add the following code to thonny
while 1 :
ser.readline()
Step 6: Now run the code again to observe the data being sent
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
PROGRAM:
void setup()
{
Serial.begin(9600);
}
void loop(){
Serial.println(“Hello Pi”);
delay(2000);
}
RESULT:
Thus the communication between Arduino and Raspberry Pi was established and the message was
sent from Arduino to Raspberry Pi using serial communication.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
AIM:
To create the simplest experiment by using an IoT module with interfaces on the ESP32.
PROCEDURE:
ARDUINO CODE:
#include <ESP8266WiFi.h>
#include "Adafruit_MQTT.h"
#include
"Adafruit_MQTT_Client.h"
#include "DHT.h"
#define WLAN_SSID "YOUR_WIFI_SSID"
#define WLAN_PASS "YOUR_WIFI_PASSWORD"
#define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883 // use 8883 for
SSL #define AIO_USERNAME"umaece1982"
#define AIO_KEY "aio_EpaH61HXULkHr4c8izGTucz5Fqoi"
#define DHTPIN D6
#define DHTTYPE DHT11
DHT dht(DHTPIN,
DHTTYPE);
WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME,
AIO_KEY);
Adafruit_MQTT_Publish temperature = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME
"feeds/temperature1");
Adafruit_MQTT_Publish humidity = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME
"feeds/humidity1");
void MQTT_connect();
void setup() {
Serial.begin(115200);
dht.begin();
delay(10);
Serial.println(F("Adafruit MQTT demo"));
Serial.println(); Serial.println();
Serial.print("Connecting to ");
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Serial.println(WLAN_SSID);
WiFi.begin(WLAN_SSID, WLAN_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected");
Serial.println("IP address: "); Serial.println(WiFi.localIP());
}
uint32_t x=0;
void loop() {
MQTT_connect();
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print(F("\nTemperature:
")); Serial.print(t);
Serial.print(F("\nHumidity: "));
Serial.print(h);
temperature.publish(t);
humidity.publish(h);
delay(60000);
}
void MQTT_connect()
{ int8_t ret;
if (mqtt.connected()) {
return;
}
Serial.print("Connecting to MQTT... ");
uint8_t retries = 3;
while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
Serial.println(mqtt.connectErrorString(ret));
Serial.println("Retrying MQTT connection in 5 seconds...");
mqtt.disconnect();
delay(5000); // wait 5
seconds retries--;
if (retries == 0) {
// basically die and wait for WDT to reset me
while (1);
}
}
Serial.println("MQTT Connected!");}
RESULT
The ESP32 has successfully connected to Adafruit IO via Wi-Fi, as programmed.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Ex no.11 Log Data using Raspberry PI and upload it to the cloud platform
AIM
To write and execute the program Log Data using Raspberry PI and upload it to the cloud platform.
CONNECTIONS:
PROGRAM:
AIM:
To design a Smart Home Automation IOT-based system.
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:
PROGRAM:
import time import
network import
BlynkLib
from machine import Pin
led=Pin(16, Pin.OUT)
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)
# Handle connection error if
wlan.status() != 3:
raise RuntimeError('network connection failed') else:
print('connected')
ip=wlan.ifconfig()[0]
print('IP: ', ip)
"Connection to Blynk" #
Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
# Register virtual pin handler
@blynk.on("V0") #virtual pin V0
def v0_write_handler(value): #read the value if
int(value[0]) == 1:
led.value(1) #turn the led on else:
led.value(0) #turn the led off
while True:
blynk.run()
RESULT:
The design of an IOT system has been verified and modeled successfully.