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

ESIoT Manual

ESIOT lab essentials
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

ESIoT Manual

ESIOT lab essentials
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 87

TABLE OF CONTENTS

Page Faculty
Sl.No Date PRACTICAL EXERCISES
Number Signature

Write 8051 Assembly Language experiments using


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

Explore different communication methods with IoT devices


6.
(Zigbee, GSM, Bluetooth)

Introduction to Raspberry PI platform and python


7.
programming

8. Interfacing sensors with Raspberry PI

Communicate between Arduino and Raspberry PI using


9.
any wireless medium

10. Setup a cloud platform to log the data

Log Data using Raspberry PI and upload to the cloud


11.
platform

12. Design an IOT based system


State the vision and mission of the department

Vision of the Institute

To be a leader in imparting quality technical education, research & enterprising skills in pursuit of professional excellence.

Mission of the Institute

 T o promote quality education & technical skills to meet the industry requirements
 To incorporate team work, leadership skills & lifelong learning
 To facilitate career development & higher education assistance
 To encourage innovative ideas for research & development and entrepreneurship for societal needs
 To inculcate ethical responsibility & human values

Vision of the Department

To achieve academic excellence in the field of Electronics and Communication


Engineering and to produce meritorious engineers with human values by imparting high quality technical
education

Mission of the Department

 To create efficient Electronics and Communication Engineers to meet the current and future
demands of industry and society with ethical values
 To instill the quality of leadership and entrepreneurship in students
 To elevate the spirit of innovation and creativity among students towards research and
development
PROGRAMME OUTCOMES

1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an
engineering specialization to the solution of complex engineering problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering problems
reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and design system
components or processes that meet the specified needs with appropriate consideration for the public health and safety,
and the cultural, societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research methods including
design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid
conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools
including prediction and modeling to complex engineering activities with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health, safety,
legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering solutions in societal and
environmental contexts, and demonstrate the knowledge of, and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering
practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams, and in
multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the engineering community and
with society at large, such as, being able to comprehend and write effective reports and design documentation, make
effective presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the engineering and management
principles and apply these to one’s own work, as a member and leader in a team, to manage projects and in
multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent and life-
long learning in the broadest context of technological change.
Program Educational Objectives (PEOs)

PEO-I: Futuristic Learning:


Graduates will attain excellence in the field of Electronics and Communication
Engineering through lifelong learning process by imbibing the new technologies.

PEO-II: Career Development:


Graduates will become successful engineers or researchers or entrepreneurs with social responsibilities.

PEO-III: Professionalism:
Graduates will excel as estimable engineers with ethics, effective communication and leadership skills.

Program Specific Outcomes (PSO):

Graduates will be able to

PSO1: Identify, analyze and provide solutions to the complex engineering problems in the areas of communication,
networking, signal processing and embedded systems with the societal needs in considerations.

PSO2: Apply the contextual knowledge of Electronics and Communication Engineering to design systems containing
electrical/electronic devices, software and hardware using modern tools and techniques.
WRITE 8051 ASSEMBLY LANGUAGE EXPERIMENTS USING SIMULATOR
EXP NO: 1

DATE :

AIM:

To perform assembly language experiment using simulator

SOFTWARE USED:

Keil uvision5

PROGRAM:
org 00h
sjmp start
org 30h
start:
mov r0,#30h //source address
mov r1,#40h //destination address
mov r7,#05h //Number of bytes to be moved
back: mov a,@r0
mov @r1,a
inc r0
inc r1
djnz r7,back //repeat till all data transferred
end

OUTPUT:

Page | 5
RESULT:

Thus the assembly language program was performed and got output successfully.

Page | 6
TEST DATA TRANSFER BETWEEN REGISTERS AND MEMORY
EXP NO: 2

DATE :

AIM:

To perform data transfer between registers and memory experiment.

SOFTWARE USED:

Keil uvision5

PROGRAM:
ORG 0000
Mov R0,#40H
Mov R1,#51H
Mov a,@R0
Mov R2,A
INC R0
Back : Mov A,@R0
Xch A ,@R1
Mov @R0,A
INC R0
INC R1
DjnZ R2,Back
END

Page | 7
OUTPUT:

RESULT:

Thus the data transfer between registers and memory experiment was performed and
got output successfully.

Page | 8
PERFORM ALU OPERATIONS
EXP NO: 3

DATE :

AIM:

To perform addition, substraction, multiplication, division experiment.

SOFTWARE USED:

Keil uvision5

PROGRAM:

org 0000H
mov a,#25H
mov b,#12H
add a,b
mov 40H,a
mov a,#25H
subb a,b
mov 41H,a
mov a,#25H
mul ab
mov 42H,a
mov 43H,b
mov a,#25H
mov b,#12H
div ab
mov 44H,a
mov 45h,b
mov a,#25H
Inc a
mov 46H,a
Dec a
mov 47H,a
end

Page | 9
ADDITION

SUBTRACTION

Page | 10
MULTIPLICATION

DIVISION

RESULT:

Thus the ALU operation was performed and got output successfully.

Page | 11
WRITE BASIC AND ARITHMETIC PROGRAMS USING EMBEDDED C

EXP NO: 4

DATE :

AIM:

To perform addition, substraction, multiplication, division experiment.

SOFTWARE USED:

Keil uvision5

PROGRAM:
#include<stdio.h>
int main()
{

int a=6, b=2, c, d, e, f, g;


c=a+b;
d=a-b;
e=a*b;
f=a/b;
g=a%b;
return 0;
}

Page | 12
OUTPUT:

RESULT:

Thus the arithmetic programs using embedded C was performed and got output
successfully.

Page | 13
INTRODUCTION TO ARDUINO PLATFORM AND PROGRAMMING

EXP NO: 5

DATE :

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 the students with the non-technical background.

The designs of Arduino boards use a variety of controllers and microprocessors.

The Arduino board consists of sets of analog and digital I/O (Input / Output) pins, which are
further interfaced to breadboard, expansion boards, and other circuits. Such boards feature
the model, Universal Serial Bus (USB), and serial communication interfaces, which are used
for loading programs from the computers.

Features

The features of Arduino are listed below:

o Arduino programming is a simplified version of C++, which makes the learning process
easy.
o The Arduino IDE is used to control the functions of boards. It further sends the set of
specifications to the microcontroller.
o Arduino does not need an extra board or piece to load new code.
o Arduino can read analog and digital input signals.
o The hardware and software platform is easy to use and implement.

Arduino Download

The Arduino software (IDE) is open-source software. We are required to write the code and
upload the code to the board to perform some task.

Page | 14
The Arduino IDE software can be used with any type of Arduino boards. The software is
available for various operating system such as, Windows, Linux, and Mac OS X.

The steps to download the Arduino software are listed below:

1. Go to the official website of Arduino (https://www.arduino.cc/) > Click on SOFTWARE <


click on DOWNLOADS, as shown below:

Or

Open the URL https://www.arduino.cc/en/Main/Software

2. A page will appear, as shown below:

Page | 15
3. Scroll the screen a little, as shown below:

4. Click on the 'Windows Installer' as we are operating with the Windows. We can select
the Linux or Mac OS X, accordingly.

5. A contribution window will appear. We can contribute according to our choice and click on
the 'CONTRIBUTE &DOWNLOAD' option. Otherwise, click on the 'JUST
DOWNLOAD' option, as shown below:

Page | 16
6. The downloading process will start. The downloading file will look like the below image:

7. Wait for few seconds for the downloading process to complete.

8. Open the downloaded file.

9. Grant permission to the Arduino Software on your computer.

10. Accept the license by clicking on 'I Agree' button, as shown below:

Page | 17
11. Click on the 'Next' button. It is shown below:

12. The window specifying the location of the installed folder will appear.

Click on the 'Install' button. It is shown below:

Page | 18
If you want to change the location, click on the 'Browse' button.

13. The installing process of Arduino will start, as shown below:

Wait for the installation process to complete.

14. Now, we have to accept the security for the installation. We are required to accept the
security Installation three times.

Click on the 'Install' button. The image is shown below:

Page | 19
15. Again, click on the 'Install' button. It is shown below:

16. Again, click on the 'Install' button. It is shown below:

17. The installation process is now completed. The window will now appear as:

Page | 20
18. Click on the 'Close' button at the bottom.

The Arduino IDE software will appear on your desktop, as shown below:

19. Now, open the Arduino software.

20. The Arduino IDE environment is written in the programming language named as Java. So,
we need to allow access to the Java Platform.

As soon we open the Arduino software, a license window will appear, as shown below:

Page | 21
Accept the license by clicking on the 'Allow access' button.

21. The Arduino window will appear as:

Visibility of the connected Hardware port

We can view the port of the attached hardware Arduino IDE to our computer.

Page | 22
The steps are listed below:

1. Go to the File Manager and right-click on the This PC option, as shown below:

2. Click on the Manage


3. First, we need to connect the Arduino board to our computer.
4. A window will appear, as shown below:

5. Click on the Device Manager


6. Under the PORT option, we can see the ports of the connected hardware.

( OR )

we will learn in easy steps, how to set up the Arduino IDE on our computer and prepare the
board to receive the program via USB cable.

Step 1 − First you must have your Arduino board (you can choose your favorite board) and a
USB cable. In case you use Arduino UNO, Arduino Duemilanove, Nano, Arduino Mega 2560,
or Diecimila, you will need a standard USB cable (A plug to B plug), the kind you would
connect to a USB printer as shown in the following image.

Page | 23
In case you use Arduino Nano, you will need an A to Mini-B cable instead as shown in the
following image.

Step 2 − Download Arduino IDE Software.

You can get different versions of Arduino IDE from the Download page on the Arduino
Official website. You must select your software, which is compatible with your operating
system (Windows, IOS, or Linux). After your file download is complete, unzip the file.

Page | 24
Step 3 − Power up your board.

The Arduino Uno, Mega, Duemilanove and Arduino Nano automatically draw power from
either, the USB connection to the computer or an external power supply. If you are using an
Arduino Diecimila, you have to make sure that the board is configured to draw power from the
USB connection. The power source is selected with a jumper, a small piece of plastic that fits
onto two of the three pins between the USB and power jacks. Check that it is on the two pins
closest to the USB port.

Connect the Arduino board to your computer using the USB cable. The green power LED
(labeled PWR) should glow.

Step 4 − Launch Arduino IDE.

After your Arduino IDE software is downloaded, you need to unzip the folder. Inside the
folder, you can find the application icon with an infinity label (application.exe). Double-click
the icon to start the IDE.

Step 5 − Open your first project.

Once the software starts, you have two options −

 Create a new project.


 Open an existing project example.

To create a new project, select File → New.

Page | 25
To open an existing project example, select File → Example → Basics → Blink.

Here, we are selecting just one of the examples with the name Blink. It turns the LED on and
off with some time delay. You can select any other example from the list.

Step 6 − Select your Arduino board.

To avoid any error while uploading your program to the board, you must select the correct
Arduino board name, which matches with the board connected to your computer.

Page | 26
Go to Tools → Board and select your board.

Here, we have selected Arduino Uno board according to our tutorial, but you must select the
name matching the board that you are using.

Step 7 − Select your serial port.

Select the serial device of the Arduino board. Go to Tools → Serial Port menu. This is likely
to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To
find out, you can disconnect your Arduino board and re-open the menu, the entry that
disappears should be of the Arduino board. Reconnect the board and select that serial port.

Page | 27
Step 8 − Upload the program to your board.

Before explaining how we can upload our program to the board, we must demonstrate the
function of each symbol appearing in the Arduino IDE toolbar.

A − Used to check if there is any compilation error.

B − Used to upload a program to the Arduino board.

C − Shortcut used to create a new sketch.

D − Used to directly open one of the example sketch.

E − Used to save your sketch.

F − Serial monitor used to receive serial data from the board and send the serial data to the
board.

Now, simply click the "Upload" button in the environment. Wait a few seconds; you will see
the RX and TX LEDs on the board, flashing. If the upload is successful, the message "Done
uploading" will appear in the status bar.

Note − If you have an Arduino Mini, NG, or other board, you need to press the reset button
physically on the board, immediately before clicking the upload button on the Arduino
Software.

SIMPLE PROGRAM:

Structure
Arduino programs can be divided in three main parts: Structure, Values (variables and
constants), and Functions. In this tutorial, we will learn about the Arduino software program,
step by step, and how we can write the program without any syntax or compilation error.
Let us start with the Structure. Software structure consist of two main functions −

 Setup( ) function

Page | 28
 Loop( ) function

Void setup ( ) {

}
 PURPOSE − The setup() function is called when a sketch starts. Use it to initialize the
variables, pin modes, start using libraries, etc. The setup function will only run once,
after each power up or reset of the Arduino board.
Void Loop ( ) {

}
 PURPOSE − After creating a setup() function, which initializes and sets the initial
values, the loop() function does precisely what its name suggests, and loops
consecutively, allowing your program to change and respond. Use it to actively control
the Arduino board.

Example:
To control the joystick sensors using Arduino Uno board.

Page | 29
III
ECE

Components required:

S.NO APPARATUS RANGE QUANTITY


B
1 Arduino board Uno 5 VOLT DC 1
2 Joystick sensor 1
3 USB cable 1
4 Jumber wires AS PER PINS

Hardware Procedure:

• Connect the USB to the ArduinoUno kit.


• Connect the Joystick sensor pins using jumping wires.
• Connect properly the pins both the sensors and Arduino Uno kit.
• Find the outputs on the serial monitor/serial plotter.

SoftwareProcedure:

1. Click on ArduinoIDE

2. Click on file

3. Click on New

4. Write a Programme as given as per in the source.

5. Click on Save

6. Click on Verify

7. Click on Upload the code in to ArduinoUno by using USB cable.

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
ECE

Program:
B
int xpin = A0;
Int ypin = A1;
int swpin = 2;

void setup()
{
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(2,INPUT);
}

void loop()
{
int xdata = analogRead(A0);
int ydata = analogRead(A1);
int swdata = digitalRead(2);

Serial.print("xdata:");
Serial.println(xdata);
Serial.print("\t");
Serial.print("ydata:");
Serial.println(ydata);
delay(1000);
}

RESULT:
Thus the Introduction to arduino platform and Joystick sensor output by using Arduino Uno software.

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
ECE

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
EXPLORE DIFFERENT COMMUNICATION METHODS WITH IOT DEVICES (ZIGBEE,
ECE
GSM, BLUETOOTH)

EXP NO: 6

DATE :
B

Zigbee
ZigBee is similar to Bluetooth and is majorly used in industrial settings. It has some significant
advantages in complex systems offering low-power operation, high security, robustness and
high and is well positioned to take advantage of wireless control and sensor networks in IoT
applications.
The latest version of ZigBee is the recently launched 3.0, which is essentially the unification of
the various ZigBee wireless standards into a single standard.

Iot Technology – ZigBee

Bluetooth
An important short-range IoT communications Protocols / Technology. Bluetooth, which has
become very important in computing and many consumer product markets. It is expected to be
key for wearable products in particular, again connecting to the IoT albeit probably via a
smartphone in many cases.
The new Bluetooth Low-Energy (BLE) – or Bluetooth Smart, as it is now branded – is a
significant protocol for IoT applications. Importantly, while it offers a similar range to
Bluetooth it has been designed to offer significantly reduced power consumption.

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
ECE

Iot Technology – Bluetooth

How to Set Up and Test Arduino Bluetooth Connection

This works with android phones and the HC-05 and HC-06 bluetooth modules, as well as pretty
much any arduino or arduino clone.

Pretty straightforward, connect the bluetooth module to the arduino like so

RX-pin2

TX-pin 3

GND-GND

VCC-5v

Step 2: Plug in the Arduino and Upload the Sketch

Download the ino file and upload it to the arduino.

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
ECE

Step 3: Connect to the Bluetooth on Your Phone

Open up the bluetooth settings on your phone and look for the module. Mine is named Sailfish
but yours should be named either hc-05 or hc-06. The password is almost always 1234, if not,
try 0000.

Step 4: Connect to the Bluetooth Module

download a bluetooth terminal app from the appstore, this one works great:
https://play.google.com/store/apps/details?id=Qwerty.BluetoothTerminal&hl=en and open it
up. Open the app, hit connect to a device - insecure and select your bluetooth module from the
list.

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
ECE

Step 5: Ready to Go!

Finally open up the Serial Monitor in the arduino IDE by hitting the magnifying glass in the top
right corner, and you should be good to go. You now have a back and forth extremely simple
connection between your phone and your arduino via bluetooth.

Program:

char data = 0; //Variable for storing received data

void setup()
{
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}

void loop()
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data and store it into variable data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n"); //New line
if(data == '1') //Checks whether value of data is equal to 1
digitalWrite(13, HIGH); //If value is 1 then LED turns ON
else if(data == '0') //Checks whether value of data is equal to 0
VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2
III
ECE

digitalWrite(13, LOW); //If value is 0 then LED turns OFF


}
}
B
Cellular
Any IoT application that requires operation over longer distances can take advantage of
GSM/3G/4G cellular communication capabilities. While cellular is clearly capable of sending
high quantities of data, especially for 4G, the cost and also power consumption will be too high
for many applications.
But it can be ideal for sensor-based low-bandwidth-data projects that will send very low
amounts of data over the Internet.

RESULT:

Thus the different communication methods with IOT devices(Zigbee, Gsm, Bluetooth) was studied successfully.
VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2
III
ECE

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
ECE

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


INTRODUCTION TO RASPBERRY PI PLATFORM AND PYTHONIIIPROGRAMMING
ECE

EXP NO: 7

DATE :

Raspberry Pi - Introduction
Raspberry Pi, developed by Raspberry Pi Foundation in association with Broadcom, is a
series of small single-board computers and perhaps the most inspiring computer available
today.
From the moment you see the shiny green circuit board of Raspberry Pi, it invites you to
tinker with it, play with it, start programming, and create your own software with it. Earlier,
the Raspberry Pi was used to teach basic computer science in schools but later, because of its
low cost and open design, the model became far more popular than anticipated.
It is widely used to make gaming devices, fitness gadgets, weather stations, and much more.
But apart from that, it is used by thousands of people of all ages who want to take their first
step in computer science.
It is one of the best-selling British computers and most of the boards are made in the Sony
factory in Pencoed, Wales.
Generations and Models
In 2012, the company launched the Raspberry Pi and the current generations of regular
Raspberry Pi boards are Zero, 1, 2, 3, and 4.
Generation 1 Raspberry Pi had the following four options −
 Model A
 Model A +
 Model B
 Model B +
Among these models, the Raspberry Pi B models are the original credit-card sized format.
On the other hand, the Raspberry Pi A models have a smaller and more compact footprint and
hence, these models have the reduced connectivity options.
Raspberry Pi Zero models, which come with or without GPIO (general-purpose input output)
headers installed, are the most compact of all the Raspberry Pi boards types.
Speed Specifications

The table below gives the speed specifications of various Raspberry Pi models and
generations focusing on the version‟s release date, form factor and dimensions −

Raspberry Pi Version Release Date Form Factor Dimensions (in mm)

Raspberry Pi 4 Model B 2019-2020 Standard 85.6 x 56.5

Raspberry Pi 3 Model B+ 2018 Standard 85.6 x 56.5

Raspberry Pi 3 Model B 2016 Standard 85.6 x 56.5

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
ECE

Raspberry Pi 3 Model A+ 2018 Compact 65 x 56.5

Raspberry Pi Zero 2017 Mini 65 x 30 x 5


Wireless with Headers B

Raspberry Pi Zero 2016 Mini 65 x 30 x 5


Wireless

Raspberry Pi Zero 2015 Mini 65 x 30 x 5

Raspberry Pi 2 Model B 2015 Standard 85.6 x 56.5

Raspberry Pi 1 Model B + 2014 Standard 85.6 x 56.5

Raspberry Pi 1 Model B 2012 Standard 85.6 x 56.5

Raspberry Pi 1 Model A+ 2014 Compact 65 x 56.5

Raspberry Pi 1 Model A 2013 Standard 85.6 x 56.5


The table below gives the speed specifications of various Raspberry Pi models and
generations focusing on the version‟s weight, General Purpose Input/Output (GPIO),
central processing unit (CPU) speed, Cores and Random-access memory (RAM) −

Raspberry Weight (in


GPIO CPU Speed Cores RAM
Pi Version grams)

Raspberry
Pi 4 Model 46 40 Pin 1.5 GHz Quad 1,2,4, or 8 GB
B

Raspberry
Pi 3 Model 50 40 Pin 1.4 GHz Quad 1 GB
B+

Raspberry
Pi 3 Model 40 40 Pin 1.2 GHz Quad 1 GB
B

Raspberry
Pi 3 Model 28 40 Pin 1.4 GHz Quad 512 MB
A+

Raspberry 10 40 Pin 1 GHz Single 512


Pi Zero

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
ECE

Wireless MB
with
Headers
B

Raspberry
40 Pin 512
Pi Zero 10 1 GHz Single
Unpopulated MB
Wireless

Raspberry 40 Pin 512


8 1 GHz Single
Pi Zero Unpopulated MB

Raspberry
Pi 2 Model 42 40 Pin 1.2 1 GB
Quad
B GHz

Raspberry
700 512
Pi 1 Model 42 40 Pin Single
MHz MB
B+

Raspberry
21 Pin (26 700 512
Pi 1 Model 38 Single
Pin Header) MHz MB
B

Raspberry
700 512
Pi 1 Model 23 40 Pin Single
MHz MB
A+

Raspberry
21 Pin (26 700 256
Pi 1 Model 30 Single
Pin Header) MHz MB
A

Connectivity Specifications
The table below gives the connectivity specifications of various Raspberry Pi boards focusing on
the version‟s full sized USB ports, other USB and charge methods, power and High-Definition
Multimedia Interface (HDMI) ports –

Raspberry Pi Full sized USB Other USB & Power HDMI Ports
Version Ports Charge Methods

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
ECE

Raspberry Pi 2 USB3.0 2 1 USB-C 5.1V at 3A 2 micro-HDMI


4 Model B USB2.0
B
Raspberry Pi 4 USB2.0 1 MIcroUSB 5.1V at HDMI, Composite (TRRS)
3 Model B+ 2.5A

Raspberry Pi 4 USB2.0 1 MIcroUSB 5.1V at HDMI, Composite (TRRS)


3 Model B 2.5A

Raspberry Pi 1 USB2.0 1 MIcroUSB 5.1V at 3A HDMI, Composite (TRRS)


3 Model A+

Raspberry Pi 1 MIcroUSB 5.1V at Mini-HDMI, GPIO Composite


Zero Wireless 1.2A
with Headers

Raspberry Pi 1 MIcroUSB 5.1V at Mini-HDMI, GPIO Composite


Zero Wireless 1.2A

Raspberry Pi 1 MIcroUSB 5.1V at Mini-HDMI, GPIO Composite


Zero 1.2A

Raspberry Pi 4 USB2.0 1 MIcroUSB 5.1V at HDMI, Composite (TRRS)


2 Model B 1.8A

Raspberry Pi 4 USB2.0 1 MIcroUSB 5.1V at HDMI, Composite (TRRS)


1 Model B + 1.2A

Raspberry Pi 2 USB2.0 1 MIcroUSB 5.1V at 3A PAL and NTSC, HDMI or DSI,


1 Model B RCA

Raspberry Pi 1 USB2.0 1 MicroUSB or 5.1V at HDMI, Composite (TRRS)


1 Model A+ GPIO 700mA

Raspberry Pi 1 1 MicroUSB or 5.1V at PAL and NTSC, HDMI


1 Model A USB2.0 GPIO 700mA or DSI, RCA

VELAMMALINSTITUTE OFTECHNOLOGY,DEPT OFE.C.E Page 2


III
ECE

The table below gives the connectivity specifications of various Raspberry Pi boards
focusing on the version‟s video out quality, video in, Ethernet, bluetooth, Wi-Fi and
external storage –
B

Raspberry Video Out Video In Ethernet Bluetooth Wi-Fi External Storage


Pi Version Quality

Raspberry 4kp60 CSI Camera Gigabit Bluetooth 5.0 Dual Band- MicroSD
Pi 4 Connector Ethernet 2.4 GHz and
Model B 5GHz

Raspberry 1080p60 CSI Camera 10/100 Bluetooth Dual Band- MicroSD


Pi 3 Connector Mbit/s 4.2/BLE 2.4 GHz and
Model B+ 5GHz

Raspberry 1080p60 CSI Camera 10/100 Bluetooth 4.1 2.4 GHz MicroSD
Pi 3 Connector Mbit/s
Model B

Raspberry 1080p60 CSI Camera Bluetooth Dual Band- MicroSD


Pi 3 Connector 4.2/BLE 2.4 GHz and
Model A+ 5GHz

Raspberry 1080p60 CSI Camera Bluetooth 4.1 2.4 GHz MicroSD


Pi Zero Connector
Wireless
with
Headers

Raspberry 1080p60 CSI Camera Bluetooth 4.1 2.4 GHz MicroSD


Pi Zero Connector
Wireless

Raspberry 1080p60 CSI Camera MicroSD


Pi Zero Connector

Raspberry 1080p60 CSI Camera 10/100 MicroSD


Pi 2 Connector Mbit/s
Model B

Page | 37
III
ECE

Raspberry 1080p60 CSI Camera 10/100 MicroSD


Pi 1 Connector Mbit/s
Model B
B
+

EXAMPLE: Smallest and largest number in a


Array in Python

largest:

l=[2,5,9,8]

max=l[o]

for i in range(len(l));

if l[i]>max;

max=l[i]

print(max)

smallest:

l=[2,5,9,8]

min=l[o]

for i in range(len(l));

if l[i]<min;

min=l[i]

print(min)

RESULT:

Thus the introduction to raspberry pi platform and python programming was studied successfully.
Page | 38
III
INTERFACING SENSORS WITH RASPBERRY PI
ECE

EXP NO: 8

DATE :

The Raspberry Pi IR Sensor Interface can be converted into a Proximity Detector, where the
application will detect if the object is too close to the sensor.

Circuit Diagram
The following image shows the connection diagram of Interfacing IR Sensor with Raspberry Pi.
You have already seen the circuit diagram of the IR Sensor Module.

Components Required
 Raspberry Pi 3 Model B
 IR Sensor
 5V Buzzer
 Mini Breadboard
 Connecting Wires
 Power Supply
 Computer

Circuit Design
The IR Sensor Module has only three Pins: VCC, GND and Data. Connect the VCC and GND
pins of the IR Sensor to +5V and GND pins of the Raspberry Pi.

Then connect the Data pin of the IR Sensor to GPIO23 i.e. Physical Pin 16 of the Raspberry Pi.

Page | 39
III
ECE

In order to indicate the alarm, I have used a simple 5V Buzzer. Connect one terminal of the
buzzer to GND of Raspberry Pi and the other terminal (usually marked +) to GPIO24 i.e.
Physical Pin 18 of Raspberry Pi.
B

Code
The following is the code for interfacing IR Sensor with Raspberry Pi. It is written in Python.

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

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

Working
We have learned how to interface an IR Sensor with Raspberry Pi. I‟ll now explain the working
of the project.

All the magic happens in the IR Sensor Module. As it is a Reflective type IR Sensor, whenever
an object is placed in front of the sensor, the Infrared light from the IR LED gets reflected back
after hitting the object and falls on the Photo Diode.

The photo diode then starts conducting. As a result, the voltage at the non-inverting input of the
LM358 will be greater than that at the inverting input.

Page | 40
III
ECE

Since the LM358 is acting as a Comparator, its output will become HIGH and the on-board
LED glows. The HIGH on the Data Pin is detected by the Raspberry Pi and it activates the
buzzer.
B

Using the 10 KΩ Potentiometer, you can adjust how far the object can be placed in front of the
sensor in order to detect.

Applications
As mentioned in the earlier sections, Proximity Sensor or Obstacle Detection is the main
application of interfacing IR Sensor with Raspberry Pi. Some of the common applications
include:

 Contactless Tachometer
 Line Follower Robot
 Obstacle Avoiding Robot
 Car Reverse Sensor
 Mobile Proximity Sensor

RESULT:

Thus the Interfacing Sensors with Raspberry Pi was studied successfully

Page | 41
III
COMMUNICATE BETWEEN ARDUINO AND RASPBERRY
ECEPI USING ANY

WIRELESS MEDIUM
EXP NO: 9

DATE : B

1. Summary:
 The process of how to communicate an Arduino and a Raspberry Pi with nRF24L01 module.
To Start off We will be learning Some basics of Raspberry Pi then we will have a look at
Headless Raspberry Pi setup. For the Implementation firstly, we will understand the simple
communication of Arduino to Arduino then we will learn Arduino to the raspberry pi.

2. Required Components:
 Ultrasonic Sensor
 2 Arduino Uno
 Raspberry Pi 3
 2 nRF24l01 transmitter and receiver
 Jump wires
 Arduino cable
 MINI USB 2.0 for Pi
 Breadboard

3. Required Software:
 Raspbian for pi
 Arduino IDE or Visual Studio
 Putty on a remote computer for SSH
 VNC viewer on a remote computer

4. Introduction to Raspberry Pi 3:

Page | 42
III
ECE

4.1. Components Specifications:


 1.4 GHz 64-bit quad-core ARM Cortex-A53, 1GB RAM
 2.4/5Ghz dual-band 802.11ac Wireless LAN, 10/100/1000Mbps Ethernet Bluetooth 4.2
 4 USB ports, Full HDMI port, Combined 3.5mm audio jack and composite video port,
40 GPIO pins
 Micro SD card slot, Video Core IV 3D graphics core, Camera interface (CSI), Display
interface (DSI)
4.2 Raspberry Pi Pinout:

Page | 43
III
ECE

4.3. Headless Raspberry Pi Setup:


 Say, I just bought a raspberry pi and wish to check out how it works. But all I have is
my Laptop, the Pi, a micro SD card, and my Wi-Fi network. How do I connect and
control the Pi? B
1) Download Raspbian:
 Your Pi needs an OS. Download Raspbian from Raspberrypi.org „s download section:
 https://www.raspberrypi.org/downloads/raspbian/

2) Download SD Memory Card Formatter:


 It is used to format the SD card as it is needed that the SD card should be empty before
the flashing image you downloaded. You can download it
from https://www.sdcard.org/downloads/formatter/eula_windows/

3) Flash it onto an SD card:


 You need to flash this downloaded image to the micro SD card. Assuming your laptop
has an SD card slot or a micro Sd card reader, you need a flashing software like etcher.
Go ahead and download from https://etcher.io/

Page | 44
III
ECE

4) Configure Wi-Fi:
 It‟s easier to make two devices talk to each other if they are in the same network. An
ethernet cable can easily make your laptop‟s network available to the Pi. But we don‟t
have one. So, we are going to add a file to the SD card so that the Pi boots with a wifi
pre-configured.
 The SD card mounts as two volumes boot and rootfs . Open the boot volume and create
a file named wpa_supplicant.conf on booting the RPi, this file will be copied to
/etc/wpa_supplicant directory in /rootfs partition. The copied file tells the Pi the WIFI
setup information. This would overwrite any existing WIFI configuration, so if you had
already configured WIFI on the pi, then that will be overwritten.
 A typical wpa_supplicant.conf file is as follows:
ctrl_interface=DIR=/var/run/wpa_supplicant
GROUP=netdevupdate_config=1country=US
network={ ssid="«your_SSID»" psk="«your_PSK»" key_mgmt=WPA-PSK}
NOTE: Your SSID is your WIFI‟s name. And psk is the password of the WI-FI.
5) Enable SSH
 We will later access the Pi using a secured shell (SSH), SSH is disabled by default in
Raspbian. To enable SSH, create a file named ssh in the boot partition. If you are on
Linux, use the touch command to do that.

Page | 45
III
ECE

6) Find Pi‟s Ip address:


 Before switching on your raspberry pi, we need to find out the existing devices
connected to the network. Make sure your laptop is connected to the same WIFI
network as the one you configured on pi above.
 Download the Advanced IP Scanner to scan the IP of our raspberry pi. You can
download it from here https://www.advanced-ip-scanner.com/

7) SSH into your Pi:


 To create a secured shell connection in Linux we can use the ssh command. If you are
on windows, try downloading Putty from https://www.putty.org/

Page | 46
III
ECE

Default credentials are:


username: pipassword: raspberry

8) Access Pi remotely:
 Sometimes it doesn‟t feel right if we can‟t use the mouse. For that, we need to look into
the Raspbian desktop.
 We need to setup VNC (Virtual Network Connection) to see and control Pi graphically.
Let‟s do that.
 To access the remote desktop, you need VNC-viewer (client) for your laptop.
Fortunately, RealVNC is available for a lot of OSes, pick one for your OS
from https://www.realvnc.com/en/connect/download/viewer/
9) Commands for vncserver:

Page | 47
III
ECE

10) Now open VNC Viewer on your remote computer:

Page | 48
III
ECE

5. Implementation and Working:

5.1. Wireless communication of Arduino to Arduino with nRF24L01: B


 In this, we will learn how to make wireless communication between two Arduino
boards using the NRF24L01. And measure distance with ultrasonic sensor and transmit
it to another Arduino with transceiver module.
Wiring Instructions:
To wire your NRF24L01+ wireless Sender to your Arduino, connect the following pins:
 Connect the VCC pin to 3.3 Volts
 Connect the GND pin to ground (GND)
 Connect the CE pin to Arduino 9
 Connect the CSN pin to Arduino 10
 Connect the SCK pin to Arduino 13
 Connect the MOSI pin to Arduino 11
 Connect the MISO pin to Arduino 12
To wire your ultrasonic sensor to your Arduino, connect the following pins:
 Connect the VCC pin to Arduino 5Volts
 Connect the GND pin to ground (GND)
 Connect the Trig pin to Arduino 4
 Connect the Echo pin to Arduino 3

Schematic Diagram for wiring of Arduino Uno with ultrasonic sensor and NRF24L01
To wire your NRF24L01+ wireless sender to your Arduino, connect the following pins:
 Connect the VCC pin to 3.3 Volts
 Connect the GND pin to ground (GND)
Page | 49
III
ECE

 Connect the CE pin to Arduino 9


 Connect the CSN pin to Arduino 10
 Connect the SCK pin to Arduino 13
 Connect the MOSI pin to Arduino 11 B
 Connect the MISO pin to Arduino 12

Schematic Diagram for wiring of Arduino Uno NRF24L01


NOTE: RF24 module is mandatory for the code to run so you can add the library
accordingly
 Start Arduino IDE then add the Downloaded Library from Here :

Page | 50
III
ECE

5.2. Code:
Sender Side code:
Receiver Side code:
Sending the Data

Page | 51
III
ECE

Receiving the data:

6. Wireless communication of Arduino to Raspberry Pi with nRF24L01:


6.1: Installation of RF24 Module on Raspberry Pi:
 It is the most important and foremost step for any Communication to work between
Arduino and Raspberry Pi as we have used RF24 library in Arduino for communication
so the same Library is needed on Pi.

Page | 52
III
ECE

 Further are the steps to which involve the installation of the Library. It took me almost
one week to install it as no clear idea about it is present.
=> Way to go:
1. Login to Raspberry Pi using Putty. B
2. Go to the VNC server for GUI.
3. In the terminal type:
sudo raspi-config

Turn on SPI from Interfacing options in config

4. Reboot the Pi. In the terminal, type:


sudo reboot
Page | 53
III
ECE

5. In the terminal type:


sudo apt-get update
6. Download the install.sh file
B on terminal:
from http://tmrh20.github.io/RF24Installer/RPi/install.sh or Run this
wget http://tmrh20.github.io/RF24Installer/RPi/install.sh
7. Make it executable:
chmod +x install.sh
8. Run it and choose your options:

9. Run an example from one of the libraries: cdrf24libs/RF24/examples_linux


make
sudo ./gettingstarted
Run Following Commands to run the program.
10. Further, if we want to run Python Programs for the same purpose, we can do this:
Running the Example Edit the pingpair_dyn.py example to configure the appropriate
pins per the above documentation:
nano pingpair_dyn.py
 Configure another device, Arduino or RPi with the pingpair_dyn example
 Run the example
sudo python pingpair_dyn.py

Page | 54
III
ECE

6.2. Wireless communication of Arduino to Arduino with nRF24L01:


 In this, we will learn how to make wireless communication between Arduino and
Raspberry Pi using the NRF24L01. And measure distance with an ultrasonic sensor
with the help of Arduino Uno and transmit it to Raspberry Pi and Data is received.
Wiring Instructions:
To wire your NRF24L01+ wireless Sender to your Arduino, connect the following pins:
 Connect the VCC pin to 3.3 Volts
 Connect the GND pin to ground (GND)
 Connect the CSN pin to Arduino 10
 Connect the CE pin to Arduino 9
 Connect the SCK pin to Arduino 13
 Connect the MISO pin to Arduino 12
 Connect the MOSI pin to Arduino 11
To wire your ultrasonic sensor to your Arduino, connect the following pins:
 Connect the VCC pin to Arduino 5Volts
 Connect the GND pin to ground (GND)
 Connect the Trig pin to Arduino 4
 Connect the Echo pin to Arduino 3
Schematic Diagram:

Page | 55
III
ECE

Schematic Diagram for wiring of Arduino Uno with ultrasonic sensor and NRF24L01
To wire your NRF24L01+ Wireless Receiver to your Raspberry Pi, connect the
following pins:
 Connect the VCC pin to 3.3 Volts (Pin 1)
 Connect the GND pin to ground (GND) (Pin 6)
 Connect the CE pin to Raspberry GPIO 22
 Connect the CSN pin to Raspberry GPIO 8
 Connect the SCK pin to Raspberry GPIO 11
 Connect the MOSI pin to Raspberry GPIO 10
 Connect the MISO pin to Raspberry GPIO 09
Schematic Diagram:

Page | 56
III
ECE

Schematic Diagram for wiring of Raspberry Pi and NRF24L01


6.3. Code:
Sender Side Code:
Receiver Side Code:
 It's not mandatory to use this code as it is tweaked by me as per my requirement.
To check the proper functioning of your connection and code you can run the examples
present in the library like pingpair_dyn.ino on your Arduino and pingpair_dyn.py on
Raspberry Pi
 The snippet of my running communication:

Page | 57
III
ECE

RESULT:

Thus the communicate between arduino and Raspberry Pi Using Any Wireless Medium was
successfully studied.

Page | 58
III
SETUP A CLOUD PLATFORM TO LOG THE DATA
ECE

EXP NO: 10

DATE :
B

1. Creating an Arduino Account

To starting using the Arduino IoT cloud, we first need to log in or sign up to Arduino.

2. Go to the Arduino IoT Cloud

After we have signed up, you can access the Arduino IoT Cloud from any page
on arduino.cc by clicking on the four dots menu in the top right corner. You can also go
directly to the Arduino IoT Cloud.

Navigating to the cloud.

3. Creating a Thing

The journey always begin by creating a new Thing. In the Thing overview, we can choose
what device to use, what Wi-Fi network we want to connect to, and create variables that we can
monitor and control. This is the main configuration space, where all changes we make are
automatically generated into a special sketch file.

Page | 59
III
ECE

The Thing overview.

4. Configuring a Device

Devices can easily be added and linked to a Thing. The Arduino IoT Cloud requires your
computer to have the Arduino Create Agent installed. The configuration process is quick and
easy, and can be done by clicking on the “Select device” button in the Thing overview. Here,
we can choose from any board that has been configured, or select the “Configure new
device” option.

Configuring a device.
Page | 60
III
ECE

We can also get a complete overview of our devices by clicking the “Devices" tab at the top of
the Arduino IoT Cloud interface. Here we can manage and add new devices.

The device tab.

5. Creating Variables

The variables we create are automatically generated into a sketch file. There are several data
types we can choose from, such as int, float, boolean, long, char. There‟s also special
variables, such as Temperature, Velocity, Luminance that can be used. When clicking on
the “Add variable” button, we can choose name, data type, update setting and interaction
mode.

Page | 61
III
ECE

Creating variables.

6. Connecting to a Network
B
To connect to a Wi-Fi network, simply click the “Configure” button in the network section.
Enter the credentials and click “Save”. This information is also generated into your sketch file!

Entering network credentials.

7. Editing the Sketch

Now that we have configured variables, devices and network settings, we can get to
programming our devices!

An automatically generated sketch file can be found in the “Sketch” tab. It has the same
structure as a typical

.ino

file, but with some additional code to make the connection to your network and to the cloud.

A sketch that, for example, reads an analog sensor, and use the cloud variable to store it.
When the sketch has been uploaded, it will work as a regular sketch, but it will also update the
cloud variables that we use!

Additionally, each time we create a variable that has the Read & Write permission enabled, a
function is also generated, at the bottom of your sketch file. Each time this variable changes, it
will execute the code within this function! This means that we can leave most of the code out
of the loop() and only run code when needed.

To upload the program to our board, simply click the "Upload" button.

Page | 62
III
ECE

Editing a sketch in the cloud editor.

The editor also has a Serial Monitor Tool, which can be opened by clicking the magnifying
glass in the toolbar. Here you can view information regarding your connection, or commands
printed via

Serial.print()

The Serial Monitor Tool.

Page | 63
III
ECE

After we have successfully uploaded the code, we can open the “Serial Monitor” tab to view
information regarding our connection. If it is successful, it will print “connected to
network_name” and “connected to cloud”. If it fails to connect, it will print the errors here as
well. B

The cloud editor is a mirrored "minimal" version of the Web Editor. Any changes you make
will also be reflected in the Web Editor, which is more suitable for developing more advanced
sketches.

8. Creating a Dashboard

Now that we have configured the device & network, created variables, completed the sketch
and successfully uploaded the code, we can move on to the fun part: creating dashboards!

Visualize your data.

Dashboards are visual user interface for interacting with your boards over the cloud, and we
can setup many different setups depending on what your IoT project needs. We can access our
dashboards by clicking on the “Dashboards” tab at the top of the Arduino IoT Cloud interface,
where we can create new dashboards, and see a list of dashboards created for other Things.

Page | 64
III
ECE

Navigating to dashboards.
B
If we click on “Create new dashboard”, we enter a dashboard editor. Here, we can create
something called widgets. Widgets are the visual representation of our variables we create, and
there are many different to choose from. Below is an example using several types of widgets.

The different widgets available.

When we create widgets, we also need to link them to our variables. This is done by clicking
on a widget we create, select a Thing, and select a variable that we want to link. Once it is
linked, we can either interact with it, for example a button, or we can monitor a value from a
sensor. As long as our board is connected to the cloud, the values will update!

Let's say we have a temperature widget that we want to link to the temperature variable
inside the Cloud project thing.

Page | 65
III
ECE

Linking a variable to a widget.

Note that not all widgets and variables are compatible. A switch and an integer can for example
not be linked, and will not be an option while setting up your dashboard.

We can also have several things running at once, depending on your Arduino IoT Cloud plan,
which we can include in the same dashboard. This is a great feature for tracking multiple
boards in for example a larger sensor network, where boards can be connected to different
networks around the world, but be monitored from the same dashboard.

Finally we have created a IOT logging

RESULT:

Thus the setup a cloud platform to log the data was studied successfully

Page | 66
III
LOG DATA USING RASPBERRY PI AND UPLOAD TO THE CLOUD PLATFORM
ECE

EXP NO: 11

DATE :

ThingSpeak is an open IoT platform for monitoring your data online. In ThingSpeak
channel you can set the data as private or public according to your choice. ThingSpeak takes
minimum of 15 seconds to update your readings. Its a great and very easy to use platform for
building IOT projects.
There are also some other platforms available for monitoring your data online which we will
cover in later articles but there are some advantages of ThingSpeak over other platforms like it
is very easy to set up and it also has many options to plot graph.
Components Required

1. Raspberry Pi
2. Power Cable
3. WiFi or Internet

Steps for building Raspberry Pi Data Logger on Cloud

Step 1: Signup for ThingSpeak


For creating your channel on ThingSpeak you first need to sign up on ThingSpeak. In case if
you already have account on ThingSpeak just sign in using your id and password.
For creating your account go to www.thinspeak.com

Page | 67
III
ECE

Click on signup if you don‟t have account and if you already have account click on sign in.
After clicking on signup fill your details. B

After this verify your E-mail id and click on continue.

Step 2: Create a Channel for Your Data


Once you Sign in after your account verification, Create a new channel by clicking “New
Channel” button

After clicking on “New Channel”, enter the Name and Description of the data you want to
upload on this channel. For example I am sending my CPU data (temperature), so I named it as
CPU data.

Page | 68
III
ECE

Now enter the name of your data (like Temperature or pressure) in Field1. If you want to use
more than one Field you can check the box next to Field option and enter the name and
description of your data.
After this click on save channel button to save your details. B

Step 3: Getting API Key in ThingSpeak


To send data to ThingSpeak, we need an unique API key, which we will use later in our python
code to upload our CPU data to ThingSpeak Website.
Click on “API Keys” button to get your unique API key for uploading your CPU data.

Now copy your “Write API Key”. We will use this API key in our code.

Step 4: Python Code for Raspberry Pi


Complete code is given at the end of this tutorial, just make a file with any name and .py
extension and copy-paste the code and save the file. Don‟t forget to replace the API key with
yours. You can run the python file any time using below command:

python /path/filename.py

Page | 69
III
ECE

Assuming you already installed python in Raspberry pi using this command

sudo apt-get install python


B

Case 1: If you are using monitor screen then just use the given code.
Now install all libraries:

sudo apt-get install httplib


sudo apt-get install urllib

After installing libraries run your python code (python /path/filename.py)


If the code runs properly you will see some CPU temperature values as shown in below image.

If there are any errors uploading the data, you will receive “connection failed” message.

Case 2: If you are using “Putty” then you should follow these commands:
First update your pi using:

sudo apt-get update

Page | 70
III
ECE

After this make a file cpu.py using:

nano cpu.py
B

After creating this file copy your code to this file and save it using CTRL + X and then „y‟ and
Enter.
After this install all libraries using:

sudo apt-get install httplib


sudo apt-get install urllib

After installing libraries run your python code using:

python cpu.py

If the code runs properly you will see some CPU temperature values as shown in above image.

Step 6: Check ThingSpeak site for Data Logging


After completing these steps open your channel and you will see the CPU temperature data is
updating into ThingSpeak website.

Page | 71
III
ECE

Like this you can send any sensor data connected with Raspberry pi to the ThingSpeak Cloud.
In next article we will connect LM35 temperature sensor with Raspberry Pi and send the
temperature data to ThingSpeak, which can be monitored from anywhere.
Complete Python code for this Raspberry Pi Cloud Server is given below. Code is easy and
self-explanatory to understand.

Code

import httplib
import urllib

import time

key = "ABCD" # Put your API Key here

def thermometer():

while True:

#Calculate CPU temperature of Raspberry Pi in Degrees C

Page | 72
III
ECE

temp = int(open('/sys/class/thermal/thermal_zone0/temp').read()) / 1e3 # Get Raspberry Pi


CPU temp

params = urllib.urlencode({'field1': temp, 'key':key }) B

headers = {"Content-typZZe": "application/x-www-form-urlencoded","Accept":


"text/plain"}

conn = httplib.HTTPConnection("api.thingspeak.com:80")

try:

conn.request("POST", "/update", params, headers)

response = conn.getresponse()

print temp

print response.status, response.reason

data = response.read()

conn.close()

except:

print "connection failed"

break

if name == " main ":

while True:

thermometer()

RESULT:
Thus the Log Data Using Raspberry Pi and Upload to The Cloud Platform was studied
successfully

Page | 73
III
DESIGN AN IOT BASED SYSTEM ECE

EXP NO: 12

DATE :

Steps to Astounding Internet of Things Design


It would take an entire book to cover this topic. In that regard, we won‟t go into describing the
details of each step. Instead, we will help you get a comprehensive picture of what Internet of
Things design is all about.

#1 Step: All great projects start with research


The first step is a pre-development stage when you identify some challenges other people have
and understand the way IoT can address these challenges. This step is also called business
analysis, discovery phase, market research, or conceptual stage. You need to understand what
needs your future solution meets, identify the audience and ways to reach them, create profiles
of your users, describe distribution channels, find partners, draft a financial plan, and much
more. You also need to browse the market and look at similar existing solutions. Consider
yourself a startup that needs to pass the first startup development stage.
#2 Step: Engineer ergonomic IoT devices
An IoT fleet is the backbone of the network. So you should carefully design, prototype, test,
and construct the device before going to mass production. It‟s a very tricky journey especially
if you plan to utilize several types of sensors and actuators. A device for final users (like
fitness trackers) must be ergonomic, and simple-in-use, while for industrial gadgets one of the
biggest challenges is battery life. It‟s also necessary to find a reliable device vendor that has
enough experience in IoT fleet management and production.
In addition to all of the above, you need to understand whether your solution is possible to
build using IoT devices. IoT affects various industries, and devices in some industries like
healthcare are very complicated since the accuracy of these devices must be close to 100%,
and interruptions in operation can lead to people‟s death – so it requires a lot of financing and
expertise. On the other side, if your idea is connected with Smart Homes, it will be much
easier to find a device manufacturer or build a device on your own. Balance your desires with
possibilities.
Page | 74
III
ECE

#3 Step: Carefully design an IoT architecture


To build an IoT architecture you can use the services of specialized companies
like SumatoSoft or hire a highly qualified IoT architect. Whatever you choose, always keep in
mind that this step is extremely important and you shouldn‟t save on it. BThe system logic and
key elements of the entire IoT ecosystem are defined here. Pay special attention to network
characteristics and technologies since they must cope with the traffic volume it carries. Define
the types of data that it is going to transmit: voice, video, pictures, text, etc. Dealing with IoT
traffic entails the presence of special network requirements.
#4 Step: IoT system development and fleet deployment
When the IoT fleet is ready to deploy, a comprehensive system to manage the IoT fleet is
needed. Using specialized platforms is the best way to develop such a system. Choosing a
platform provider, you should examine the technologies they support, the possibility to
register devices from different vendors that use different protocols, and the price of the
platform.
Before the fleet deployment, you need to create an instance of every device in the system,
record the information about each device, provide secure residentials for every device, set up
permissions and access rights, and much more. Device onboarding can become a tricky issue
without the right platform for IoT fleet management. While the right platform can increase
production throughput and help to achieve a fourfold increase in device provisioning
throughput.

Best IoT platforms are:


 HomeKit
 AWS IoT Device Management Services
 Azure IoT Suite

Page | 75
III
ECE

 Oracle IoT
In case you work with the mass market, an additional step here is building a fast and user-
friendly application. The application development lifecycle consists of designing and
prototyping, programming, testing, and releasing the application. B
9 Best Internet of Things Design Principles

#1 Principle: Think of security in advance


Privacy and security issues are the key challenge for IoT products. Incorrect or insecure
software may open a network to hackers‟ attacks and data leakage. In addition, there is a need
to establish proper security update processes as a part of IoT update management to deploy
security patches effectively and quickly.
#2 Principle: Test in the real environment
The IoT fleet interacts with the environment which makes it vulnerable to all kinds of physical
effects like hits, rapid temperature drops, pests, etc. All these treats are hard to test in
laboratory conditions, so it‟s necessary to test devices in a real environment where they are
supposed to work further.
#3 Principle: Apply UX in device and application development
UX aims to provide a positive experience and helps to meet user needs and requirements. UX-
based IoT design brings great value to the final user and the IoT system.
#4 Principle: Provide the autonomy of devices during connection loss
The Internet of Things is about connectivity. However, there will be a time when the device
will disconnect from the network. The device should continue to work properly and transfer the
collected information when the connection will be restored.
#5 Principle: Place getaways close to the maximum number of devices

The location of gateways should be as close to the IoT fleet as possible. It‟s necessary to
provide a lower latency in their communication.
#6 Principle: The system should be easily scalable
The future growth of the IoT system directly depends on its opportunities to scale efficiently
and stay robust when the volume of data and the number of devices increase.
#7 Principle: Build trust in your system
Since the Internet of Things often deals with sensitive information, you need to build trust in
your system to acquire more users. Trust should become one of the core values.
#8 Principle: Deploy only working products
Once the connected devices are deployed, their replacement with a newer version will be an
almost impossible task to accomplish because of high costs. That means that one single error in
the fleet which is detected after the fleet deployment can lead to large financial losses. Due to
that, it‟s good to avoid untested hardware iterations and deploy only working products.

#9 Principle: Data management and analysis should be effective


IoT systems generate enormous volumes of information. This data will be useless until the
system learns how to transform data streams into valuable insights. It is up to effective data
management and analysis whether the IoT system will generate value or just become a data
warehouse.
Page | 76
III
ECE

The Significance of the Ethical Aspect in IoT Design


As IoT devices and applications become more prevalent, it‟s important to consider the ethical
implications of IoT design. Some key ethical considerations include privacy, security, data
ownership, and transparency. B
For example, imagine a smart home security system that uses cameras and sensors to monitor a
family‟s activity. While the system may be effective in preventing theft or intruders, it could
also collect personal data about the family‟s daily routines and habits, which could be used for
nefarious purposes if it falls into the wrong hands.
How IoT engineers can address this issue:
1. Implement security measures: IoT designers should implement security measures such as
encryption and authentication to protect user data from unauthorized access.
2. Develop transparent data policies: IoT designers should develop transparent data policies that
clearly explain what data is being collected and how it will be used, as well as obtain user
consent before collecting any personal data.
3. Consider the impact on vulnerable populations: IoT designers should consider the potential
consequences of their designs, particularly for vulnerable populations such as children, the
elderly, or people with disabilities, and work to ensure that their products are accessible and
inclusive to all users.
4. Prioritize privacy by design: IoT designers should prioritize privacy by design, which involves
incorporating privacy considerations into the design process from the beginning, rather than as
an afterthought.
5. Educate users: IoT designers should provide clear and concise instructions on how to use their
products safely and securely, as well as provide resources for users to learn more about IoT
security and privacy best practices.
Great Internet of Things Design Examples

Building a great IoT design is not an easy task. However, we managed to find 3 breathtaking
examples that managed to follow our principles above.
Whistle – Better tech for better care
Whistle is an application that connects to the IoT device on a pet through the cellular network.
Its goal is to take care of the pets by providing precise data to their owners. The IoT device
monitors key behaviors like scratching, drinking, sleep, licking, and other activities. Then it
analyzes them and assigns a score to the pet‟s health. The scoring system leverages machine
Page | 77
III
ECE

learning methods and health stories from 100 000 + dogs to evaluate a pet‟s behavior and track
its wellness.
Keymitt – Smart locks for your doors
Keymitt offers smart door locks with voice assistance. The KeymittB application is very
convenient and user-friendly, and it is compatible with Android and iOS smartphones. This IoT
solution is much safer than ordinary door locks because it ensures privacy and secure access
thanks to real-time notifications of the owner. Moreover, smart locks have one great advantage
compared to traditional locks – your application is responsible for lock control, there is no need
to hold keys.
Curve – The smart GPS tracker
Curve is a smart GPS tracker that can be attached to almost anything. You can track your keys,
pets, or your favorite bag. Curve uses 4 different tracking technologies; GPS, Wi-Fi, Cellular
and Bluetooth so even if you‟re at home or outside, you‟ll have a reliable connection to
whatever you‟re trying to find.
August Smart Lock Pro – Key-free access to your home
The August Smart Lock Pro is a smart lock that allows users to remotely control their door
locks using their smartphones. It integrates with popular smart home platforms like Alexa and
Google Assistant, allowing users to lock and unlock their doors with voice commands. The
smart lock also includes a range of security features, such as two-factor authentication and
activity alerts, to ensure that the user‟s home is secure. The lock also allows users to provide
temporary access to guests or service providers through the August app, making it easy to grant
and revoke access as needed.

RESULT:

Thus the design an IOT based system was studied successfully

Page | 78

You might also like