0% found this document useful (0 votes)
4 views67 pages

Iot - Unit II Ar19 Ece

The document outlines the course objectives and outcomes for an Internet of Things (IoT) course at Aditya Engineering College, focusing on Arduino and Raspberry Pi. It covers topics such as IoT concepts, device connectivity, cloud protocols, and embedded systems, along with practical programming in Embedded C and Python. The course aims to equip students with the skills to develop IoT applications using various development environments and tools.

Uploaded by

NAGENDRA S
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)
4 views67 pages

Iot - Unit II Ar19 Ece

The document outlines the course objectives and outcomes for an Internet of Things (IoT) course at Aditya Engineering College, focusing on Arduino and Raspberry Pi. It covers topics such as IoT concepts, device connectivity, cloud protocols, and embedded systems, along with practical programming in Embedded C and Python. The course aims to equip students with the skills to develop IoT applications using various development environments and tools.

Uploaded by

NAGENDRA S
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/ 67

ADITYA ENGINEERING COLLEGE (A)

Course Name
Internet of Things [ IoT ]
Unit II-Introduction to Arduino, Raspberry Pi:

Course Instructor
P Bujjibabu , M. Tech.,(Ph.D.), Senior Member IEEE
Assistant Professor
Dept of Electronics and Communication Engineering
Aditya Engineering College(A)
Surampalem.
5/15/2023 IoT P. Bujjibabu
Course objectives:
COB 1: To introduce the concepts of the Internet of Things (IoT).
COB 2: To impart knowledge on IoT and Machine to Machine application areas.
COB 3: To introduce various Integrated Development Environments (IDEs) used in IoT.
COB 4: To enable the students learn the effective usage of device connectivity and cloud
connectivity models.
COB 5: To illustrate various cloud connectivity protocols.
COB 6: To make the students understand the implementation of IoT for various
applications.
Course outcomes:
CO 1: Explain the basic building blocks of IoT.
CO 2: Make use of the features provided by the Arduino & Raspberry Pi IDEs and
develop basic programming.
CO 3: Explain various sensors and actuators used in IoT.
CO 4: Outline the protocols for device and cloud connectivity in IoT.
CO 5: Demonstrate the case studies of IoT applications

5/15/2023 IoT P. Bujjibabu


Unit II Introduction to Arduino, Raspberry Pi:

 Introduction
 Arduino Uno Architecture,
 Setup the IDE,
 Editing in Arduino,
 Arduino Libraries,
 Embedded C programming for Arduino,
 Introduction to Raspberry Pi,
 Types of Raspberry Pi,
 Architecture of Raspberry pi 3B+,
 Basic Embedded C/ Python programming for Raspberry Pi,
5/15/2023 IoT P. Bujjibabu
 Examples
Industry / Robot /
System

Industry /
System

IoT P. Bujjibabu
4
System & Control system
System / Plant:
“A system may be a piece of equipment, perhaps just a set of machine
parts functioning together, the purpose of which is to perform a
particular operation”.

Control System:
“A control system is an interconnection of components forming a system
configuration that provide a desired system performance”

Un
Open loop No
controlled
systems feedback
O/P
Systems
Closed loop Controlled
feedback
systems O/P
5
IoT P. Bujjibabu
Open loop system

Closed loop system

6
IoT P. Bujjibabu
Multivariable control system

7
IoT P. Bujjibabu
Embedded Systems
• "It is a combination of hardware and software to perform a specific task"

“An embedded system is a system with a dedicated function within a


larger mechanical or electrical system, often with real-time computing
constraints.
It is embedded as part of a complete device often including hardware and
mechanical parts.
Embedded systems control many devices in common use today.”

Components of Embedded Systems

Communication
Power Supply Processor Memory Timers & Counters
Ports

• Assembler
Application Specific Software • Emulator
Input & Output
Circuits Components • Debugger
• Compiler
8
IoT P. Bujjibabu
Why Arduino..?

Arduino ( Arrr-dween-oh )
(n.) It's an open-source physical computing platform based on a simple
microcontroller board, and a development environment for writing
software for the board.

9
IoT P. Bujjibabu
Types of Arduino Boards

Arduino Mega
Arduino Nano
Arduino LilyPad

Arduino Leonardo
Arduino Uno Arduino Mini
10
IoT P. Bujjibabu
Arduino Uno

Digital pins: Analog pins:


• 14 digital IO pins • 6 analog pins(A0, A1, A2, A3, A4, and A5)
• 6 are PWM pins (3, 5, 6, 9, 10, and 11). • Takes analog values as an input
PWM stands for Pulse Width Modulation and it is a technique used in controlling the
brightness of LED, speed control of DC motor, controlling a servo motor.
11
IoT P. Bujjibabu
Arduino Uno Features
• The Most of the Arduino boards come with an 8-bit
Microcontroller.
• 32k bytes of flash memory and 2k bytes of SRAM (Static
Random Access Memory).
• Input voltage required- 7 V – 12V
• Arduino uses C/C++ as a programming language.
• Digital I/O pins- 14 & Analog Input pins- 6
• Clock frequency-
– Processor speed ranges from 8 MHz to 400 MHz.
• The average speed of most of the Arduinos is 16 MHz.
• Flash Memory- 32KB
• It is limited to IDE (Integrated Development Environment)
12
IoT P. Bujjibabu
13
IoT P. Bujjibabu
Arduino IDE

VERIFY SERIAL MONITOR

UPLOAD

NEW TAB

OPEN CODE GOES HERE


SAVE
BOARD & SERIAL
PORT SELECTIONS

14
IoT P. Bujjibabu
Tools

• Auto Format This formats your code nicely: i.e. indents it so that
opening and closing curly braces line up, and that the statements
inside curly braces are indented more.
• Archive Sketch Archives a copy of the current sketch in .zip format.
The archive is placed in the same directory as the sketch.
• Fix Encoding & Reload Fixes possible discrepancies between the
editor char map encoding and other operating systems char maps.
• Serial Monitor Opens the serial monitor window and initiates the
exchange of data with any connected board on the currently selected
Port. This usually resets the board, if the board supports Reset over
serial port opening.
• Serial Monitor Opens the serial monitor window and initiates the
exchange of data with any connected board on the currently selected
Port. This usually resets the board, if the board supports Reset over
serial port opening.
15
IoT P. Bujjibabu
Tools

• Board Select the board that you're using. See below for descriptions
of the various boards.
• Port This menu contains all the serial devices (real or virtual) on your
machine. It should automatically refresh every time you open the top-
level tools menu.
• Programmer For selecting a hardware programmer when
programming a board or chip and not using the onboard USB-serial
connection. Normally you won't need this, but if you're burning a
bootloader to a new microcontroller, you will use this.
• Burn Bootloader The items in this menu allow you to burn
a bootloader onto the microcontroller on an Arduino board. This is not
required for normal use of an Arduino board but is useful if you
purchase a new ATmega microcontroller (which normally come
without a bootloader). Ensure that you've selected the correct board
from the Boards menu before burning the bootloader on the target
board. This command also set the right fuses. 16
IoT P. Bujjibabu
Libraries

• Libraries provide extra functionality for use in sketches, e.g. working


with hardware or manipulating data.
• To use a library in a sketch, select it from the Sketch > Import
Library menu.
• This will insert one or more #include statements at the top of the
sketch and compile the library with your sketch.
• Because libraries are uploaded to the board with your sketch, they
increase the amount of space it takes up.
• If a sketch no longer needs a library, simply delete
its #include statements from the top of your code.

17
IoT P. Bujjibabu
Basic Coding structure

18
IoT P. Bujjibabu
Basic Coding structure
 setup() function
• Called when a sketch starts.
• To initialize variables, pin modes, start using libraries, etc.
• Will only run once, after each power-up or reset of the Arduino
board.
 loop() function
• Loops consecutively.
• Code in the loop() section of the sketch is used to actively control the
Arduino board.
 Commenting
• Any line that starts with two slashes (//) will not be read by the
compiler, so you can write anything you want after it.

19
IoT P. Bujjibabu
 pinMode()
• Instruction used to set the mode (INPUT or OUTPUT) in which we
are going to use a pin. •D13 - 101
• E.g.: pinMode (13, OUTPUT); •D13 - Due
•D1 - Gemma
• i.e.. setting pin13 as output. •D13 - Intel Edison
•D13 - Intel Galileo Gen2
•D13 - Leonardo and Micro
•D13 - LilyPad
 digitalWrite() •D13 - LilyPad USB
• Write a HIGH or a LOW value to a digital pin. •D13 - MEGA2560
•D13 - Mini
• E.g.: digitalWrite (13, HIGH); •D6 - MKR1000
•D13 - Nano
• i.e.. setting pin 13 to high or ON •D13 - Pro
• E.g.: digitalWrite (13, LOW); •D13 - Pro Mini
•D13 - UNO
• i.e.. setting pin 13 to high or OFF •D13 - Yún
•D13 - Zero
20
IoT P. Bujjibabu
external LED with this sketch

• You need to build this circuit, where you connect one end of the
resistor to the digital pin correspondent to
the LED_BUILTIN constant.
• Connect the long leg of the LED (the positive leg, called the anode)
to the other end of the resistor.
• Connect the short leg of the LED (the negative leg, called the
cathode) to the GND.
• In the diagram below we show an UNO board that has D13 as the
LED_BUILTIN value.
• The value of the resistor in series with the LED may be of a different
value than 220 ohm; the LED will lit up also with values up to 1K
ohm.

21
IoT P. Bujjibabu
22
IoT P. Bujjibabu
 digitalRead()
• Reads the value from a specified digital pin, either HIGH or LOW
• E.g.: int inPin=7;
val = digitalRead(inPin);
• i.e.. Reads the value from inPin and assigns it to val.
int ledPin = 13; // LED connected to digital pin 13
Sets pin 13 to
int inPin = 7; // pushbutton connected to digital pin 7 the same
int val = 0; // variable to store the read value value as pin 7,
void setup() { declared as an
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output input
pinMode(inPin, INPUT); // sets the digital pin 7 as input
}

void loop() {
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}
23
IoT P. Bujjibabu
 delay()
• Pauses the program for the amount of time (in milliseconds)
specified as parameter.
• E.g.: delay(1000);
• i.e.. waits for a second (1000 ms = 1 s)

24
IoT P. Bujjibabu
Libraries

• Libraries provide extra functionality for use in sketches, e.g. working


with hardware or manipulating data.
• Libraries are a collection of code that makes it easy for you to
connect to a sensor, display, module, etc.
• For example, the built-in LCD03 library makes it easy
to talk to character LCD displays.
• There are hundreds of additional libraries available on the Internet for
download. To use the additional libraries, you will need to install
them.
• To use a library in a sketch, select it from the Sketch > Include
libraries Manage Libraries.
• This will insert one or more #include statements at the top of the
sketch and compile the library with your sketch.
• Because libraries are uploaded to the board with your sketch, they
increase the amount of space it takes up.
25
IoT P. Bujjibabu
Working with Library manager

• Open the IDE and click to the "Sketch" menu and then Include
Library > Manage Libraries.
• Then the Library Manager will open and you will find a list of
libraries that are already installed or ready for installation.
• In this example we will install the Drive library. Scroll the list to find
it, click on it, then select the version of the library you want to install.
• Sometimes only one version of the library is available. If the version
selection menu does not appear, don't worry: it is normal.

26
IoT P. Bujjibabu
Importing a .zip Library

• Libraries are often distributed as a ZIP file or folder.


• The name of the folder is the name of the library.
• Inside the folder will be a .cpp file, a .h file and often a keywords.txt
file, examples folder, and other files required by the library.
• Starting with version 1.0.5, you can install 3rd party libraries in the
IDE. Do not unzip the downloaded library, leave it as is.
• In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP
Library. At the top of the drop down list, select the option to "Add
.ZIP Library''.

27
IoT P. Bujjibabu
Embedded C programming for Arduino-Introduction

 There are a lot of programming languages, more


than 700 actually
 Python — Artificial Intelligence & Machine Learning
 JavaScript — Rich Interactive Web Development
 Java — Enterprise Application Development
 R — Data Analysis(statistical computing & graphical modeling)
 Golang — Server-Side Programming(Go claims to
offer a mix of high-performance like C/C++,
simplicity, and usability like Python, along with
efficient concurrency handling like Java) used in
back-end technologies, cloud services, distributed
networks, IoT.
28
IoT P. Bujjibabu
• PHP — Web Development(A large number of companies are
using PHP today to create tools like CMS (Content Management
Systems), e-Commerce platforms, and web applications. PHP also
makes it extremely easy to create web pages in an instant.)
• SQL(Structured Query Language) Data Management
• Swift — For Mobile App Development on iOS (Apple’s own
programming language that was released in 2014 as a replacement for its
Objective-C programming language)
 C/C++ — Operating Systems and System Tools
• What this language is used for — as C & C++ both are
used to create applications and platforms, such as
system applications, real-time systems, IoT, embedded
systems, games, cloud, containers, and more. 29
IoT P. Bujjibabu
Difference between Programming Language & Scripting language

Programming Language VS Scripting Language

Platform-agnostic (cross-
Platform-specific
platform)
Compiled (Mostly) interpreted
Slower at runtime Faster at runtime
Less code-intensive More code-intensive
Creates apps as part of a stack Creates standalone apps
JavaScript/ECMAScript PHP
Python Ruby
Examples Groovy Perl
Lua Bash
PowerShell R
30
VBA Emacs
IoT
Lisp GMLP. Bujjibabu
C-Language:
 C is a general-purpose programming language, used to design
any type of desktop-based applications.
 It was developed by Dennis Ritchie as a system programming
language to develop the operating system.
 The main features of C language include low-level access to
memory, a simple set of keywords, and clean style
 These features make C language suitable for system
programming like OS or compiler development.
 In nature it uses a native platform development scheme, i.e. the
development of the application by it is platform-dependent and
can only be used on a single platform.

31
IoT P. Bujjibabu
Embedded C-Language:
 Embedded C is an extension of C language and it is used to develop
micro-controller based applications.
 The extensions in the Embedded C language from normal C
Programming Language is
– the I/O Hardware Addressing,
– fixed-point arithmetic operations,
– accessing address spaces, etc.
 Embedded C Program has five layers of Basic Structures.
 They are:
– Comment:
– Pre-processor directives:
– Global Declaration:
– Local Declaration:
– Main function(declaration part and the execution part)
32
IoT P. Bujjibabu
Embedded C Program has five layers of Basic Structures

• Comment: These are simple readable text, written in code to make it


more understandable to the user. Usually comments are written
in // or /* */.
• Pre-processor directives: The Pre-Processor directives tell the
compiler which files to look in to find the symbols that are not present
in the program.
• Global Declaration: The part of the code where global variables are
defined.
• Local Declaration: The part of the code where local variables are
defined.
• Main function: Every C program has a main function which drives the
whole code. It basically has two parts the declaration part and the
execution part. Where, the declaration part is where all the variables are
declared, and the execution part defines the whole structure of
execution in the program.
33
IoT P. Bujjibabu
Difference between Embedded C Language & C language

Parameter Embedded C Language C language

GENERAL Embedded C is an extension C is a general purpose high


C language and is used to level programming language,
develop micro-controller which is used to design any
based applications. type of desktop applications.
It is a type of

DEPENDENCY Embedded C is fully hardware C language is hardware


dependent language. independent language.
Embedded C is OS independent C compilers are OS dependent.

COMPILER A specific compilers that are able to The standard compilers can be
generate particular hardware/micro- used to compile and execute
controller based output is used. the program.
Popular Compiler are: Popular Compilers are:
Keil compiler GCC (GNU Compiler
BiPOM ELECTRONIC collection)
Green Hill software Borland turbo C,
Intel C++

34
IoT P. Bujjibabu
Parameter Embedded C Language C language

USABILITY AND
• Formatting depends upon the type
APPLICATION • C language has a free-format
of microprocessor that is used.
of program coding.
• It is used for limited resources like
• It is specifically used for
RAM and ROM.
desktop application.
• High level of optimization.
• Optimization is normal.
• It is not easy to read and modify the
• It is very easy to read and
Embedded C language.
modify the C language.
• Bug fixing is complicated in a
• Bug fixing are very easy in a C
Embedded C language program.
language program.
• It supports only required processor
• It supports other various
of the application, and not the
programming languages
programming languages.
during application.
• Only the pre-defined input can be
• Input can be given to the
given to the running program.
program while it is running.
• Applications of Embedded C
• Applications of C Program:
Program:
• Logical programs
DVD
• System software
TV
programs
Digital camera 35
IoT P. Bujjibabu
Factors for Selecting the Programming Language

The following are few factors that are to be considered while selecting
the Programming Language.
 Size: The memory that the program occupies is very important as
Embedded Processors like Microcontrollers have a very limited
amount of ROM (Program Memory).
 Speed: The programs must be very fast i.e., they must run as fast as
possible. The hardware should not be slowed down due to a slow
running software.
 Portability: The same program can be compiled for different
processors.
 Ease of Implementation
 Ease of Maintenance
 Readability
 Adaptability
36
IoT P. Bujjibabu
Programming Embedded Systems

• Processor is the heart of the Embedded System and it can be


anything like a Microprocessor, Microcontroller, DSP, CPLD
(Complex Programmable Logic Device) or an FPGA (Field
Programmable Gated Array).
• All these devices have one thing in common: they are programmable
i.e., we write a program (which is the software part of the Embedded
System) to define how the hardware actually works.
• Embedded Software or Program allow Hardware to monitor
external events (Inputs / Sensors) and control external devices
(Outputs) accordingly.
• During this process, the program for an Embedded System may have
to directly manipulate the internal architecture of the Embedded
Hardware (usually the processor) such as
– Timers, Serial Communications Interface,
– Interrupt Handling, and I/O Ports etc…
37
IoT P. Bujjibabu
Embedded C programming for Arduino

• Embedded C is one of the most popular and commonly used


Programming Languages in the development of Embedded
Systems.
• An Embedded System can be best described as a system which has
both the hardware and software and is designed to do a specific
task
• There are many popular programming languages like Assembly,
BASIC, C++, Python etc. (as discussed earlier) that are often used
for developing Embedded Systems but Embedded C remains
popular due to;
– its efficiency,
– less development time and
– portability.
• So, in this discussion, we will learn,
– Basics of Programming Structure of Embedded C.
– Embedded C Program IoT
38
P. Bujjibabu
How we can program our Arduino in embedded C?

• Arduino contains an AVR based microcontoller in it.


• The name of microcontroller is Atmega 328P.
• The very first thing if you want to understand how to code in
Embedded C is you need to understand – How to read datasheet

http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-
7810-Automotive-Microcontrollers-
ATmega328P_Datasheet.pdf

• Now when you have datasheet you need to see the pin configuration
or the schematic of your microcontroller so as to get the
understanding of which the pin mapping and port numbers.
• The below picture is the pin diagram of Atmega 328P-

39
IoT P. Bujjibabu
Atmega32 has 32-gpio's grouped into four 8-bit ports namely PORTA-PORTD

https://www.microchip.com/webdoc/AVRLibcReferenceManual/
After this you also need to have the AVR libC reference manual. It is an important
document if you want to get started with programming in embedded C. You can find the
reference manual here-
IoT P. Bujjibabu
 We need reference manual because it provide information about the
set of C libraries for AVR architecture.
 They provide support and are vendor provided.
 These libraries helps you in creating a C code that would be
understood by your microcontroller.
 And this the exact reason why we call Embedded C a hardware
dependent language. Because your set of C library will change if you
will change your hardware.
Advantages with Programming in C or Embedded C
• Significantly easy to write code in C
• Consumes less time when compared to Assembly
• Maintenance of code (modifications and updates) is very simple
• Make use of library functions to reduce the complexity of the main
code
• One can easily port the code to other architecture with very little
41
modifications IoT P. Bujjibabu
Basics of Embedded C Program

Basic features of the Embedded C Program: predefined words that have


• Keywords and a specific meaning defined
• Datatypes in accordance with the
Keywords in Embedded C compiler
• A Keyword is a special word with a special meaning to the compiler
(a C Compiler for example, is a software that is used to convert
program written in C to Machine Code).
• For example, if we take the Keil’s Cx51 Compiler (a popular C
Compiler for 8051 based Microcontrollers) the following are some of
the keywords:
bit _at_ alien bdata
sbit bit code compact
sfr data far idata
small interrupt large pdata
large _priority_ reentrant sbit
sfr sfr16 small
42
_task_ using
IoT xdata P. Bujjibabu
Data Types in Embedded C
• Keywords in Embedded C
• Data Types in C Programming Language (or any programming
language for that matter) help us declaring variables in the program.
• ThereData
are many
Type data Bits
types in C ProgrammingRange Language like signed
int, unsigned int, signed
(Bytes)char, unsigned char, float, double, etc. In
addition tobitthese there few
1 more0dataor 1types in Embedded
(bit addressable C.of RAM)
part
• The following are the extra data types in Embedded C associated with
signed int 16 (2) -32768 to +32767
the Keil’s Cx51 Compiler.
unsigned int 16 (2)
• bit 0 to 65535
• sbit
signed char 8 (1) -128 to +127
• sfr unsigned 8 (1) 0 to 255
• sfr16float 32 (4) ±1.175494E-38 to ±3.402823E+38
• The following table shows some of the data types in Cx51 Compiler
double 32 (4) ±1.175494E-38 to ±3.402823E+38
along with their ranges.
sbit 1 0 or 1 (bit addressable part of RAM)
sfr 8 (1) RAM Addresses (80h to FFh)
43
sfr16 16 (2) IoT 0 to 65535 P. Bujjibabu
Basic Structure of an Embedded C Program

Or the Template for Embedded C Program:


The following part shows the basic structure of an Embedded C Program.
• Multiline Comments . . . . . Denoted using /*……*/
• Single Line Comments . . . . . Denoted using //
• Preprocessor Directives . . . . . #include<…> or #define
• Global Variables . . . . . Accessible anywhere in the program
• Function Declarations . . . . . Declaring Function
• Main Function . . . . . Main Function, execution begins here
{ /* Blinky LED 13 in Embedded C written in Arduion Uno IDE*/
Local Variables . .#include<avr/io.h>
. . . Variables confined to main function
Function Calls . . .#define
. . Calling
F_CPUother Functions
16000000UL
Infinite Loop . . . . #include
. Like while(1) or for(;;)
<util/delay.h>
Statements .int. .main(void)
.. {
…. while(1) {
…. DDRB|= (1<<PB5);
} PORTB|=(1<<PB5);
• Function Definitions . . . . . Defining the _delay_ms(500);
Functions
{ PORTB&=~(1<<PB5);
Local Variables . . . . . Local Variables confined to this Function
_delay_ms(500);
Statements . . . . . }
…. return 0;
…. 44
} IoT P. Bujjibabu
#include<AT89X51.h> // special function register declarations for the intended 8051 derivative
void Delay(void); // Function prototype declaration
void main (void)
{
while(1) //infinite loop
{
P2 = 0x55; // LED 0b 0101 0101; Delay();
P2 = 0xAA; // LED 0b 1010 1010; Delay();
}
}
void Delay(void)
{
int j;
int i;
for(i=0;i<10;i++)
{
for(j=0;j<10000;j++)
{
return 0
}
}
} 45
IoT P. Bujjibabu
#include<avrio.h>
int main(void)
{
DDRB =0xFF;
PORTB= cc_ssd[0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F];
while(1)
{
for (i=0;i<9;i++)
{
PORTB=cc_ssd[i];
delay_ms(1000);
}
return 0;
}
}

46
IoT P. Bujjibabu
#include<reg51.h>

void main(void)
{
bit mydata P1^0;
//char mydata[]={};
for(z=0;z<=50000;z++)
{
P1= 0x55;
P1= 0xAA;
}
//P1= mydata[z];
}

47
IoT P. Bujjibabu
Introduction to Raspberry Pi
 The Raspberry Pi is a single-board computer developed by

the Raspberry Pi Foundation, a UK-based charity organization.


 Original concept was to inspire and educate children in computers
 Inspired by Acorn’s BBC Micro from 1981.
 Early concepts started in 2006.
 Based on Atmel ATmega644.
 Officially launched in 2012.

48
https://datasheets.raspberrypi.com/ IoT P. Bujjibabu
Introduction to Raspberry Pi
• A low cost, credit-‐card sized computer

• The Raspberry Pi is a minimal effort, Master card measured PC that


attachments into a PC screen or TV.

• It is a competent little gadget that empowers individuals of any age to


investigate registering.

• And to figure out how to program in dialects like Scratch and Python

• Plugs into a computer monitor or TV, Utilize console and mouse.

• Can browse the internet and play HD video

• Can also interact with the outside world!

49
https://realpython.com/python-raspberry-pi/
IoT P. Bujjibabu
Embedded C programming for Arduino

50
IoT P. Bujjibabu
Raspberry Pi Kit Contents
Raspberry XXX Raspberry Pi Case Power Supply

1. Raspberry Pi B+ or newer.
2. USB WiFi Dongle.
3. Pi Camera
Pi Camera WiFi Dongle
4. SD Card (8 GB+ recommended).
5. SD Card Reader.
6. Keyboard and/or mouse.
7. Laptop or HDMI display monitor
8. Power Supply
51
Micro SD Card IoT P. Bujjibabu
Types of Raspberry Pi

The different types of raspberry pi models are following

• Raspberry Pi 1 model B

• Raspberry Pi 1 model A Key parameters


behind the Technology
• Raspberry Pi 1 model B+ migration
• Raspberry Pi 1model A+

• Raspberry Pi Zero
1. No of GPIOs
• Raspberry Pi 2 2. No of USBs
• Raspberry Pi 3 model B 3. No of Micro SDs
4. Power Consumption
• Raspberry Pi Zero W 5. Audio features
6. The Shape or the accessibility
52
IoT P. Bujjibabu
Architecture of Raspberry pi 3B+
• The Pi 3 Model B+ has a 1.4GHz 64-bit quad-core
Broadcom Arm Cortex A53-architecture processor
compared with the Raspberry Pi 3 Model B's 1.2GHz CPU.
• It is with a 15 percent performance improvement.
• It also supports dual-band wireless local-area networks at
2.4GHz and 5GHz, Bluetooth 4.2, and Bluetooth Low
Energy.
• Raspberry Pi Foundation says the dual-band wireless LAN
comes with modular compliance certification, which should
make it easier and cheaper to commercially launch products
based on the Raspberry Pi 3 Model B+.
• This move should help cut down on wireless LAN
compliance testing.
53
IoT P. Bujjibabu
Architecture of Raspberry pi 3B+
• Like every other Raspberry Pi board, R-Pi 3 B+ is a single-
board computer.
• But it has a fast and power-efficient 1.4 GHz
processor (1.2GHz in model B) and a faster gigabit
Ethernet (it’s limited to 300 Mbit/s by the internal USB
2.0 connection) or dual-channel 2.4 / 5 GHz 802.11ac Wi-
Fi (100 Mbit/s).
• It also comes with a USB boot, network boot, and Power
over Ethernet(PoE) option that are not present in the B
model.
• Raspberry Pi 3 B+ Pinout with GPIO functions, schematic,
and specs are given in detail below
54
IoT P. Bujjibabu
Architecture of Raspberry pi 3B+

55
IoT P. Bujjibabu
Architecture of Raspberry pi 3B+
• Processor: The BCM2837B0 processor is the main component of
this tiny board that helps in carrying out a large set of instructions
based on mathematical and logical formulas. BCM2837B0 is a
1.4GHz 64bit ARM quad-core Cortex A53 processor.
• RAM: RAM used in R-Pi 3 B+ is 1GB LPDDR2 SDRAM (similar to
the previous version).
• GPU: It stands for Graphics Processing Unit and is used for
performing out the image calculation. The GPU uses OpenGL ES
version 2.0, hardware-accelerated OpenVG API, and 1080p30 H.264
high-profile decoder. It can provide up to 1Gpixel/s, 1.5Gtexel/s, or 24
GFLOPs of a general-purpose computer.
• USB Ports: Similar to model B, model B+ also consists of 4 USB
ports. Thus removing the hassle of connecting the USB hub in order to
increase the ports.
56
IoT P. Bujjibabu
Architecture of Raspberry pi 3B+
• Micro USB Power Source Connector: This connector is used
for delivering 5V power to the board. It consumes approx. 170 to
200mA more power than model B. The power connector is also
repositioned in the new B+ model and placed next to the HDMI
socket.
• HDMI and Composite Connection: Both the audio output
socket and the video composite socket reside in a single 4-pole 3.5mm
socket which is placed near the HDMI port, and now all the power
and audio-video composite socket are placed on the one side of the
board which gives it a clean and nice look.
• USB Hard Drive: The board is capable of using an external USB
hard drive.
• PoE: B+ model comes with a facility of Power over Ethernet (PoE); a
new feature added in this device which allows us to power the board
57
using the ethernet cables. IoT P. Bujjibabu
Raspberry pi Features
• Superior software implementation
• 64-bit Quad-core processor
• Large RAM (latest Raspberry Pi 4 Model B Board has up to
8G of RAM)
• Processor speed- 700MHz- 1.5GHz
• Raspberry Pi has 40 input/output pins.
• It can be connected to the Internet.
• It can run all kinds of applications (including MS Office and
Email).
• It contains everything- CPU (Central Processing Unit), GPU
(Graphics Processing Unit), Ethernet port, GPIO (General-
Purpose Input/Output) pins, and power source connector.
58
IoT P. Bujjibabu
Difference Between Arduino and Raspberry Pi

Basis Arduino Raspberry Pi

License Arduino is an open- Both hardware and


source project. Both its software of Raspberry
software and hardware Pi are closed source.
design are open source.
Control Unit From Atmega Family From ARM Family

Clock Frequency 16 MHz (Arduino UNO) Up to 1.5 GHz in Raspberry Pi 4


Requires large RAM (more than
RAM Requires less RAM (2kB)
1 GB)
CPU Architecture 8-bit 64-bit

Logic level Arduino’s logic level is 5V. Raspberry Pi’s logic level is 3V.

Power Consumption Consumes about 200 Consumes about 700 MW of


MW of power IoT power
59
P. Bujjibabu
Difference Between Arduino and Raspberry Pi

Basis Arduino Raspberry Pi

Based on Arduino is a Raspberry Pi is based on a


Microcontroller microprocessor

Simple hardware Complex hardware structure


Hardware Structure structure
Raspberry Pi supports its own
Software Arduino boards are Linux-based operating system
programmable using Raspberry Pi OS. You can also
C/C++ languages. install the OS you like
Arduino does not have
Internet
internet support. You need Raspberry Pi has a built-in
additional modules or Ethernet port and WiFi
shields to connect it to the support.
internet.
Raspberry Pi boards are
Cost Arduino boards are cheaper. expensive.
60
IoT P. Bujjibabu
Difference Between Arduino and Raspberry Pi

Basis Arduino Raspberry Pi

How they handle power


drop Arduino devices begin Raspberry Pi
executing code when they requires the same
are turned on. Therefore, care as a PC. You
when power is turned off, have to shut the
abruptly, you won’t end up operating system
with a corrupt operating down properly.
system or errors. The code
will simply start again when
plugged in.
Current drive
strength Higher current drive strength Lower current drive
strength
Arduino is generally used
Capability to perform single (and Raspberry Pi can perform
61
simple) tasks repeatedly. multiple
IoT tasks simultaneously.
P. Bujjibabu
Difference Between Arduino and Raspberry Pi

Basis Arduino Raspberry Pi

Wireless connectivity Arduino does not Raspberry Pi supports


support Bluetooth or Bluetooth and WiFi.
WiFi.

Current drive Higher current drive


strength strength Lower current drive strength

Traffic light countdown Robot controller, Game


timer, Parking lot counter, servers, Stop motion
Applications cameras, etc.
Weighing machines, etc.

62
IoT P. Bujjibabu
Raspberry Pi Software
• The operating system for the Raspberry Pi is stored on a
microSD card.
• If your card did not come from an official Raspberry Pi kit,
then you’ll need to install the operating system on it.
• There are multiple ways to set up the operating system on
your Raspberry Pi.
• You can find out more about the different installation
options on the Raspberry Pi website.
• You’ll look at two ways to install Raspbian, the officially
supported Raspberry Pi operating system, which is based
on Debian Linux.
• The Raspberry Pi foundation recommends that you use
the Raspberry Pi Imager for the initial setup of your63SD
IoT P. Bujjibabu
• The Raspberry Pi Foundation specifically selected Python
as the main language because of its power, versatility, and
ease of use.
• Python comes preinstalled on Raspbian, the Raspbian
operating system comes with several preinstalled Python
IDEs that you can use to write your programs.
• One of these IDEs is Mu. It can be found in the main menu
• Raspberry Pi Icon → Programming → Mu
• There’s a chance that Mu may not be preinstalled on your
version of Raspbian.
• If Mu isn’t installed, then you can always install it by going
to the following file location:
• Raspberry Pi Icon → Preferences → Recommended Software 64
IoT P. Bujjibabu
Using Mu

• If you plan on using Mu to complete the projects in this


tutorial, then you can use it now to create the python-
projects directory. To create this directory, you’ll want to do
the following:
1.Open Mu by going to Raspberry Pi Icon → Programming → Mu.
2.Click New in the menu bar to create an empty file.
3.Click Save in the menu bar.
4.Navigate to the /home/pi directory in the directory dropdown.
5.Click the Create New Folder icon in the top-right corner.
6.Name this new directory python-projects and hit Enter.
7.Click Cancel to close.

65
IoT P. Bujjibabu
Over SSH
If you’d rather use SSH to access your Raspberry Pi, then you’ll use the
command line to create the python-projects directory.

Note: Since you’ll be accessing the Raspberry Pi command line, you’ll


need to use a command-line text editor to edit your project files.

Both nano and vim come preinstalled on Raspbian and can be used to
edit the project files.
You can also use VS Code to remotely edit files on the Raspberry Pi, but
some setup is required.

66
IoT P. Bujjibabu
THANK YOU

Stay Healthy- Stay Safe

5/15/2023 IoT P. Bujjibabu

You might also like