0% found this document useful (0 votes)
8 views

CS3691 - EMB & IoT Lab Manual Final Copy

The document is a laboratory manual for the CS3691 Embedded Systems and IoT course, outlining course objectives, a list of experiments, and expected outcomes. It includes detailed procedures for various experiments using 8051 Assembly Language and Embedded C, as well as introductory information on Arduino and Raspberry Pi platforms. The manual aims to teach students about embedded processor architecture, interfacing with I/O devices, and building IoT systems.

Uploaded by

Sticky
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)
8 views

CS3691 - EMB & IoT Lab Manual Final Copy

The document is a laboratory manual for the CS3691 Embedded Systems and IoT course, outlining course objectives, a list of experiments, and expected outcomes. It includes detailed procedures for various experiments using 8051 Assembly Language and Embedded C, as well as introductory information on Arduino and Raspberry Pi platforms. The manual aims to teach students about embedded processor architecture, interfacing with I/O devices, and building IoT systems.

Uploaded by

Sticky
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/ 77

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

CS3691 - EMBEDDED SYSTEMS & IOT


LABORATORY MANUAL

NAME: ROLL NO:

SEMESTER: BATCH:

REGISTER NO:

Prepared By,

Mrs.Kiruthika.S.V
Assistant Professor
Department of ECE
Christ the King Engineering College
Karamadai, Coimbatore.
CS3691 EMBEDDED SYSTEMS AND IOT

SYLLABUS

COURSE OBJECTIVES:

❖ To learn the internal architecture and programming of an embedded processor.


❖ To introduce interfacing, I/O devices to the processor.
❖ To introduce the evolution of the Internet of Things (IoT).
❖ To build a small low-cost embedded IoT system using Arduino/Raspberry Pi/
open platform.
❖ To apply the concept of the Internet of Things in real-world scenario.

LIST OF EXPERIMENTS

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

OUTCOMES:

CO1: Explain the architecture of embedded processors.


CO2: Write embedded C programs.
CO3: Design simple embedded applications.
CO4: Compare the communication models in IOT
CO5: Design IoT applications using Arduino/Raspberry Pi /open platform.
LIST OF EXPERIMENTS

PAGE DATE OF MARK


S.No. DATE NAME OF THE EXPERIMENT SIGNATURE
NO SUBMISSION (10)
LIST OF EXPERIMENTS

PAGE DATE OF MARK


S.No. DATE NAME OF THE EXPERIMENT SIGNATURE
NO SUBMISSION (10)
PROGRAMS
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
8051 Assembly Language program using Keil simulator
DATE

AIM:
To write 8051 Assembly Language Program for an 8-bit addition using Keil simulator and
execute it.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keil μvision5 IDE 1

INTRODUCTION TO 8051 SIMULATORS:

A simulator is software that will execute the program and show the results exactly to the
program running on the hardware, if the programmer finds any errors in the program while
simulating the program in the simulator, he can change the program and re-simulate the code and
get the expected result, before going to the hardware testing. The programmer can confidently
dump the program in the hardware when he simulates his program in the simulator and gets the
expected results.
8051 controller is a most popular 8-bit controller which is used in a large number of
embedded applications and many programmers write programs according to their application. So
testing their programs in the software simulators is a way. Simulators will help the programmer to
understand the errors easily and the time taken for the testing is also decreased.
These simulators are very useful for students because they do need not to build the complete
hardware for testing their program and validate their program very easily in an interactive way.
CS3691 EMBEDDED SYSTEMS AND IOT

PROCEDURE

1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create New Project Select Device for
Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of simulation by clicking Run or step run.8.
CS3691 EMBEDDED SYSTEMS AND IOT

PROGRAM:

ORG 0000H
CLR C
MOV A, #20H
ADD A, #21H
MOV R0, A
END

OUTPUT:

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
Test data transfer between registers and memory
DATE

AIM:
To write and execute an Assembly language program to transfer data between registers and
memory.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keil μvision5 IDE 1

PROCEDURE

1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create a New Project Select Device for
the Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of the simulation by clicking Run or Step run.
CS3691 EMBEDDED SYSTEMS AND IOT

PROGRAM:
TYPE-I:
ORG 0000H
CLR C
MOV R0, #55H
MOV R1, #6FH
MOV A, R0
MOV 30H, A
MOV A, R1
MOV 31H, A
END

OUTPUT:
CS3691 EMBEDDED SYSTEMS AND IOT

PROGRAM:
TYPE-II:
ORG 0000H
CLR C
MOV R0, #30H
MOV R1, #40H
MOV R7, #06H
BACK: MOV A, @R0
MOV @R1, A
INC R0
INC R1
DJNZ R7, BACK
END

OUTPUT:

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
ALU operations
DATE

AIM:
To write and execute the ALU program using the Keil simulator.

SOFTWARE TOOLS REQUIRED:

S.No Software Requirements Quantity


1 Keil μvision5 IDE 1

PROCEDURE

1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create New Project Select Device for
Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of simulation by clicking Run or step run.
CS3691 EMBEDDED SYSTEMS AND IOT

PROGRAM:

ORG 0000H
CLR C
//ADDITION
MOV A, #20H
ADD A, #21H
MOV 41H, A

//SUBTRACTION
MOV A, #20H
SUBB A, #18H
MOV 42H, A

//MULTIPLICATION
MOV A, #03H
MOV B, #04H
MUL AB
MOV 43H, A

//DIVISION
MOV A, #95H
MOV B, #10H
DIV AB
MOV 44H, A
MOV 45H, B

//AND
MOV A, #25H
MOV B, #12H
ANL A, B
MOV 46H, A

//OR
MOV A, #25H
MOV B, #15H
ORL A, B
MOV 47H, A

//XOR
MOV A, #45H
MOV B, #67H
CS3691 EMBEDDED SYSTEMS AND IOT

XRL A, B
MOV 48H, A

//NOT
MOV A, #45H
CPL A
MOV 49H, A
END

OUTPUT:

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
WRITE BASIC PROGRAMS USING EMBEDDED C
DATE

AIM:
To write a basic embedded C program to control a port 0 pin 0 connected to an 8051
microcontroller using a Keil simulator.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keil μvision5 IDE 1

PROCEDURE

1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create a New Project Select Device for
the Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of the simulation by clicking Run or Step run.
CS3691 EMBEDDED SYSTEMS AND IOT

OUTPUT:
CS3691 EMBEDDED SYSTEMS AND IOT

PROGRAM:
#include<REG51.h>
int i,j;
sbit LED = P2^0;
void main()
{
while(1)
{
LED = 0;
for(j=0;j<10000;j++);
LED = 1;
for(j=0;j<10000;j++);
}
}

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
ARITHMETIC PROGRAMS USING EMBEDDED C
DATE

AIM:
To write an embedded C program for addition, subtraction, multiplication, and division
using the Keil simulator.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keil μvision5 IDE 1

PROCEDURE

1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project and Create New Project Select Device for
Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with the .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of the simulation by clicking Run or Step run.
CS3691 EMBEDDED SYSTEMS AND IOT

PROGRAM:
#include<REG51.H>
unsigned char a, b;
void main()
{
a=0x10;
b=0x04;
P0=a-b;
P1=a+b;
P2=a*b;
P3=a/b;
while(1);
}
CS3691 EMBEDDED SYSTEMS AND IOT

OUTPUT:

Port P0= _________


Port P1= _________
Port P2= _________
Port P3= _________

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
INTRODUCTION TO THE ARDUINO PLATFORM
DATE

AIM:
To study the basics of Arduino Uno board and Arduino IDE 2.0 software.

Hardware & SOFTWARE TOOLS REQUIRED:

S.No. Hardware & Software Requirements Quantity


1 Arduino IDE 2.0 1
2 Arduino Uno Board 1

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.
CS3691 EMBEDDED SYSTEMS AND IOT

TYPES OF ARDUINO BOARDS


1) Arduino UNO
Arduino UNO is based on an ATmega328P microcontroller. It is easy to use compared to other
boards, such as the Arduino Mega board, etc. The Arduino UNO includes 6 analog pin inputs, 14
digital pins, a USB connector, a power jack, and an ICSP (In-Circuit Serial Programming) header. It
is the most used and of standard form from the list of all available Arduino Boards.

2) Arduino Nano
The Arduino Nano is a small Arduino board based on ATmega328P or ATmega628 Microcontroller.
The connectivity is the same as the Arduino UNO board. The Nano board is defined as a sustainable,
small, consistent, and flexible microcontroller board. It is small in size compared to the UNO board.
The devices required to start our projects using the Arduino Nano board are Arduino IDE and mini-
USB. The Arduino Nano includes an I/O pin set of 14 digital pins and 8 analog pins. It also includes
6 Power pins and 2 Reset pins.

3) Arduino Mega
The Arduino Mega is based on the ATmega2560 Microcontroller. The ATmega2560 is an 8-bit
microcontroller. We need a simple USB cable to connect to the computer and the AC to DC adapter
or battery to get started with it. It has the advantage of working with more memory space. The
Arduino Mega includes 54 I/O digital pins and 16 Analog Input/Output (I/O), ICSP header, a reset
CS3691 EMBEDDED SYSTEMS AND IOT

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
INTRODUCTION TO ARDUINO PROGRAMMING
DATE

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

HARDWARE & SOFTWARE TOOLS REQUIRED:

S.No Hardware & Software Requirements Quantity


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

5 Joystick Module 1

PROGRAM:

DIGITAL WRITE:

void setup() {
pinMode(2, OUTPUT);
}
void loop() {
digitalWrite(2, HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);
}
CS3691 EMBEDDED SYSTEMS AND IOT

CONNECTION:

Arduino UNO Pin Arduino Development Board


2 LED

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

CONNECTION:

Arduino UNO Pin Arduino Development Board


2 LED
5 S1 (SW 1)

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);
}
CS3691 EMBEDDED SYSTEMS AND IOT

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

CONNECTION:

Arduino UNO Pin Arduino Development Board Joystick Module


2 LED
VCC or 5V +5V
GND GND
A0 VRx or VRy
CS3691 EMBEDDED SYSTEMS AND IOT

CONNECTION:

Arduino UNO Pin Arduino Development Board


3 LED

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


CS3691 EMBEDDED SYSTEMS AND IOT

CONNECTION:

Arduino UNO Pin Arduino Development Board


4 LED

SERIAL COMMUNICATION:
void setup()
{
Serial.begin(9600);
pinMode(4, OUTPUT);

void loop() {
if(Serial.available()>0)
{
char data=Serial.read();
Serial.println(data);
if(data=='1'){
digitalWrite(4,HIGH);
}
else if(data=='2'){
digitalWrite(4,LOW);
}

}
}

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO: Different communication methods with IoT devices


DATE (Zigbee, GSM, Bluetooth)

AIM:
To Explore different communication methods with IoT devices (Zigbee, GSM, Bluetooth).

DIFFERENT COMMUNICATION METHODS:


IoT devices require reliable and efficient communication methods to transmit data and interact with
other devices or systems. Here are three commonly used communication methods for IoT devices:

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

GSM (Global System for Mobile Communications):


GSM is a widely used cellular network technology that enables IoT devices to connect to the
internet using SIM cards. It operates on various frequency bands and provides wide coverage, making
it suitable for applications that require long-range communication. GSM is commonly used in
applications such as asset tracking, remote monitoring, and smart cities.

Bluetooth:
Bluetooth is a short-range wireless communication technology that operates on the 2.4 GHz
frequency band. It is commonly used for connecting IoT devices to smartphones, tablets, and other
nearby devices. Bluetooth Low Energy (BLE) is a power-efficient version of Bluetooth that is ideal
for battery-powered IoT devices. Bluetooth is widely used in applications such as wearable devices,
healthcare monitoring, and home automation.

Each communication method has its advantages and limitations, and the choice depends on
the specific requirements of the IoT application. Factors to consider include range, power
consumption, data rate, security, and interoperability with other devices or systems.
CS3691 EMBEDDED SYSTEMS AND IOT

CONNECTIONS:

Arduino UNO Pin Bluetooth Module Arduino Development Board


VCC 5V -
GND GND -
2 Tx -
3 Rx -
4 - LED
CS3691 EMBEDDED SYSTEMS AND IOT

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");
}
}
}
CS3691 EMBEDDED SYSTEMS AND IOT

CONNECTIONS:

TRANSMITTER:

Arduino UNO Pin Zigbee Module


VCC 5V
GND G
2 Tx
3 Rx

PROGRAM:
TRANSMITTER SIDE:

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

void loop() {
mySerial.write('A');
Serial.println('A');
delay(100);
mySerial.write('B');
Serial.println('B');
delay(100);

}
CS3691 EMBEDDED SYSTEMS AND IOT

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:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO: INTRODUCTION TO THE RASPBERRY PI


DATE PLATFORM

Introduction to Raspberry Pi Pico W:

The Raspberry Pi Pico W is a compact and affordable microcontroller board developed by the
Raspberry Pi Foundation. Building upon the success of the Raspberry Pi Pico, the Pico W variant
brings wireless connectivity to the table, making it an even more versatile platform for embedded
projects. In this article, we will provide a comprehensive overview of the Raspberry Pi Pico W,
highlighting its key features and capabilities.
Features:
• RP2040 microcontroller with 2MB of flash memory
• On-board single-band 2.4GHz wireless interfaces (802.11n)
• Micro USB B port for power and data (and for reprogramming the flash)
• 40 pins 21mmx51mm ‘DIP’ style 1mm thick PCB with 0.1″ through-hole pins also with edge
castellations
• Exposes 26 multi-function 3.3V general purpose I/O (GPIO)
• 23 GPIO are digital-only, with three also being ADC-capable
• Can be surface mounted as a module
• 3-pin ARM serial wire debug (SWD) port
• Simple yet highly flexible power supply architecture
• Various options for easily powering the unit from micro-USB, external supplies, or batteries
• High quality, low cost, high availability
• Comprehensive SDK, software examples, and documentation
• Dual-core Cortex M0+ at up to 133MHz
• On-chip PLL allows variable core frequency
• 264kByte multi-bank high-performance SRAM

Raspberry Pi Pico W:
The Raspberry Pi Pico W is based on the RP2040 microcontroller, which was designed by Raspberry
Pi in-house. It combines a powerful ARM Cortex-M0+ processor with built-in Wi-Fi connectivity,
opening up a range of possibilities for IoT projects, remote monitoring, and wireless communication.
The Pico W retains the same form factor as the original Pico, making it compatible with existing Pico
accessories and add-ons.
CS3691 EMBEDDED SYSTEMS AND IOT

RP2040 Microcontroller:
At the core of the Raspberry Pi Pico W is the RP2040 microcontroller. It features a dual-core ARM
Cortex-M0+ processor running at 133MHz, providing ample processing power for a wide range of
applications. The microcontroller also includes 264KB of SRAM, which is essential for storing and
manipulating data during runtime. Additionally, the RP2040 incorporates 2MB of onboard flash
memory for program storage, ensuring sufficient space for your code and firmware.

Wireless Connectivity:
The standout feature of the Raspberry Pi Pico W is its built-in wireless connectivity. It includes an
onboard Cypress CYW43455 Wi-Fi chip, which supports dual-band (2.4GHz and 5GHz) Wi-Fi
802.11b/g/n/ac. This allows the Pico W to seamlessly connect to wireless networks, communicate
with other devices, and access online services. The wireless capability opens up new avenues for IoT
projects, remote monitoring and control, and real-time data exchange.

GPIO and Peripherals:


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

MicroPython and C/C++ Programming:


The Raspberry Pi Pico W can be programmed using MicroPython, a beginner-friendly programming
language that allows for rapid prototyping and development. MicroPython provides a simplified
syntax and high-level abstractions, making it easy for newcomers to get started. Additionally, the
CS3691 EMBEDDED SYSTEMS AND IOT

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 and
flexibility for handling real-time data and timing-critical applications. The PIO state machines can
be programmed to interface with custom protocols, generate precise waveforms, and offload tasks
from the main processor, enhancing the overall performance of the system.

Open-Source and Community Support


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

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.
CS3691 EMBEDDED SYSTEMS AND IOT

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
INTRODUCTION TO PYTHON PROGRAMMING
DATE

AIM:
To learn about the evolution, core features, general characteristics and applications of Raspberry

THEORY:
The Raspberry Pi is a credit card sized computer that can connect to a huge variety of sensors and
other modules like LCD displays, servos, and motors. The Raspberry Pi is a low-cost, low power
consumption, credit-card-sized single-board computer. After some initial setup, you can connect
it to a computer or TV monitor and start using it. Aside from a monitor, the Raspberry Pi will also
need a mouse and keyboard, unless you decide to set it up in headless mode. In headless mode you
only need a computer and a USB cable to use the Raspberry Pi.

Fig: Raspberry Pi
The Raspberry Pi has 40 GPIO pins to connect external peripherals or sensors. The abundance of
GPIO pins allows the Raspberry Pi to be used as a control center for more complex projects like
robots and autonomous vehicles. Finally, the Raspberry Pi relies on a Broadcom BCM2835
System on a Chip (SoC). An SoC is an integrated circuit that has all the components necessary to
power a computer. On the Raspberry Pi, the Broadcom chip contains a 700MHz ARM processor
and a video core 4 GPU.
CS3691 EMBEDDED SYSTEMS AND IOT

USES OF RASPBERRY PI
There are so many things you can make with a Raspberry Pi. And due to its extreme popularity,
the number of third-party sensors, modules, and code libraries has grown to epic proportions. This
has greatly expanded the possible applications for the Raspberry Pi. The applications really are
endless, but here are some common ones:

 Web servers

 Local network hubs for IoT

 Sensor control
 Robotics control

 Industrial equipment control

 Automated control systems

 Data processing

THE RASPBERRY PI OS
There are several different operating systems available for use on the Raspberry Pi, but the
Raspberry Pi OS (formerly Raspbian) is the most popular. The Raspberry Pi OS is based on the
Debian release of Linux. Linux is great for critical applications because it focuses on security and
stability instead of mainstream operating systems that focus on ease of use. Linux is also
lightweight and less resource intensive than commercial operating systems. The Raspberry Pi OS
has two different versions – a version with a desktop and command line interface, or a lightweight
version with just a command line interface.

PROGRAMMING THE RASPBERRY PI


One of the goals of the creators of the Raspberry Pi was to create a computing platform that would
allow people with no background in computer science or programming to learn how to use and
program a computer.
CS3691 EMBEDDED SYSTEMS AND IOT

The Raspberry Pi is an amazing feat of engineering and anyone interested in programming or


building electronics projects should consider learning how to use it. There are hundreds of
microcontroller and development boards out there, but the Raspberry Pi combines all of those
functions on a device the size of a credit card. It was created so that computing could be more
accessible for everyone -- it is relatively inexpensive, and anyone could simply connect a monitor,
keyboard, and mouse to get started. As sensors, actuators and other devices can be easily attached
to it via its handy General purpose Input Output (GPIO) connector, it also serves as a gentle
introduction into physical computing.
The programming language such as Python is executed directly using an interpreter, rather than
needing to go through a compiler. The code is read one at a time, where each statement is translated
into machine language and then executed. While a compiler scans the entire program and translates
it as a whole into machine code, an interpreter translates the program one statement at a time.

• Enter the following code into the IDE.


• Click on Save
• Name this file and click OK
• Click on Run
• Down the bottom in the IDE, you will see the output here.

• Another way to write and run python programs is through the terminal. To access the
terminal, click on the terminal icon up the top left-hand corner.
• Type the following command: nano helloworld.py
• Enter the following code
• Press CTRL+O to save
• Press CTRL+X to exit

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
INTERFACING SENSORS WITH RASPBERRY PI
DATE

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

HARDWARE & SOFTWARE TOOLS REQUIRED:

S.No Hardware & Software Requirements Quantity

1 Thonny IDE 1
2 Raspberry Pi Pico Development Board 1
3 Jumper Wires few
4 Micro USB Cable 1

5 IR Sensor 1

6 Ultrasonic sensor 1

PROCEDURE

1. Enter the following code into the IDE.


2. Click on Save
3. Name this file and click OK
4. Click on Run
5. Down the bottom in the IDE, you will see the output here.
6. Another way to write and run python programs is through the terminal. To access the
terminal, click on the terminal icon up the top left-hand corner.
7. Type the following command: nano helloworld.py
8. Enter the following code
9. Press CTRL+O to save
10. Press CTRL+X to exit
CS3691 EMBEDDED SYSTEMS AND IOT

PROGRAM:

Import RPi.GPIO as GPIO


import time
sensor = 16
buzzer = 18

GPIO.setmode(GPIO.BOARD)
GPIO.setup(sensor,GPIO.IN)
GPIO.setup(buzzer,GPIO.OUT)
GPIO.output(buzzer,False)
print "IR Sensor Ready ....

try:
while True:
if GPIO.input(sensor):
GPIO.output(buzzer,True)
print "Object Detected"
while GPIO.input(sensor):
time.sleep(0.2)
else:
GPIO.output(buzzer,False)

except KeyboardInterrupt:
GPIO.cleanup()
CS3691 EMBEDDED SYSTEMS AND IOT

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO: COMMUNICATE BETWEEN ARDUINO AND


DATE RASPBERRY PI

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

HARDWARE & SOFTWARE TOOLS REQUIRED:

S.No Hardware & Software Requirements Quantity

1 Thonny IDE 1
2 Raspberry Pi Pico Development Board 1
3 Arduino Uno Development Board 1
4 Jumper Wires few
5 Micro USB Cable 1
6 Bluetooth Module 2

PROGRAM:
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);
}
CS3691 EMBEDDED SYSTEMS AND IOT

CONNECTIONS:

Arduino UNO Pin Arduino Development Board Bluetooth Module


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

SLAVE
RASPBERRY PI PICO
from machine import Pin, UART
uart = UART(0, 9600)
led = Pin(16, Pin.OUT)

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')
CS3691 EMBEDDED SYSTEMS AND IOT

CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


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

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

Ex. No:
SETUP A CLOUD PLATFORM TO LOG THE DATA
Date:

AIM:
To set up a cloud platform to log data from Arduino and Raspberry Pi to use cloud services like
Amazon Web Services (AWS), Google Cloud Platform (GCP), or Microsoft Azure.

APPARATUS & SOFTWARE REQUIRED:

Arduino, Raspberry Pi, PC with internet.

THEORY:

1. Create an AWS Account:

If you don't have an AWS account, sign up for one at https://aws.amazon.com/. AWS offers a free
tier with limited usage, which is suitable for small-scale projects.

2. Set Up IoT Core:

AWS IoT Core is a managed cloud service that allows you to connect devices to the cloud. You
can use it to securely communicate with your Arduino and Raspberry Pi.

a. In the AWS Management Console, navigate to the AWS IoT Core service.

b. Create a new IoT Thing for each of your devices (Arduino and Raspberry Pi) and generate
security certificates and policies to enable secure communication.

3. Connect Your Devices:

Install the necessary libraries and scripts on your devices to establish MQTT or HTTP(S)
communication with AWS IoT Core. AWS provides SDKs and documentation for various
programming languages.

4. Set Up Data Logging:

a. Create an Amazon S3 bucket to store your data. This is where your data will be logged.

b. Create an AWS Lambda function to process incoming data and store it in your S3 bucket. You
can trigger this Lambda function when data is sent to AWS IoT Core.

c. Configure AWS IoT Core to route incoming data to the Lambda function.

5. Visualize Data (Optional):


CS3691 EMBEDDED SYSTEMS AND IOT

You can set up data visualization and analysis tools to make sense of your data. AWS offers
services like Amazon Quick Sight or Amazon Sage Maker for this purpose.

6. Monitor and Manage:

Set up monitoring and alerts using AWS CloudWatch to keep an eye on your data logging system's
health and performance. This is a high-level overview, and the exact steps may vary depending on
the cloud platform you choose. You can follow similar steps on other cloud platforms like Google
Cloud or Azure, but the specific services and configurations will be different. Make sure to review
the documentation and pricing details of the cloud platform you choose to understand the costs
associated with data storage and data transfer to ensure it aligns with your project's requirements
and budget.

PROGRAM:
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Generated code. DO NOT EDIT!
#
# Snippet for CopyLogEntries
# NOTE: This snippet has been automatically generated for illustrative purposes only.
# It may require modifications to work in your environment.
CS3691 EMBEDDED SYSTEMS AND IOT

# To install the latest published package dependency, execute the following:


# python3 -m pip install google-cloud-logging

# [START logging_v2_generated_ConfigServiceV2_CopyLogEntries_async]
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import logging_v2

async def sample_copy_log_entries():


# Create a client
client = logging_v2.ConfigServiceV2AsyncClient()

# Initialize request argument(s)


request = logging_v2.CopyLogEntriesRequest(
name="name_value",
destination="destination_value",
)

# Make the request


operation = client.copy_log_entries(request=request)

print("Waiting for operation to complete...")


CS3691 EMBEDDED SYSTEMS AND IOT

response = (await operation).result()

# Handle the response


print(response)

# [END logging_v2_generated_ConfigServiceV2_CopyLogEntries_async]
CS3691 EMBEDDED SYSTEMS AND IOT

RESULT:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

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

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

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'
CS3691 EMBEDDED SYSTEMS AND IOT

CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


LCD Module
Pin Development Board
- 5V VCC
- GND GND
GP0 - SDA
GP1 - SCL

# 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)
CS3691 EMBEDDED SYSTEMS AND IOT

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:
CS3691 EMBEDDED SYSTEMS AND IOT
CS3691 EMBEDDED SYSTEMS AND IOT

EXP NO:
Design an IOT-based system
DATE

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

HARDWARE & SOFTWARE TOOLS REQUIRED:

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

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)
CS3691 EMBEDDED SYSTEMS AND IOT

CONNECTIONS:

Raspberry Pi Pico Raspberry Pi Pico


Pin Development Board
GP16 LED 1
CS3691 EMBEDDED SYSTEMS AND IOT

# 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:
CS3691 EMBEDDED SYSTEMS AND IOT

You might also like