0% found this document useful (0 votes)
124 views29 pages

18CS81 Iot Module 5

Uploaded by

POONAM BHASKAR
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)
124 views29 pages

18CS81 Iot Module 5

Uploaded by

POONAM BHASKAR
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/ 29

21-06-2022

Syllabus- Internet Of Things Technology Syllabus- Internet Of Things Technology

Module – 5

IoT Physical Devices and Endpoints

5.1. Introduction to Arduino 5.1. Introduction to Arduino


• Arduino is a basic single board microcontroller designed to make applications, • Arduino Uno is a microcontroller board based on the ATmega328P.

interactive controls, or environments easily adaptive. • It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6
• Arduino boards are able to read inputs - light on a sensor, a finger on a button, analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP
or a Twitter message - and turn it into an output - activating a motor, turning header and a reset button.
on an LED, publishing something online.
• "Uno" means one in Italian and was chosen to mark the release of Arduino
• The hardware consists of a board designed around an 8-bit microcontroller, or a 32-bit
Software (IDE) 1.0.
ARM.
• The Uno board and version 1.0 of Arduino Software (IDE) were the reference
versions of Arduino, now evolved to newer releases.

PWM: Pulse Width Modulation


21-06-2022

5.1.1. Why Arduino? 5.1.2. Which Arduino?


• Open source and extensible software • Entry Level
• Simple, Flexible, clear programming environment:
 Easy to use and ready to first creative projects. These boards and modules are
• Inexpensive: the best to start learning and tinkering with electronics and coding.
• Cross-platform: • Enhanced Features
• Entry Level
 Experience the excitement of more complex projects, with advanced
• Enhanced Features
functionalities, or faster performances.
• Internet of Things
• Internet of Things
• Wearable
 Make connected devices easily with IoT and the world wide web.

• Wearable

 Add smartness to projects and sewing the power of electronics directly to


textiles.

5.1.2. Which Arduino? 5.1.2. Which Arduino?


ARDUINO UNO ARDUINO MEGA 2560

• A microcontroller board based on the ATmega328P. • A microcontroller board based on the ATmega2560.

• It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 • It has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16
analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB
header and a reset button. connection, a power jack, an ICSP header, and a reset button.

• Connect it to a computer with a USB cable or power it with a AC-to-DC adapter or • It is the recommended board for 3D printers and robotics projects.
battery to get started.
21-06-2022

5.1.2. Which Arduino? 5.1.2. Which Arduino?


ARDUINO MICRO ARDUINO MKR1000

• A microcontroller board based on the ATmega32U4, featuring a built-in USB • It is based on the Atmel ATSAMW25 ARM SoC (System on Chip), that is part of
which makes the Micro recognizable as a mouse or keyboard. the Smart Connect family of Atmel Wireless devices, specifically designed for IoT
projects and devices.
• It has 20 digital input/output pins (of which 7 can be used as PWM outputs and
12 as analog inputs), a 16 MHz crystal oscillator, a micro USB connection, an • The ATSAMW25 is composed of three main blocks:
ICSP header, and a reset button.
 SAMD21 Cortex-M0+ 32bit low power ARM MCU

 WINC1500 low power 2.4GHz IEEE® 802.11 b/g/n Wi-Fi

 ECC508 Crypto Authentication

 PCB Antenna.

5.2. Exploring Arduino UNO Learning Board 5.2. Exploring Arduino UNO Learning Board
1. Reset Button – This will restart any code that is loaded to the Arduino board.

2. AREF – Stands for “Analog Reference” and is used to set an external reference
voltage

3. Ground Pin – There are a few ground pins on the Arduino and they all work the
same

4. Digital Input/Output – Pins 0-13 can be used for digital input or output

5. PWM – The pins marked with the (~) symbol can simulate analog output

6. USB Connection – Used for powering up your Arduino and uploading sketches

7. TX/RX – Transmit and receive data indication LEDs.


21-06-2022

5.2. Exploring Arduino UNO Learning Board 5.2. Exploring Arduino UNO Learning Board
8. ATmega Microcontroller – This is the brains and is where the programs are stored 13. 5V Pin – This pin supplies 5 volts of power to your projects

9. Power LED Indicator – This LED lights up anytime the board is plugged in a 14. Ground Pins – There are a few ground pins on the Arduino and they all work the
power source same

10. Voltage Regulator – This controls the amount of voltage going into the Arduino 15. Analog Pins – These pins can read the signal from an analog sensor and convert
board it to digital

11. DC Power Barrel Jack – This is used for powering your Arduino with a power
supply

12. 3.3V Pin – This pin supplies 3.3 volts of power to your projects

5.2.1. Things that Arduino can do 5.3. Installing the Software (Arduino IDE)
• can control with Arduino is an LED. • The Arduino IDE (Integrated Development Environment) is where we can develop
programs that instructs what Arduino to do.
• Display a message in LCD Display
• We can load new programs onto main chip, the ATmega328p, via USB using
• Control DC or Servo Motors
Arduino IDE.
• Read Data from outside world
• To download Arduino IDE, browse https://www.arduino.cc/en/Main/Software.
• Motion sensor allows us to detect movement
• Select type of OS that we are using and download it.
• Light sensor allows to measure the quantity of light outside world

• Humidity and Temperature sensor used to measure humidity and temperature.

• Ultrasonic sensor allows to determine the distance to an object through sound

• Shields are an extension of the Arduino


21-06-2022

5.3. Installing the Software (Arduino IDE) 5.3. Installing the Software (Arduino IDE)
• The Arduino Software (IDE) allows you to write programs and upload them to • Install the Arduino Desktop IDE accordingly to operating system.
board. In the Arduino Software page you will find two options:
 Windows
1. Online IDE (Arduino Web Editor). It will allow to save sketches in the cloud,
 Mac OS X
having them available from any device and backed up.
 Linux
2. Offline, should use the latest version of the desktop IDE.
 Portable IDE (Windows and Linux)

• Choose board in the list here on the right to learn how to get started with it and
how to use it on the Desktop IDE.

5.3. Installing the Software (Arduino IDE) 5.3.1. Connecting Arduino UNO Learning Board:
• Figure shows Arduino IDE • If you want to program your Arduino Uno while offline you need to install the

Fundamentals of Arduino Programming: Arduino Desktop IDE.

Two required functions / methods / routines: • Connect your Uno board with a USB cable; sometimes this cable is called a USB

void setup() printer cable.


{
• If you used the Installer, Windows - from XP up to 10 - will install drivers
// runs once
} automatically as soon as you connect your board.

void loop()
{
// repeats
}
21-06-2022

5.3.1. Connecting Arduino UNO Learning Board: 5.3.1. Connecting Arduino UNO Learning Board:
• You need to select the entry in the Tools > Board menu that corresponds to your • Select the serial device of the board from the Tools | Serial Port menu.
Arduino or Genuino board. (Figure shows layout of Arduino IDE)
• 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 board and re-open the menu; the entry that
disappears should be the Arduino or Genuino board.

• Reconnect the board and select that serial port.

5.3.1. Connecting Arduino UNO Learning Board: 5.3.1. Connecting Arduino UNO Learning Board:
• Open your first sketch
• Figure shows selecting the port
• Open the LED blink example sketch: File > Examples >01.Basics > Blink.
21-06-2022

5.3.1. Connecting Arduino UNO Learning Board: 5.3.1. Connecting Arduino UNO Learning Board:
• Upload the program • Layout of Arduino Uno IDE

• Now, simply click the "Upload" button in the environment. Wait a few seconds - you
should 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.

• A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start to blink (in
orange).

5.3.1. Connecting Arduino UNO Learning Board: 5.3.1. Connecting Arduino UNO Learning Board:
• Toolbar buttons and Functions of each button as shown in figure Breadboard for prototyping Arduino Uno Circuits

Verify / Compile Checks the code for Errors • The breadboard allows you to connect components together by plugging them
Stop Stop the serial monitor or un highlight other buttons into the little holes.
New Creates a new blank sketch,
Enter a name and a location for your sketch
• The key is to understand how the holes are connected.

Open Shows the list of sketches in your sketch book • As shown in figure, the holes in a column (When oriented as shown in figure) are
Upload Uploads the current sketch to the Arduino. connected together.
Need to make sure that you have current board and port selected (Tools menu)
before uploading • So to connect components together you need to plug the leads you want to

Serial Monitor Display serial data being sent from the Arduino connected into the same column.

Verify/Compile Button used to check that your code is correct, before upload it to Arduino • Note that columns are not connected across the “trench” in the center of the
Stop Button Will stop the serial monitor from operating. If you need to obtain a snapshot of board.
the serial data so far examined.
21-06-2022

5.3.1. Connecting Arduino UNO Learning Board: 5.3.1. Connecting Arduino UNO Learning Board:
Breadboard for prototyping Arduino Uno Circuits Breadboard for prototyping Arduino Uno Circuits

• These are typically used to create “rails”. • In order to keep circuit organized you need to use a breadboard, pictures below
Figure.
• These are typically used for ground and supply voltage that need to connect many
components.

• Some rows are marked (+) and Some (-). These are just markings

• The row will set at whatever voltage that we need to connect it.

breadboard for prototyping Arduino Uno circuits

5.3.1. Connecting Arduino UNO Learning Board: 5.4. Fundamentals of Arduino Programming
Technical Specifications of Arduino UNO
Microcontroller Arduino ATmega328P
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limit) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
PWM Digital I/O Pins 6
Analog Input Pins 6
DC Current per I/O Pin 20 mA
DC Current for 3.3V Pin 50 mA
32 KB (ATmega328P) of which 0.5 KB used by
Flash Memory
bootloader
SRAM 2 KB (ATmega328P)
EEPROM 1 KB (ATmega328P)
Clock Speed 16 MHz
LED_BUILTIN 13
Length 68.6 mm
Width 53.4 mm
Weight 25 g
21-06-2022

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


• The Arduino IDE supports the languages C and C++ using special rules of code • Structure: Structure of Arduino programming contains two parts
structuring.
void setup() //preparation function used to declare variables
• The Arduino IDE supplies a software library from the Wiring project, which
{ // first function that runs only once in the program
provides many common input and output procedures.
// Statements(); //used to set pins for serial communication
• User-written code only requires two basic functions, for starting the sketch and
}
the main program loop, that are compiled and linked with a program stub main()
into an executable cyclic executive program with the GNU toolchain, also
included with the IDE distribution. void loop() //execution block where instructions are executed repeatedly

{ //this is core of the Arduino programming

// statements(); //functionalities involves reading inputs, triggering outputs etc..

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


• Setup() • loop():

 This function is called once when a sketch starts after power-up or reset.  After setup() function exits (ends), the loop() function is executed repeatedly
in the main program.
 It is used to initialize variables, input and output pin modes, and other
libraries needed in the sketch  It controls the board until the board is powered off or is reset.

void setup ( ) //after calling setup(), loop() function dos its task void loop( ) //after calling setup(), loop() function does its task
{ {
digitalWrite(pin, HIGH); //set pin ON digitalWrite(pin, HIGH); //set pin ON
delay(10000); // pauses for ten thousand milliseconds delay(10000); // pauses for ten thousand milliseconds
digitalWrite(pin, LOW); //set pin OFF digitalWrite(pin, LOW); //set pin OFF
delay(10000); // pauses for ten thousand milliseconds delay(10000); // pauses for ten thousand milliseconds
} }
21-06-2022

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


• Functions • Functions: Example

 A function is a piece of code that has a name and set of statements executed
int delayvar( )
when function is called.
{
 Functions are declared by its type followed with name of a function. int var; //create temporary variable
var=analogRead(potent); //read from potentiometer
 Syntax:
var=var/4; //convert the value of variable var
type functionName (parameters)
return var; //return var
{ }

Statement(s);

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


• { } curly braces • /* ……………. */ block Multiline Comments

 They define beginning and end of function blocks, unbalanced braces may  Multiline comments begins with /* with a description of the block and ends
leads to compilation errors. with */

 Syntax: /* this is multiline comment

• semicolon Use the closing comments to avoid errors */

 It is used to end a statement and separate elements of a program

 Syntax: int x=14; • Single line comments

 Single line comment begins with // and ends with instructions.

 Syntax: // this is single line comment


21-06-2022

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


void loop()
• Variables • Variables
{
 A variable is a way of storing value for later use in a program.  Example for(int local=0;local<5;)

 A variable is defining by its value type as an int, long, float etc by setting a int var; //global variable {

specified name and optionally assigning an initial value. void setup() local++;
{ //local variable & visibility is with in for loop
 A global variable can be seen in every part of the program which is declared }
// nothing is required;
at the beginning of the program before setup() function } float local_f;
 A local variable is defined inside a function in which it was declared. //local variable & visibility is with in loop

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


• Variables Variables
int val = 5;
• int greenLED = 9;
void setup() {
Declare delayTime
pinMode(greenLED, OUTPUT);Variable

void loop() {
assignment digitalWrite(greenLED, HIGH);
Type “becomes” delay(delayTime); Use delayTime
digitalWrite(greenLED, LOVWa)ri;able
value delay(delayTime);
variable name
}
21-06-2022

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming

• Variables int delayTime = 2000; • Data Types


int greenLED = 9;
Data Type Syntax Range
void setup() { byte byte x=100; O to 255
pinMode(greenLED, OUTPUT);
} int int y=200; 32767 to -32768
void loop() {
digitalWrite(greenLED, HIGH);
delay(delayTime); long long var=8000; 2147483647 to -2147483648
digitalWrite(greenLED, LOW);
delayTime = delayTime - 100; float float x=3.142; 3.4028235E+38 to -3.4028235E+38
delay(delayTime);
arrays int myarray []={10,20,30,40} Size depends on the data type
associated with declaration

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


• Operators • Constants
Operator Syntax Constants Usage

Arithmetic Operators x=x+5; y=y-6; z=z*2; p=p/q; TRUE/FALSE Boolean constants true=2 and false=0 defined in logic levels
(+, -, /, *) If(b==true)

Assignment Operators x++; x+=y; x-=y; x*=y; x/=y {

(=, ++, --, +=, -=, *=, /=) // do somethings


}
Comparison Operators x==y; x!=y; x<y; x>y;
(==, !=, <, >, <=, >=) INPUT/OUTPUT Used with pinMode() function to define levels
pinMode(13, OUTPUT)
Logical Operators x>2 && x<5; //returns Boolean value
(&& , ||, !) x>2 || x<5; //returns Boolean value HIGH/LOW Used to define pin levels

!x>2; HIGH – 1, ON, 5 Volts


LOW – 0, OFF, 0 Volts
21-06-2022

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


• Flow Control Statements • Flow Control Statements
Operator Syntax Operator Syntax

if if(some_variable == value) for for(initialization; condition; Expression) {


{ //DoSomethings;
//statement(s); }
}
for(int p=0;p<5;p++){
else
digitalWrite(13,HIGH); //sets pin 13 ON
{
delay(250); //pauses 250 ms
//statement(s);
digitalWrite(13,LOW); //sets pin 13 OFF
}
delay(250); //pauses 250 ms
}

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


• Flow Control Statements • Digital & Analog input output pins and their usage
Operator Syntax Methods Usage

while While loop executes until the expression inside parenthesis becomes false. pinMode(pin, mode) Before using a pin as a digital input or output, must first configure
while(condition) the pin, which is done with pinMode().
{
Used in setup() method to configure pin to behave as Input/Output
//Statement(s); //evaluates till comparison results in a false value
pinMode(pin, INPUT) //pin set to INPUT
}
pinMode(pin, OUTPUT) //pin set to OUTPUT
do while Bottom evaluated loop, works same way as while loop but condition is tested
DigitalRead(pin) Read value from a specified pin with result being HIGH/LOW
at the end of loop.
do Val=DigitalRead(pin); //val will be equal to input pin

{ DigitalWrite(pin, value) Outputs to HIGH/LOW on a specified pin.


//Statement(s); //evaluates till comparison results in a false value DigitalWrite(pin, HIGH); //pin set to HIGH
} while(condition)
21-06-2022

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


• Digital & Analog input output pins and their usage • Analog I/O
Methods Usage Methods Usage

Example int x=13; //connect x to pin 13 Read value from a specified analog pin works on pins 0 -5.
int p=7 //connect push button to pin 7 val = analogRead(pin); //value equal to pin
int val=0; //variable to store the read value analogRead() reads the voltage value on a pin and returns int value
void setup() The pin argument denotes the analog pin you want to read from. When
{ referring to an analog pin, call them as A0, A1, A2,…A6.
pin MODE(x, OUTPUT); //sets ‘x’ as OUTPUT This function takes approximately 100 microseconds to perform.
} Writes an analog value using pulse width modulation (PWM) to a pin
analogWritanalogRead(
void loop() marked PWM works on pins 3,5,6,9,10.
pin,value)
{ It uses a simple technique to “emulate” an analog output.
val=digitalRead (p); //sets ‘value’ to 0 It relies on two things:
digitalWrite(x, val); //sets ‘x’ to button value a pulse width and a duty cycle.

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


• Analog I/O • time
Methods Usage Methods Usage

Example int x=10; //connect ‘x’ to pin 13 delay(ms) Pauses for amount of time specified in miliseconds.
int p=0; //connect potentiometer to analog pin 7
millis() Returns the number of milliseconds since Arduino is running
int val;
val = millis(); //val will be equal to millis()
void setup( ) { }
void loop()
{
val=analog Read(p);
val /=4;
analog Write(x, val); //outputs PWM signal to ‘x’
}
21-06-2022

5.4. Fundamentals of Arduino Programming 5.4. Fundamentals of Arduino Programming


Arduinos are capable of generating pseudo-random numbers using the random()
• Mathematical Functions • Random function:
Methods Usage Methods Usage

min(x, y) Calculates minimum of two numbers randomSeed(value) Sets a value/seed as starting point
val=min(val, 10) // sets ‘val’ to smaller than 10 or equal to 10.
random(min, max) Allows to return numbers within a range of specified by min and max values
max(x,y) Calculates maximum of two numbers Val=random(100, 200) //sets ‘val’ to random number between 100 to 200.
random(max)
val=max(val, 10) // sets ‘val’ to larger than 10 or equal to 10.
Example int num; int x=10;
void setup(){
randomSeed(millis()); //set millis() as seed
num = random(200); //random number 0 – 200
analogWrite(x, number); //outputs PWM signal
delay(500);
}

5.4. Fundamentals of Arduino Programming 5.5. Examples


• Serial • Blink LED void setup()
{
Methods Usage pinMode(10, OUTPUT);

Serial.begin(rate) Opens serial port and sets the baud rate fro serial data transmission }
void setup() {
void loop()
Serial.begin(9600); //sets default rate to 9600 bps {
}
digitalWrite(10, HIGH);
delay(500); // Wait for 1000 millisecond(s)

Serial.println(data); Prints data to the serial port digitalWrite(10, LOW);


Serial.println(value); //sends value to serial monitor delay(500); // Wait for 1000 millisecond(s)

//exit(0); //to exit from simulation (only once LED will blink

}
https://www.tinkercad.com/ https://www.tinkercad.com/things/53AHrLloDKL-frantic-jaiks-lahdi/editel?tenant=circuits
21-06-2022

5.5. Examples 5.5. Examples


void setup() void loop()
• Toggle the LED using switch void setup() • Traffic Light Simulation { {
{
pinMode(10, OUTPUT); pinMode(10, OUTPUT); digitalWrite(10, HIGH);
pinMode(8, OUTPUT); delay(500); // Wait for 1000 millisecond(s)
} pinMode(6, OUTPUT);
} digitalWrite(10, LOW);
delay(500); // Wait for 1000 millisecond(s)
void loop()
{
digitalWrite(8, HIGH);
delay(500); // Wait for 1000 millisecond(s)
digitalWrite(10, HIGH);
digitalWrite(8, LOW);
delay(500); // Wait for 1000 millisecond(s)
delay(500); // Wait for 1000 millisecond(s)
digitalWrite(10, LOW);
digitalWrite(6, HIGH);
delay(500); // Wait for 1000 millisecond(s)
delay(500); // Wait for 1000 millisecond(s)
digitalWrite(6, LOW);
//exit(0); //to exit from simulation (only once LED will blink
delay(500); // Wait for 1000 millisecond(s)
}
}
https://www.tinkercad.com/ https://www.tinkercad.com/things/53AHrLloDKL-frantic-jaiks-lahdi/editel?tenant=circuits https://www.tinkercad.com/ https://www.tinkercad.com/things/53AHrLloDKL-frantic-jaiks-lahdi/editel?tenant=circuits

5.5. Important Functions 5.6. RaspberryPi


 Serial.println(value); • Raspberry Pi is a series of credit card sized board computers developed in UK by
Raspberypi Foundation to promote the teaching of basic computer science in
 Prints the value to the Serial Monitor on your computer
schools and developing countries.
 pinMode(pin, mode);
• Generations:
 Configures a digital pin to read (input) or write (output) a digital value
o First generation: RaspberryPi 1 Model B) was released in February 2012
 digitalRead(pin);
followed by simpler and inexpensive model A.
 Reads a digital value (HIGH or LOW) on a pin set for input
o In 2014, the foundation released a board with improved design in Paspberry
 digitalWrite(pin, value); 1 Model B+.

 Writes the digital value (HIGH or LOW) to a pin set for output
21-06-2022

5.6. RaspberryPi 5.6. RaspberryPi


• Raspberry Pi is the name of a series of single-board computers made by the
Raspberry Pi Foundation, a UK charity that aims to educate people in
computing and create easier access to computing education.

• The Raspberry Pi launched in 2012, and there have been several iterations and Reset PI Ethernet Controller

variations released since then.


SD Card
• The original Pi had a single-core 700MHz CPU and just 256MB RAM, and the
latest model has a quad-core 1.4GHz CPU with 1GB RAM.

• The main price point for Raspberry Pi has always been $35 and all models have
been $35 or less, including the Pi Zero, which costs just $5.

5.6. RaspberryPi 5.6. RaspberryPi


• Processor • Power Source

o The Broadcom BCM2835 SoC used in first generation Raspberrypi used in o Power to Raspberrypi is via micro USB port on the side of the unit.
first generation smartphones which includes 700MHz ARM 1176JZF-S
o Recommended voltage is +5V and recommended input current 2A.
processor, Video Core IV graphics Processing Unit (GPU) and RAM.
o Raspberrypi can function on lower current power (5V @1A)
o Raspberrypi 2 uses BCM2836 SoC with 900MHz 32-bit quad core ARM Cortex
A7 processor with 256KB shared L2 cache
• SD Card
o Raspberrypi 3 uses BCM2837 SoC with 1.2GHz 64-bit quad core ARM Cortex
o Raspberrypi does not have locally available storage.
A53 processor with 512KB shared L2 cache
o Framework is stacked on SD card which is embedded on SD card space on
Raspberrypi
21-06-2022

5.6. RaspberryPi 5.6. RaspberryPi


• GPIO (General Purpose Input and Output) • DSI Display X

o GPIO is a non specific pins on a coordinated circuit to know is an input or o The Rasberrypi Connector S2 is a display serial interface (DSI) for
output pin which can be controlled by a client at run time. connecting a liquid crystal display (LCD) panel using a 15-pin ribbon cable.

o GPIO Capabilities o The mobile industry processor interface (MIPI) inside the Broadcom
BCM2835 IC feeds graphics data display panel through this connector.
 GPIO pins can be designated to be input or output

 GPIO pins can be empowered / crippled


• Audio Jack
 Input values are LOW, HIGH
o A standard 3.5 mm TRS connector is accessible on the RPi for stereo sound
 Yield values are writable / meaningful yield
 Input values are frequently utilized as IRQs

5.6. RaspberryPi 5.6. RaspberryPi


• Status LEDs • CSI Connector

o OK – SDCard Access (GPIO16) o Camera Serial Interface (CSI) is a serial interface connector outlines by
MIPI (Mobile industry Processor Interface) for interfacing computerized
o Power - 3.3V Power “PWR”
cameras with portable processor.
o FDX - Full Duplex (LAN) (Model B)
• HDMI
o LNK - Link/Activity (LAN) (Model B)
o High Definition multimedia interface (HDMI) to give both video and Sound
o 10M/100 - 10/100Mbit (LAN) (Model B) yield.
• JTAG Headers

• Ethernet Port o JTAG is acronym for Joint Test Action Group used for accessing to gadget

o Ethernet port is accessible on model B and Model B+ (LAN9512 LAN) pins by means of a serial port.
21-06-2022

5.6. RaspberryPi 5.6. RaspberryPi

5.6. RaspberryPi 5.6. RaspberryPi


Hardware Layout: Hardware Layout:

raspi-config Wireless networking

• The Raspberry Pi configuration tool in Raspbian, allowing you to easily enable • Configuring your Pi to connect to a wireless network using the Raspberry Pi 3's

features such as the camera, and to change your specific settings such as or Pi Zero W's inbuilt wireless connectivity, or a USB wireless dongle

keyboard layout

config.txt Wireless access point

• The Raspberry Pi configuration file • Configuring your Pi as a wireless access point using the Raspberry Pi 3 and
Pi Zero W's inbuilt wireless connectivity, or a USB wireless dongle
21-06-2022

5.6. RaspberryPi 5.6. RaspberryPi


Using a proxy Localisation
Setting up your Pi to access the internet via a proxy server Setting up your Pi to work in your local language/time zone
HDMI Config Default pin configuration
Guide to setting up your HDMI device, including custom settings Changing the default pin states.
Audio config Device Trees config
Switch your audio output between HDMI and the 3.5mm jack Device Trees, overlays, and parameters
Camera config Kernel command line
Installing and setting up the Raspberry Pi camera board How to set options in the kernel command line
External storage config UART configuration
Mounting and setting up external storage on a Raspberry Pi How to set up the on-board UARTS.
Firmware warning icons
Description of warning icons displayed if the firmware detects issues

5.6. RaspberryPi 5.6. RaspberryPi


LED warning flash codes Why RaspberryPi?
Description of the meaning of LED warning flashes that are shown if a Pi fails to boot • Inexpensive
or has to shut down • Cross Platform
Securing your Raspberry Pi • Simple
Some basic advice for making your Raspberry Pi more secure • Clear Programming Environment
Screensaver • Open Source
How to configure screen blanking/screen saver • Extensible Hardware and Software
The boot folder
What it's for and what's in it
21-06-2022

Operating Systems on RaspberryPi: Programming RaspberryPi with Python:


• You have a few options when it comes to interacting with the Raspberry Pi. The • The Raspberry Pi is an amazing single board computer (SBC) capable of running
first and most common is to use it like you would a full desktop computer (just Linux and a whole host of applications.
smaller). This involves connecting a keyboard, mouse, and monitor. • Python is a beginner-friendly programming language that is used in schools, web
• With this setup, you are likely best served by installing Raspbian with Desktop, development, scientific research, and in many other industries.
which gives you a full graphical user interface(GUI) to work with.
• This is the best option if you want an experience similar to working with other
operating systems (OS), such as Windows, macOS, or other popular Linux
flavors, like Ubuntu.

Wireless Temperature Monitoring System Using Pi: Wireless Temperature Monitoring System Using Pi:
• Raspberry Pi which having inbuilt wi-fi, which makes Raspberry Pi to suitable for • This basic will teach you to how to work with a cloud by using LM35 as a
IoT applications, so that by using IoT technology this monitoring system works by temperature sensor, to detect the temperature and to upload those values into the
uploading the temperature value to the Thingspeak cloud by this project you can cloud.
able to learn to how to handle cloud-based application using API keys.
• In this monitoring system, we used Thingspeak cloud, the cloud which is suitable
to view the sensor logs in the form of graph plots. Here we created one field to
monitor the temperature value, that can be reconfigurable to monitor a number of
sensor values in various fields.
• This basic will teach you to how to work with a cloud by using LM35 as a
temperature sensor, to detect the temperature and to upload those values into the
cloud.
21-06-2022

Wireless Temperature Monitoring System Using Pi: DS18B20 Temperature Sensor

• HARDWARE REQUIRED PYTHON LIBRARIES USED • The DS18B20 is a 1-wire programmable Temperature sensor from maxim
• RPi.GPIO as GPIO (To access the GPIO Pins of
• Raspberry Pi integrated. It is widely used to measure temperature in hard environments like
Raspberry Pi)
• SD card
• Time library (For Time delay)
• Power supply • Urllib2 to handle URL using
in chemical solutions, mines or soil etc.
• VGA to HDMI converter Python programming
(Optional) • The constriction of the sensor is rugged and also can be purchased with a
• MCP3008 (ADC IC) waterproof option making the mounting process easy.
• A temperature sensor(LM35)
• It can measure a wide range of temperature from -55°C to +125° with a decent
• SOFTWARE REQUIRED
• Raspbian Stretch OS accuracy of ±5°C.
• SD card Formatter
• Win32DiskImager (or) Etcher

DS18B20 Temperature Sensor DS18B20 Temperature Sensor


• Each sensor has a unique address and requires only one pin of the MCU to Applications:
Measuring temperature at hard environments
transfer data so it a very good choice for measuring temperature at multiple
Liquid temperature measurement
points without compromising much of your digital pins on the microcontroller. Applications where temperature has to be measured at multiple points

Pin Configuration:

No Pin Description
Name
1 Ground Connect to the ground of thecircuit
2 Vcc Powers the Sensor, canbe 3.3V or5V
3 Data This pin gives output the temperature value which can be read using 1-wire method
21-06-2022

DS18B20 Temperature Sensor Connecting Raspberry Pi via SSH:


• You can access the command line of a Raspberry Pi remotely from another computer or device on the
DS18B20 Temperature Sensor same network using SSH.
DS18B20 Temperature Sensor Pinout

• The Raspberry Pi will act as a remote device: you can connect to it using a client on another machine.

1. Set up your local network and wireless connectivity

2. Enable SSH

3. Enable SSH on a headless Raspberry Pi (add file to SD card on another machine)

4. Set up your client

Accessing Temperature from DS18B20 sensors: Accessing Temperature from DS18B20 sensors:
• The DS18B20 is a digital thermometer that allows to get 9-bit to 12-bit Celsius temperature • The sensor communicates using the OneWire protocol, which means it only requires a pin
measurements (programmable resolution). from a microcontroller to be connected to it.

• The temperature conversion time depends on the resolution used. For a 9-bit resolution it • Furthermore, each sensor has a unique 64-bit serial code, allowing multiple DS18B20
takes at most 93.75 ms and for a 12-bit resolution it takes at most 750 ms. devices to function on the same OneWire bus.

• The device is able to measure temperatures from -55°C to +125°C and has a ±0.5°C • In terms of power supply, the device can operate with a voltage between 3.0 V and 5.5 V,
accuracy in the range from -10°C to +85°C. which means it can operate with the same voltage of the ESP32 without the need for level
conversion.
• Additionally, it has an alarm functionality with programmable upper and lower temperature
trigger points.

• These thresholds are stored internally in non-volatile memory, which means they are kept
even if the device is powered off .
21-06-2022

Remote Log Into Your Raspberry Pi’s Full Operating System Using VNC Connect:
Remote access to RaspberryPi:
• To access a Raspberry Pi (or any home computer for that matter) from outside • VNC has long been the best way to access any computer remotely on the same
your home network, you’d usually need to jump through a lot of hoops, get an network. Recently, VNC Connect came out to make it easy to access your Raspberry Pi
IP address, and tweak a few settings on your home router. If you just need to from anywhere using a cloud connection. Once it’s set up, you can access your
control a few simple things on your Raspberry Pi, that’s overkill. We’re going to Raspberry Pi’s graphic interface from any other computer or smartphone using the VNC
outline two methods that skip all of that. Viewer app.

• The first thing you need to do is get your Raspberry Pi set up and connected to
your home network. Since you’re exposing your Raspberry Pi to the internet, be
sure you change your default password during the set up process. Once that’s
done, come back here to set up everything else.

RaspberryPi Interface: RaspberryPi Interface:

 Serial: The serial interface on Raspberry Pi has receive (rx) and transmit (tx) pins for communication with serial
RaspberryPi OS: (Not RaspberryPi OS: RaspberryPi OS: RaspberryPi OS:
peripherals.
linux) (Linux based) (Media center based) (Audio based)
 SPI: Serial Peripheral Interface (SPI) is a synchronous serial data protocol for communicating with one or more
1. RISC OS Pi 1. Xbean 1. OSMC 1. Volumio
peripheral devices. In an SPI connection, there is one master device and one or more peripheral devices. There are
five pins on raspberry Pi for SPI interface 2. Free BSD 2. Open SUSE 2. OpenELEC 2. Pimusixbox

o MISO (Master In Slave Out): Master line for sending data to the peripherals
3. NetBSD 3. Arc OS 3. LitreELEC 3. Runeaudio
o MOSI (Master out Slave In): Slave line for sending data to the master.
4. Plan 9 4. Kano OS 4. Xbian
o SCK (Serial Clock): Clock generated by master to synchronize data transmissions.
o CE0 (Chip Enable 0): To enable or disable devices. 5. Haiku 5. Nard SDX 5. Rasplex

o CE0 (Chip Enable 1): To enable or disable devices


 I2C: The I2C interface points on Raspberry Pi allows you to connect hardware modules. I2C interface allows
synchronous data transfer with just two pins-SDA (data line) and SCI (Clock line).
21-06-2022

Smart City IoT Architecture: Smart City IoT Architecture:

 A smart city IoT infrastructure is a four-layered architecture, as shown in Figure

 Data flows from devices at the street layer to the city network layer and connect to the
data center layer, where the data is aggregated, normalized, and virtualized.

 The data center layer provides information to the services layer, which consists of
the applications that provide services to the city.

 In smart cities, multiple services may use IoT solutions for many different purposes. These
services may use different IoT solutions, with different protocols and different application
languages

Smart City IoT Architecture: Smart City IoT Architecture:

Street Layer:  A variety of sensors are used at the street layer for variety of smart city use cases. Here is a short
representative list
 The street layer is composed of devices and sensors that collect data and take action
o A magnetic sensor can detect a parking event by analyzing changes in the surrounding magnetic
based on instructions from the overall solution, as well as the networking components field when a heavy metal object such as a car or a truck comes close to it (or on top of it).
needed to aggregate and collect data. o A lighting controller can dim and brighten a light based on a combination of time based and
ambient conditions.
 A sensor is a data source that generates data required to understand the physical o Video cameras combined with video analytics can detect vehicle faces and traffic conditions for

world. Sensor devices are able to detect and measure events in the physical world. various traffic and security use cases.
o An air quality sensor can detect and measure gas and particulate matter concentrations to give a
 ICT connectivity solutions rely on sensors to collect the data from the world around hyper-localized perspective on pollution in a given area.

them so that it can be analyzed and used to operationalize use cases for cities. o Device counters give an estimate of the number of devices in the area which provides a rough
idea of the number of vehicles moving or parked in a street or public parking area of pedestrians
on a sidewalk, or even of birds in public parks or on public monuments.
21-06-2022

Smart City IoT Architecture: Smart City IoT Architecture:

City Layer: City Layer:

 At the city layer, which is above the street layer, network routers and switches must be  However, one key consideration of the city layer is that it needs to transport multiple

deployed to match the size of city data that needs to be transported. types of protocols, for multiple types of IoT applications. Some applications are delay-
and jitter sensitive, and some other applications require a deterministic approach to
 This layer aggregates all data collected by sensors and the end-node network into a frame delivery.
single transport network.
 A missed packet may generate an alarm or result in an invalid status report. As a result,
 The city layer may appear to be a simple transport layer between the edge devices the city layer must be built around resiliency, to ensure that a packet coming from a
and the data center or the Internet. sensor or a gateway will always be forwarded successfully to the headend station

Smart City IoT Architecture: Smart City IoT Architecture:

City Layer:

 In this model, at least two paths exist from any aggregation switch to the data center
layer. A common protocol used to ensure this resiliency is Resilient Ethernet Protocol
(REP).
21-06-2022

Smart City IoT Architecture: Smart City IoT Architecture:

Data Center Layer: Data Center Layer:

 Ultimately, data collected from the sensors is sent to a data center, where it can be  The cloud model is the chief means of delivering storage, virtualization, adaptability, and

processed and correlated. the analytics know-how that city governments require for the technological mashup and
synergy of information embodied in a smart city.
 Based on this processing of data, meaningful information and trends can be derived, and
information can be provided back.  Traditional city networks simply cannot keep up with the real-time data needs of
smart cities; they are encumbered by their physical limitations.
 For example, an application in a data center can provide a global view of the city traffic
and help authorities decide on the need for more or less common transport vehicles. At  The cloud enables data analytics to be taken to server farms with large and
the same time, an automated response can be generated extensible processing capabilities.

Smart City IoT Architecture: Smart City IoT Architecture:

Service Layer:

 Ultimately, the true value of ICT connectivity comes from the services that the
measured data can provide to different users operating within a city.

 Smart city applications can provide value to and visibility for a variety of user types,
including city operators, citizens, and law enforcement.

 The collected data should be visualized according to the specific needs of each
consumer of that data and the particular user experience requirements and
individual use cases.
21-06-2022

Smart City IoT Architecture: Smart City IoT Architecture:

Smart City Security Architecture: Smart City Security Architecture:

 A serious concern of most smart cities and their citizens is data security.  A security architecture for smart cities must utilize security protocols to fortify each layer
of the architecture and protect city data.
 Vast quantities of sensitive information are being shared at all times in a layered, real-
time architecture, and cities have a duty to protect their citizens’ data from unauthorized  Figure shows a reference architecture, with specific security elements highlighted.
access, collection, and tampering.
 Security protocols should authenticate the various components and protect data
 In general, citizens feel better about data security when the city itself, and not a transport throughout.
private entity, owns public or city-relevant data.

 It is up to the city and the officials who run it to determine how to utilize this data.

Smart City IoT Architecture: Smart City IoT Architecture:


Smart City Security Architecture:

 Starting from the street level, sensors should have their own security protocols.

 Some industry-standard security features include device/sensor identification and


authorization; device/sensor data encryption; Trusted Platform Module, which enables
self-destruction when the sensor is physically handled; and user ID authentication and
authorization.
21-06-2022

Smart City IoT Architecture: Smart City IoT Architecture:

Smart City Security Architecture:  The city layer transport data between the street layer and the data center layer. It acts as the network layer.
 The following are common industry elements for security on the network layer.
 Sensor identification and authorization typically requires a pre-installed factory X.509
o Firewall: A firewall is located at the edge, and should be IPsec and VPN ready and include user and role based
certificate and public key infrastructure (PKI) at the organization level, where a new
access control. It should also be integrated with the architecture to give city operators remote access to the city
certificate is installed through a zero-touch deployment process. data center.
o VLAN: A VLAN provides end to end segmentation of data transmission. Further, protecting data from rogue
 This additional processing may slow the deployment but ensures the security of the
intervention. Each service / domain has a dedicated VLAN for data transmission.
exchanges.
o Encryption: Protecting the traffic from the sensor to the application is a common requirement to avoid data

 Another consideration may be the type of data that the sensor is able to collect and tampering and eavesdropping. In most cases, encryption starts at the sensor level. In some cases, the sensor to

process. For example, a roadside car counter may include a Bluetooth sensor that gateways link uses on type of encryption and the gateway to application connection used another encryption
(Ex: VPN).
uniquely identifies each driver or pedestrian

You might also like