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

Raspberry Pi

Uploaded by

Spandan Sahu
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Raspberry Pi

Uploaded by

Spandan Sahu
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

IOT & Applications

Module - 4

IoT using Arduino: Raspberry Pi


Difference between Rpi & Arduino

Arduino Rpi
 Arduino comes with an 8-  The Raspberry Pi comes with a 64-
bit microcontroller. bit microprocessor.
 Raspberry Pi has 1GB of RAM.
 Arduino has 2 Kilobytes of RAM.
 Raspberry Pi runs an operating system,
 Arduino has no operating system. It which is usually Linux. Rpi supports any
can only run programs that were programming while operated in Linux.
compiled for the Arduino platform,  A Raspberry Pi is much more
which mostly means programs sophisticated in this regard, having a
written in C++. Video output, an HDMI port, an SD card
port, an Audio jack, CSI camera port, DSI
 In terms of I/O, Arduino has an USB- display port, 4 USB 2.0 ports which you
B port that can be used by a can use to attach USB devices, a Gigabit
computer to transfer new programs Ethernet jack, Wireless LAN, Bluetooth
to run, a power input and a set of 4.2 and I/O pins (GPIO) as well. Lots of
I/O pins. things.
 Arduino is much more simple.
 It’s a mini computer.
 ARaspberry Pi consumes more power
 Arduino consumes much less power than Arduino (700+ mA).
(~50 mA idle).
Raspberry Pi
 Raspberry Pi board
comprises RAM,
processor, CPU, GPU,
Ethernet port, Xbee socket,
UART and various
interface for other
external devices.

 Essential H/W specification


of raspberry pi board
mainly include SD card
containing Linux OS,
keyboard, monitor, video
cable optional specification
includes USB mouse, USB
hub, USB Wi-Fi adapter.
What is Raspberry Pi
 The Raspberry Pi is a credit-card sized computer that plugs
into your TV and a keyboard.
 It’s a capable little PC which can be used for many of the
things that your desktop PC does.
 Created by Eben Upton CEO of Raspberry Pi Foundation
 Raspberry Pi Foundation goal is to see it being used by kids
all over the world to learn programming.
 Various versions of Raspberry Pi
Operating Systems
Raspberry Pi hardware
External Hardware Interfacing
Raspberry Pi Pins
Set up your Raspberry Pi
 SD card (Minimum size 4 Gb, recommended 8
Gb)
 HDMI to HDMI / DVI lead
 RCA video lead (If you are not using the HDMI
output)
 Keyboard and mouse (USB 2.0)
 Ethernet network cable (optional)
 Power adapter (Micro USB)
 Audio lead
Setup Procedure
Booting of Raspberry Pi
 Download NOOBS
 Format the SD card and copy the NOOBS to
SD card
 Setup the Raspberry Pi device
 Install the OS
 raspi-config
 Log in
 startx
 Now system reboots normally
Programming in Raspberry Pi
 Python (Primary programming language)
 Java
 C/C++
 HTML5
 JavaScript
 Scratch (Mathematical and computational
concepts)
 JQuery (JavaScript library)
 Perl
 Erlang
Some important commands
 To open the configuration tool after this,
simply run the following from the command
line:
 sudo raspi-config
 The sudo is required because you will be
changing files that you do not own as the
pi user.
Sample Code-1: LED Blink
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import the sleep function from the
time module

GPIO.setwarnings(False) # Ignore warning for now


GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be
an output pin and set initial value to low (off)

while True: # Run forever


GPIO.output(8, GPIO.HIGH) # Turn Pin
on 8: with LED
sleep(1) # Sleep for 1 second
GPIO.output(8, GPIO.LOW) # Turn off
sleep(1) # Sleep for 1 second
Sample Code-2: Button Event
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library

def button_callback(channel):
print("Button was pushed!")

GPIO.setwarnings(False) # Ignore warning for now


GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #
Set pin 10 to be an input pin and set initial value to be pulled
low (off)

GPIO.add_event_detect(10,GPIO.RISING,callback=button_callb
ack) # Setup event on pin 10 rising edge

message = input("Press enter to quit\n\n") # Run until


someone presses enter

Running
GPIO.cleanup() the code:
# Clean up $ python3
push_button.py
Sample Code-3: SPI LCD with RPi
# The second character
# Clear display msg = [0x7c]
msg = [0x76] msg.append(i)
spi.xfer2(msg) result = spi.xfer2(msg)

time.sleep(5) # The third character


msg = [0x7d]
# Turn on one segment of each character to msg.append(i)
show that we can result = spi.xfer2(msg)
# address all of the segments
i=1 # The last character
while i < 0x7f: msg = [0x7e]
msg.append(i)
# The decimals, colon and apostrophe result = spi.xfer2(msg)
dots
msg = [0x77] # Increment to next segment in each
msg.append(i) character
result = spi.xfer2(msg) i <<= 1

# The first character # Pause so we can see them


msg = [0x7b] time.sleep(5)
msg.append(i)
result = spi.xfer2(msg) # Clear display again
msg = [0x76]
spi.xfer2(msg)
Application of Raspberry Pi
 Supercomputer
 Developed by Prof
Simon Cox of the
University of
Southampton
 Calculating Pi was the
first test
 System has 64
processors and 1TB
of memory
 Each Raspberry Pi
has 16 Gb of SD card
Robots and Drones
Other Applications
 Media streamer
 Home automation
 Cosmic computer
 Tablet computer
 Game stations
What’s makes it special?
 Low price
 Open-source
 Low power consumption
 Small size
 Over clocking
 No need of heat-sink
 Connect to old analogue TV
 Supports 1080p HD video
What’s new?
Raspberry Pi 2 Model B

 900 MHz quad-core ARM Cortex-A7 processor


 1 Gb SDRAM
 4.5 W power
 Supports OS same as for Raspberry Pi 1, plus
Windows 10, Ubuntu and Android
References
 www.raspberrypi.org
 en.wikipedia.org/wiki/Raspberry_Pi
 www.slideshare.net/ltg_oxford/raspberry-pie-a
n-introduction
 www.cabbagesofdoom.blogspot.in
 www.techrepublic.com
 www.paw.princeton.edu
 www.jasperproject.github.io
THANK YOU

You might also like