Embedded System Raspberry Pi Manual, Lecture notes of Electronics

Embedded System Raspberry Pi Manual

Typology: Lecture notes

2017/2018

Uploaded on 12/12/2018

ravivarman-rajendira
ravivarman-rajendira 🇮🇳

1 document

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
www.dreamerindia.com
DREAMERINDIA
INNOVATIONS
RASPBERRY
www.dreamerindia.com
|
www.embeddedcollege.org
RASPBERRY
PI
B+
WORKSHOP
RAVIVARMAN
www.embeddedcollege.org
MANUAL
RAVIVARMAN
RAJENDIRAN
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Embedded System Raspberry Pi Manual and more Lecture notes Electronics in PDF only on Docsity!

www.dreamerindia.com

DREAMERINDIA

INNOVATIONS

RASPBERRY

www.dreamerindia.com | www.embeddedcollege.org

RASPBERRY PI B+ WORKSHOP MANUAL

RAVIVARMAN

www.embeddedcollege.org

MANUAL

RAVIVARMAN RAJENDIRAN

RASPBERRY PI B+ WORKSHOP MANUAL

Introduction:

The Raspberry Pi is an index card-sized

Pi Foundation. The Raspberry Pi has a

ARM1176JZF-S 700 MHz processor,

megabytes of RAM, later upgraded (Model B & Model B+) to 512

hard disk or solid-state drive, but it uses an

Model B+ using a Micro SD.

Task-1-: Installation of OS into Raspberry Pi

There are two methods of installing OS into Raspberry Pi. By using NOOBS or directly installing

required OS.I hereby given both the methods and I prefer install OS directly.

Method-I: (NOOBS Method)

 Check List: Hardware:-Raspberry Pi Board, SD Card, USB Power Cable, US

and HDMI to VGA Converter. Software

Insert an SD card that is 4GB or greater in size into your computer.

Install and run the SDFormatter

ADJUSTMENT" option to "ON" in the "Options" menu

Check that the SD card you inserted matches the one selected by the Tool

Click the "Format" button. Extract

Copy the extracted files onto the SD c

directory of the SD card. Please note that in some cases it may extract the files into a folder,

if this is the case then please copy across the files from inside the folder rather than the

folder itself.

Insert the SD card into your

Your Pi will now boot into NOOBS and should display a list of operating systems that you can

choose to install.

If your display remains blank, you should select the correct output mode

pressing one of the following number keys on your keyboard:

o 1-HDMI mode - this is the default display mode.

o 2-HDMI safe mode

cannot see anything on screen when the Pi has boote

o 3-Composite PAL mode

using the composite RCA video connector.

o 4-Composite NTSC mode

Method-II: (Direct OS Method)

 Check List: Hardware:-Raspberry Pi Board, SD Card, USB Power Cable, USB

and HDMI to VGA Converter. Software

RASPBERRY PI B+ WORKSHOP MANUAL

sized single-board computer developed in the UK by the

. The Raspberry Pi has a Broadcom BCM2835 system on a chip (SoC), which includes an

processor, Video Core IV GPU, and was originally shipped with

, later upgraded (Model B & Model B+) to 512 MB. It does not include a built

, but it uses an SD card for booting and persistent storage, with the

Installation of OS into Raspberry Pi

installing OS into Raspberry Pi. By using NOOBS or directly installing

both the methods and I prefer install OS directly.

Raspberry Pi Board, SD Card, USB Power Cable, USB Keyboard,

Software:- NOOBS & SDFormatter.

Insert an SD card that is 4GB or greater in size into your computer.

SDFormatter Formatting Tool on your machine. Set "FORMAT SIZE

ADJUSTMENT" option to "ON" in the "Options" menu.

Check that the SD card you inserted matches the one selected by the Tool.

Extract the files contained in this NOOBS zip file.

Copy the extracted files onto the SD card that you just formatted so that this file is at the root

directory of the SD card. Please note that in some cases it may extract the files into a folder,

if this is the case then please copy across the files from inside the folder rather than the

Insert the SD card into your Pi and connect the power supply.

Your Pi will now boot into NOOBS and should display a list of operating systems that you can

If your display remains blank, you should select the correct output mode for your display by

pressing one of the following number keys on your keyboard:

this is the default display mode.

HDMI safe mode - select this mode if you are using the HDMI connector and

cannot see anything on screen when the Pi has booted.

Composite PAL mode - select either this mode or composite NTSC mode if you are

using the composite RCA video connector.

Composite NTSC mode.

Raspberry Pi Board, SD Card, USB Power Cable, USB Keyboard,

Software: - Raspian OS & Win32DiskImager.

by the Raspberry

(SoC), which includes an

IV GPU, and was originally shipped with 256

. It does not include a built-in

for booting and persistent storage, with the

installing OS into Raspberry Pi. By using NOOBS or directly installing

B Keyboard, Monitor

"FORMAT SIZE

ard that you just formatted so that this file is at the root

directory of the SD card. Please note that in some cases it may extract the files into a folder,

if this is the case then please copy across the files from inside the folder rather than the

Your Pi will now boot into NOOBS and should display a list of operating systems that you can

for your display by

select this mode if you are using the HDMI connector and

select either this mode or composite NTSC mode if you are

Keyboard, Monitor

 Check List: Hardware: - 5MP Camera for Raspberry

STEPS:

Switch off the Kit.

Install the Raspberry Pi Camera module by inserting the cable into the Raspberry Pi. The

cable slots into the connector situated

connectors facing the HDMI port.

From the prompt, run "sudo raspi

to run a few commands to update your Raspberry Pi.

Boot up your Raspberry Pi.

Run "sudo raspi-config" again

Navigate to the "camera" option, and enable it. Select “Finish” and reboot your Raspberry Pi.

"raspistill" is a command line application that allows you to capture images with your

camera module. Below is an example of this command in use.

To capture an image in jpeg format, type "raspistill

"image" is the name of your image.

"raspivid" is a command line application that allows you to capture video

module. Below is an example of this command in use.

To capture a 10 second video with your Raspberry Pi camera module, run "raspivid

video.h264 -t 10000" at the prompt, where "video" is the name of your video and "10000" is

the number of milliseconds.

To view the image, Open file manager and right click on the image name you gave and select

image viewer.

To play the video, open Lxterminal and go to the directory where video is saved, type

command omxplayer videoname.h264.

Task-4: GPIO Interfacing – LED & Pushbutton

LED Turn ON and OFF using Python via GPIO Interface

 Check List: Hardware:-1xRed LED

 Circuit connection:

5MP Camera for Raspberry.

Install the Raspberry Pi Camera module by inserting the cable into the Raspberry Pi. The

cable slots into the connector situated between the Ethernet and HDMI ports, with the silver

connectors facing the HDMI port.

From the prompt, run "sudo raspi-config". If the "camera" option is not listed, you will need

to run a few commands to update your Raspberry Pi.

config" again - you should now see the "camera" option.

Navigate to the "camera" option, and enable it. Select “Finish” and reboot your Raspberry Pi.

"raspistill" is a command line application that allows you to capture images with your

camera module. Below is an example of this command in use.

To capture an image in jpeg format, type "raspistill - o image.jpg" at the prompt, where

"image" is the name of your image.

"raspivid" is a command line application that allows you to capture video with your camera

module. Below is an example of this command in use.

To capture a 10 second video with your Raspberry Pi camera module, run "raspivid

t 10000" at the prompt, where "video" is the name of your video and "10000" is

f milliseconds.

To view the image, Open file manager and right click on the image name you gave and select

To play the video, open Lxterminal and go to the directory where video is saved, type

command omxplayer videoname.h264.

LED & Pushbutton

LED Turn ON and OFF using Python via GPIO Interface

1xRed LED, 1xBlue LED, 2x330 ohms resistors & Jumper Wires.

Install the Raspberry Pi Camera module by inserting the cable into the Raspberry Pi. The

between the Ethernet and HDMI ports, with the silver

config". If the "camera" option is not listed, you will need

Navigate to the "camera" option, and enable it. Select “Finish” and reboot your Raspberry Pi.

"raspistill" is a command line application that allows you to capture images with your

o image.jpg" at the prompt, where

with your camera

To capture a 10 second video with your Raspberry Pi camera module, run "raspivid -o

t 10000" at the prompt, where "video" is the name of your video and "10000" is

To view the image, Open file manager and right click on the image name you gave and select

To play the video, open Lxterminal and go to the directory where video is saved, type

ohms resistors & Jumper Wires.

 Program Code:

TURN ON THE LEDS “

#!/usr/bin/python import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.cleanup() GPIO.setwarnings(False) GPIO.setup(17,GPIO.OUT) GPIO.setup(27,GPIO.OUT) print "Lights on" GPIO.output(17,GPIO.HIGH) GPIO.output(27,GPIO.HIGH)

TURN OFF THE LEDS “

#!/usr/bin/python import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.cleanup() GPIO.setwarnings(False) GPIO.setup(17,GPIO.OUT) GPIO.setup(27,GPIO.OUT) print "Lights OFF GPIO.output(17,GPIO.LOW) GPIO.output(27,GPIO.LOW)

STEPS:

Create file “LED_on.py” with above code &

Create file “LED_off.py” with above code & save.

Open LXTerminal and cd to program code saved directory.

To run the python code “sudo python

To run the python code “sudo python LED

Pushbutton input using Python via GPIO Interface

 Check List: Hardware:-1xPushbutton

 Circuit connection:

TURN ON THE LEDS “LED_on.py”

#!/usr/bin/python import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM)

GPIO.setwarnings(False) GPIO.setup(17,GPIO.OUT) GPIO.setup(27,GPIO.OUT) print "Lights on" GPIO.output(17,GPIO.HIGH) GPIO.output(27,GPIO.HIGH)

TURN OFF THE LEDS “LED_off.py”

#!/usr/bin/python import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM)

GPIO.setwarnings(False) GPIO.setup(17,GPIO.OUT) GPIO.setup(27,GPIO.OUT) "Lights OFF" GPIO.output(17,GPIO.LOW) GPIO.output(27,GPIO.LOW)

with above code & save.

with above code & save.

Open LXTerminal and cd to program code saved directory.

sudo python LED_on.py” and Watch LEDS turn on

sudo python LED_off.py” and Watch LEDS turn

using Python via GPIO Interface

Pushbutton, 1x4.7K ohms resistor & Jumper Wires.

 Program Code:

import os import glob import time #initialize the device os.system('modprobe w os.system('modprobe w

base_dir = '/sys/bus/w1/devices/' device_folder = glob.glob(base_dir + '28*')[0] device_file = device_folder + '/w1_slave'

def read_temp_raw(): f = open(device_file, 'r') lines = f.readlines() f.close() return lines

def read_temp(): lines = read_temp_raw() while lines[0].strip()[ time.sleep(0.2) lines = read_temp_raw() equals_pos = lines[1].find('t=') if equals_pos != temp_string = lines[1][equals_pos+2:] temp_c = float(temp_string) / 1000. temp_f = temp_c * 9.0 / 5.0 + 32. return temp_c, temp_f

while True: print(read_temp time.sleep(1)

STEPS:

Create file “Temperature.py

Open LXTerminal.

Type “sudo nano /etc/modules

Add the line “w1-gpio” and “

Type “sudo reboot” to reboot the system.

Open LXTerminal.

Type “sudo modprobe w1-gpio

Type “sudo modprobe w1-therm

Type “cd /sys/bus/w1/devices

the drivers installed.

Change directory to program code saved directory.

To run the python code “sudo

#initialize the device os.system('modprobe w1-gpio') os.system('modprobe w1-therm')

base_dir = '/sys/bus/w1/devices/' device_folder = glob.glob(base_dir + '28*')[0] device_file = device_folder + '/w1_slave'

read_temp_raw(): f = open(device_file, 'r') lines = f.readlines()

return lines

def read_temp(): lines = read_temp_raw() while lines[0].strip()[-3:] != 'YES': time.sleep(0.2) lines = read_temp_raw() equals_pos = lines[1].find('t=') if equals_pos != -1: temp_string = lines[1][equals_pos+2:] temp_c = float(temp_string) / 1000. temp_f = temp_c * 9.0 / 5.0 + 32. return temp_c, temp_f

print(read_temp()) time.sleep(1)

.py” with above code & save.

sudo nano /etc/modules”, and open modules file in nano editor.

” and “w1-therm” to install 1-wire drivers.

reboot the system.

gpio” to install 1-wire driver.

therm” to install DS1820 driver.

cd /sys/bus/w1/devices” and “ls –l” to list the installed drivers. It should show both

to program code saved directory.

sudo Temperature.py” to measure the temperature.

to list the installed drivers. It should show both

APPENDIX: 1

Linux Basic Commands:

  • raspi-config – Raspberry pi setup screen
  • startx – To run the graphical user interface
  • lxsession – To run the graphical user interface in x
  • Ifconfig – To get the network details.
  • ping – Check the communication made with the host.
  • ls – List the files in the
  • cd – Change directory.
  • pwd – Displays present working directory.
  • mkdir – Makes new directory.
  • rmdir – Remove empty Directory.
  • rm – Removes the file.
  • mv – Moves or Rename the file/directory.
  • cp – Makes the copy of the file.
  • cat – List the content of file(s).
  • sudo – Run command as super user.
  • chmod – Change file permissions.
  • head & tail – Displays beginning and end of file.
  • wget – Download the file from website.
  • man – View the manual page.
  • grep – Search inside files for given patterns.
  • find – Find files in the directory.
  • whereas – Find location of file.
  • python – Runs the puthon programs
  • lsmod – List the modules installed.
  • vi,nano – VI and Nano code editor.
  • poweroff or shutdown & reboot

APPENDIX: 2

Raspberry Pi B GPIO Configuration:

Raspberry pi setup screen To run the graphical user interface To run the graphical user interface in x-server mode. To get the network details. Check the communication made with the host. List the files in the current directory. Change directory. Displays present working directory. Makes new directory. Remove empty Directory. Removes the file. Moves or Rename the file/directory. Makes the copy of the file. the content of file(s). Run command as super user. Change file permissions. Displays beginning and end of file. Download the file from website. View the manual page. Search inside files for given patterns. Find files in the directory. Find location of file. Runs the puthon programs. List the modules installed. VI and Nano code editor. poweroff or shutdown & reboot – Shutdowns and restart the kit.

GPIO Configuration:

server mode.

Shutdowns and restart the kit.