Raspberry Pi

From ATI Chennai IT and ITES Wiki

Jump to: navigation, search

Back to IoT Course Material

In India, Element14 sells RaspberryPi. See Video.




RaspberryPi3 back.jpg

Technical Specifications

Technical Details
Parameter Value
Brand Raspberry Pi
Series Model B
Colour Black
Item Height 34 Millimeters
Item Width 7.6 Centimeters
Screen Size 60 Inches
Item Weight 45.4 g
Product Dimensions 12.2 x 7.6 x 3.4 cm
Item model number RASPBERRYPI3-MODB-1GB
Processor Count 4
RAM Size 1 GB
Wireless Type 802.11bgn
Number of USB 2.0 Ports 4
Voltage 5 Volts
Operating System Ubuntu Mate, Snappy Ubuntu Core, PINET, Windows 10 IOT, Raspbian, Pidora, OSMC, OpenElec, RISC OS, Arch Linux
Included Components Motherboard


RPi4ModelB Pinout.png

Running PHP on Raspberry Pi

PHP is installed along with Git and WiringPi by:

sudo apt-get install apache2 git-core php5
# or a more lightweight one
# sudo apt-get install lighttpd git-core php5
git clone git://git.drogon.net/wiringPi
cd wiringPi
# Check the install
gpio -v
gpio readall

The LED.php script in the webroot can be like:

        <meta name="viewport" content="width=device-width" />
        <title>LED Control</title>
        LED Control:
        <form method="get" action="gpio.php">
            <input type="submit" value="ON" name="on">
            <input type="submit" value="OFF" name="off">
            $setmode17 = shell_exec("/usr/local/bin/gpio -g mode 17 out");
            if(isset($_GET['on'])) {
                $gpio_on = shell_exec("/usr/local/bin/gpio -g write 17 1");
                echo "LED is on";
            else if(isset($_GET['off'])) {
                $gpio_off = shell_exec("/usr/local/bin/gpio -g write 17 0");
                echo "LED is off";

Raspberry Pi Cheat Sheet

# RPi.GPIO Basics cheat sheet - Don't try to run this. It'll fail!
# Alex Eames http://RasPi.TV
# http://RasPi.TV/?p=4320

# RPi.GPIO Official Documentation http://sourceforge.net/p/raspberry-gpio-python/wiki/Home/
# PWM Usage: https://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/

import RPi.GPIO as GPIO              # import RPi.GPIO module  

# choose BOARD or BCM
GPIO.setmode(GPIO.BCM)               # BCM for GPIO numbering
GPIO.setmode(GPIO.BOARD)             # BOARD for P1 pin numbering

# Set up Inputs
GPIO.setup(port_or_pin, GPIO.IN)     # set port/pin as an input
GPIO.setup(port_or_pin, GPIO.IN,  pull_up_down=GPIO.PUD_DOWN) # input with pull-down
GPIO.setup(port_or_pin, GPIO.IN,  pull_up_down=GPIO.PUD_UP)   # input with pull-up 

# Set up Outputs
GPIO.setup(port_or_pin, GPIO.OUT)               # set port/pin as an output   
GPIO.setup(port_or_pin, GPIO.OUT, initial=1)    # set initial value option (1 or 0)

# Switch Outputs
GPIO.output(port_or_pin, 1)     # set an output port/pin value to 1/GPIO.HIGH/True  
GPIO.output(port_or_pin, 0)     # set an output port/pin value to 0/GPIO.LOW/False  

# Read status of inputs OR outputs
i = GPIO.input(port_or_pin)     # read status of pin/port and assign to variable i
if GPIO.input(port_or_pin):     # use input status directly in program logic

# Clean up on exit

# What Raspberry Pi revision are we running?
GPIO.RPI_REVISION #  0 = Compute Module, 1 = Rev 1, 2 = Rev 2, 3 = Model B+

# What version of RPi.GPIO are we running?

# What Python version are we running?
import sys; sys.version

Availability and Accessories

Video Lectures


Personal tools