0% found this document useful (0 votes)
15 views80 pages

Lab Manual

The document is a lab manual for the Embedded Systems and IoT course at Anjalai Ammal-Mahalingam Engineering College, detailing practical exercises and assembly language programs for 8051 microcontrollers. It includes various experiments such as LED blinking, arithmetic operations, logical operations, and data transfer between registers and memory. The manual also provides algorithms and sample code for each exercise, ensuring students can execute and verify their programs using the Edsim51d simulator.

Uploaded by

aourclassroom
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views80 pages

Lab Manual

The document is a lab manual for the Embedded Systems and IoT course at Anjalai Ammal-Mahalingam Engineering College, detailing practical exercises and assembly language programs for 8051 microcontrollers. It includes various experiments such as LED blinking, arithmetic operations, logical operations, and data transfer between registers and memory. The manual also provides algorithms and sample code for each exercise, ensuring students can execute and verify their programs using the Edsim51d simulator.

Uploaded by

aourclassroom
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

Department of Computer Science and Engineering

Anjalai Ammal-Mahalingam Engineering College


Kovilvenni-614 403
(NAAC Accredited with B Grade)

LAB MANUAL

NAME : DINESH P

DEPARTMENT : CSE

YEAR : III CSE A&B

SUBJECT : CS3691-EMBEDDED SYSTEMS AND IOT

REGULATION : 2021

ACADEMIC YEAR : 2024-2025 & EVEN SEMSTER

Signature of the Faculty HoD/CSE


Department of Computer Science and Engineering
Anjalai Ammal - Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)

PRACTICAL EXERCISES:

1. Write 8051 Assembly Language experiments using simulator.

2. Test data transfer between registers and memory.

3. Perform ALU operations.

4. Write Basic and arithmetic Programs Using Embedded C.

5. Introduction to Arduino platform and programming

6. Explore different communication methods with IoT devices (Zigbee, GSM,Bluetooth)

7. Introduction to Raspberry PI platform and python programming

8. Interfacing sensors with Raspberry PI

9. Communicate between Arduino and Raspberry PI using any wireless medium

10. Setup a cloud platform to log the data

11. Log Data using Raspberry PI and upload to the cloud platform

12. Design an IOT based system

30 PERIODS
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)

Ex:1(a) LED Blinking Assembly Language Program Using Edsim51d Simulator


AIM
To write an Assembly Language LED Blinking Program using Simulator

ALGORITHM

Step 1: Start and Initialize the program at memory location 0H.

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 7: Initialize Counters


I. Load R2 = 5 (Outer loop counter).
II. Load R1 = 5 (Inner loop counter).

Step 8: Execute Nested Loops

I. Decrement R1 until it becomes 0 (Inner loop).


II. Decrement R2 after each inner loop completion.

Step 9: Return to Main Program

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)

Ex: 1(b) 8-Bit Arithmetic Operations 8051microcontroller Using Simulator

AIM:
Write an Assembly language programming for 8-bit Arithmetic operations using Edsim51d
simulator

ALGORITHM

Addition Program Algorithm:

➢ Clear carry.
➢ Load accumulator A with any desired 8-bitdata.
➢ Add accumulator with 8-bitnumbers.
➢ Store the result using DPTR.
➢ Stop the program.

Subtraction Program Algorithm:

➢ Clear carry.
➢ Load accumulator A with any desired 8-bitdata.
➢ Subtractaccumulatorwith8-bitnumbers.
➢ Store the result using DPTR.
➢ Stop the program.

Multiplication Program Algorithm:

➢ Load accumulator A with any desired 8-bitdata.


➢ Load B Register with any desired8-bitdata.
➢ Multiply Accumulator with B register.
➢ Store the result Present in Accumulator and B register using DPTR.
➢ Stop the program.

Division Program Algorithm:

➢ Load accumulator A with any desired 8-bitdata.


➢ Load B Register with any desired8-bitdata.
➢ Divide Accumulator with B register.
➢ Store the result Present in Accumulator and B register using DPTR.
➢ Stop the program.
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)

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

R0 = 0AH (Decimal 10)

Subtraction Program

R1 = 04H (Decimal 4)

Multiplication Program

R3 = FDH (Decimal 253)

R4 = 02H (Decimal 2)

(Note: Since multiplication in 8051 is 8-bit × 8-bit, it results in a 16-bit value.)

Division Program

R3 = 06H (Decimal 6) [Quotient]

R4 = 01H (Decimal 1) [Remainder]


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

Ex: (2) 8-Bit Assembly Language Logical Operations 8051-Microcontroller Using

Simulator

AIM:
To perform an Assembly Language logical operation Program using 8051
Microcontroller AND, OR &EX-OR.

ALGORITHM

1. Get the input value and store data in the accumulator.

2. Get the second values and store the B register.

3. Logical operation to perform the given number

4. Store the output value in memory.

AND OPERATION PROGRAM


CLR C
MOV A, #07
ANL A, #03 MOV R0, A
HERE: SJMP HERE

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

1’s COMPLEMENT PROGRAM


CLR C
MOV A,#55H CPL A
MOV R0,A
HERE: SJMP HERE

2’s COMPLEMENT PROGRAM


CLR C
MOV A, #07 CPL A
INC A MOV R3,A
HERE: SJMP HERE
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)

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

R0 = AAH (Decimal 170)

5. 2’s Complement

R3 = F9H (Decimal -7)


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

Ex No:3(a) TEST DATA TRANSFER BETWEEN REGISTER AND MEMORY

AIM:

To do test data transfer between registers and memory using instructions.

APPARATUS REQUIRED:

8051-Microcontroller Emulator Software

ALGORITHM

Step 1: Load Data into Registers


Step 2: Store and Retrieve Data from Internal RAM
Step 3: External RAM Transfer (MOVX)
Step 4: Code Memory Transfer
(MOVC) Step 5: End of program

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

Register/Memory Final value

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)

Ex no:3 (b) COMPARE 2 NUMBERS IN 8051

AIM:

To write an Assembly Language program to compare two numbers in 8051 using stimulator.

ALGORITHM:

1. Load the first number into a region.


2. Load the second number into another register.
3. Compare the two numbers using comparison instruction CJNE.
4. Compare and jump if not equal.
5. If the numbers are equal , execute code block A.
6. If the numbers are not equal , execute code block B.
7. End the program.

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

A = 10H (16 in decimal)

B = 15H (21 in decimal)

Since A ≠ B, the program jumps to NOT_EQUAL.


Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)

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)

Ex No: 4 (a) 8-Bit Arithmetic Embedded C Programming Using


Simulator
Aim
To Write a C Program to perform basic arithmetic operations like addition, subtraction,
multiplication and division Using Keil uVision5 Software

Algorithm

Addition Program Algorithm :


➢ Assign any desired 8-bitdata to a variable x.
➢ Assign another desired 8-bitdata to another variable y.
➢ Add two 8-bitnumbers and store in another variable z.
➢ Store the result in Port 0
Subtraction program Algorithm :
➢ Assign any desired 8-bitdata to a variable a.
➢ Assign another desired 8-bitdata to another variable b.
➢ Subtract two 8-bitnumbers and store in another variable c.
➢ Store the result in Port 1
Multiplication program Algorithm :
➢ Assign any desired 8-bitdata to a variable d.
➢ Assign another desired 8-bitdata to another variable e.
➢ Multiply two 8-bitnumbers and store in another variable f.
➢ Store the result in Port 2
Division program Algorithm :
➢ Assign any desired 8-bitdata to a variable p.
➢ Assign another desired 8-bitdata to another variable q.
➢ Divide two 8-bitnumbers and store in another variable r.
➢ Store the result in Port 3
➢ Stop the program.
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)

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)

Ex No:4(b) 8-Bit Logical Operations Embedded C Programming Using Simulator


Aim
To Write a C Program to perform logical operations Using Keil uVision5 Software

Algorithm

Step 1: Initialize Variables


Step 2: Perform Bitwise Operations
Step 3: Perform Bitwise Shifting Step
4: Assign Results to Ports
Step 5: Infinite Loop Step
6: Stop the program

EMBEDDED C PROGRAM

#include <reg51.h>

void main(void)
{
// Perform bitwise operations and assign to ports

P0 = 0x12 & 0x34; // AND operation


P1 = 0x12 | 0x34; // OR operation
P2 = 0x12 ^ 0x34; // XOR operation
P3 = ~0x12; // NOT (1’s complement)
P0 = 0x12 >> 3; // Right shift by 3 bits
P1 = 0x12 << 4; // Left shift by 4 bits

while(1); // Infinite loop to keep the program running


}
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)

Output

Operation Calculation Decimal Result Stored


Hex Result
in
AND 0x12 & 0x34 0x10 16 P0
OR 0x12 0x36
0x34` 54
XOR 0x12 ^ 0x34 0x26 P2
38
NOT ~0x12 0xED -19 (signed) P3
Right Shift 0x12 >> 3 0x02 2 P0
Left Shift 0x12 << 4 0x120 P1
288
Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)

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)

Ex No.5 (a) INTRODUCTION TO THE ARDUINO PLATFORM

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.

Components of an Arduino Board: Each Arduino board typically includes the


following components:

 Microcontroller (e.g., ATmega328 in Arduino UNO)


 Digital Input/Output Pins
 Analog Input Pins
 USB Interface and Connector
 Power Supply and Reset Buttons
 LEDs
 Crystal Oscillator
 Voltage Regulator
Some components may vary depending on the specific board type.

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 Arduino Micro is a compact board powered by the ATmega32U4 microcontroller. It


features a total of 20 input/output pins, including 7 PWM (Pulse Width Modulation) pins and12
analog inputpins. Additional components on the board include a reset button, a 16 MHz
crystal oscillator, an ICSP header, and a micro-USB connection. TheUSB functionality is
built into the Arduino Micro, allowing it to easily connect to a computer without requiring an
external USB-to-serial converter.
5) Arduino Leonardo

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.

11) Arduino Zero

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)

Introduction to Arduino IDE 2.0

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)

Ex No:5(b) LED BLINK

AIM:
To write a LED Blink Program using Arduino Kit

ALGORITHM

1) Start the Arduino Program.

2) Initialize the Pin:

 In the setup() function:


o Configure pin 2 as an output pin using pinMode(2, OUTPUT);.
o This prepares the pin to send signals (either HIGH or LOW voltage).

3) Execute the Main Loop Continuously:

 In the loop() function (this runs repeatedly):

a. Turn ON the LED:

 Use digitalWrite(2, HIGH); to send 5V to pin 2.


 This turns the LED ON (assuming an LED is connected to pin 2).

b. Delay for 1 Second:


 Use delay(1000); to keep the LED ON for 1000 milliseconds (1 second).

c. Turn OFF the LED:

 Use digitalWrite(2, LOW); to send 0V to pin 2.


 This turns the LED OFF.

d. Delay for 1 Second Again:

 Use delay(1000); to keep the LED OFF for 1 second before repeating the cycle.

4 Repeat steps 3a to 3d indefinitely.


Department of Computer Science and Engineering
Anjalai Ammal-Mahalingam Engineering College
Kovilvenni-614 403
(NAAC Accredited with B Grade)

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)

Ex No 5(c) LED FADE

AIM:
To write a LED Fade Program using Arduino Kit
Procedure

1) Start the program.

2) Declare and initialize variables:

 Assign PWM pin 9 to the variable led.


 Initialize the brightness level to 0.
 Set the fade amount to 5.

3) In the setup() function:

 Configure pin 9 as an output using pinMode().

4) In the loop() function:

 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

This program gradually increases and decreases the brightness of an LED


connected to a PWM-enabled pin (e.g., pin 9) using the analogWrite()
function.
*/

int led = 9; // PWM pin to which the LED is


connected int brightness = 0; // Initial brightness of
the LED
int fadeAmount = 5; // Amount by which the brightness changes each time

void setup()
{
pinMode(led, OUTPUT); // Set the LED pin as OUTPUT
}

void loop()

{
analogWrite(led, brightness); // Set LED brightness using PWM

brightness = brightness + fadeAmount; // Change brightness

// Reverse the fading direction if brightness reaches


limits if (brightness <= 0 || brightness >= 255)
{
fadeAmount = -fadeAmount;
}

delay(30); // Wait for 30 milliseconds to see the fading effect


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

Exno.6(a) Communicate Between Arduino And Bluetooth Communication Module

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.

CONNECTION ESTABLISHMENT OF BLUETOOTH HC05 AND SMARTPHONE


1) Pair HC05 module with your smartphone’s Bluetooth using 1234 as password. After getting

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

and devices are now paired.

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

notification connected at the bottom and connect button changes in disconnect.

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

instruction Serial.read() works.

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

ExNo:6(b) COMMUNICATION MODULE-ZIGBEE & ARDUINO

AIM:

To communicate with Arduino using Zigbee Protocol model.

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

Ex No: 7(a) 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
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.

Additionally, the Pico W is compatible with C/C++ programming, allowing experienced


developers to leverage the rich ecosystem of libraries and frameworks available.

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
andflexibility for handling real-time data and timing-critical applications. The PIO state
machines can beprogrammed 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 Picommunity. Raspberry Pi provides extensive documentation, including datasheets,
pinout diagrams, andprogramming guides, to assist developers in understanding the board’s
capabilities. The communityoffers 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
microcontrollerboard. 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.
\
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

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

Ex No:7(b) INTRODUCTION TO PYTHON PROGRAMMING

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

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 https://thonny.org
2. Download the version for Windows and
3. wait a few seconds while it downloads.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
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.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


Pin Development Board
Pin
GP16 Boar LED

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:

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,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:

Raspberry Pi Pico Raspberry Pi Pico


Pin Development Board
GP16 LED
GP15 SW1

SWITCH CONTROLLED LED:

from machine import Pin from


time import sleep
led=Pin(16,Pin.OUT)
sw=Pin(15,Pin.IN)
while True:
bt=sw.value() if
bt== True:
print("LED ON")
led.value(1) sleep(2)
led.value (0) sleep(2)
led.value (1) sleep(2)
led.value(0) sleep(2)
else:
print("LED OFF")
sleep(0.5)

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

Ex No:8 INTERFACE IR SENSOR WITH RASPBERRY PI

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

ExN0.9 COMMUNICATE ARDUINO AND RASPBERRY PI

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

Raspberry Pi and Arduino Communication


Step 1: Connect the Arduino to the raspberry pi with the help of a USB cable
Step 2: Open thonny and type in the following code to create a serial communication device with
the specified name and port import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
Step 3: check if the device was created by opening the terminal and typing the following
command ls /dev/tty*
Step 4: Open the arduino ide and upload the following code to the arduino board

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

ExNo: 10 LOG DATA USING CLOUD PLATFORM

AIM:

To create the simplest experiment by using an IoT module with interfaces on the ESP32.

PROCEDURE:

1. Set up the circuit as described in the “Circuit Connection” section.


2. Connect the ESP 32 to your computer using a USB cable.
3. Open the Arduino IDE software on your computer.
4. Write the code for adafruit io interface with Arduino.
5. Verify and upload the code to the ESP 32.

Create Adafruit Account in https://accounts.adafruit.com/users/sign_in


ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

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.

HARDWARE & SOFTWARE TOOLS REQUIRED:

S.No 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

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)
RESULT:
The program for Log Data using Raspberry PI and upload it to the cloud platform has been verified
and executed successfully.
ANJALAI AMMAL - MAHALINGAM ENGINEERING COLLEGE
KOVILVENNI-614 403, THIRUVARUR DISTRICT
NAAC Accredited with “B” Grade
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Ex No.12 Design an IOT-based system

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

HARDWARE & SOFTWARE TOOLS REQUIRED:

S.No 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
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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy