Book Image

Python Programming with Raspberry Pi

By : Sai Yamanoor, Srihari Yamanoor
Book Image

Python Programming with Raspberry Pi

By: Sai Yamanoor, Srihari Yamanoor

Overview of this book

Raspberry Pi Zero is a super-small and super-affordable product from Raspberry Pi that is packed with a plethora of features and has grabbed the notice of programmers, especially those who use Python. This step-by-step guide will get you developing practical applications in Python using a Raspberry Pi Zero. It will become a valuable resource as you learn the essential details of interfacing sensors and actuators to a Raspberry Pi, as well as acquiring and displaying data. You will get started by writing a Python program that blinks an LED at 1-second intervals. Then you will learn to write simple logic to execute tasks based upon sensor data (for example, to control a motor) and retrieve data from the web (such as to check e-mails to provide a visual alert). Finally, you will learn to build a home automation system with Python where different appliances are controlled using the Raspberry Pi. The examples discussed in each chapter of this book culminate in a project that help improve the quality of people’s lives.
Table of Contents (17 chapters)
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Introduction to the Raspberry Pi Zero


The Raspberry Pi Zero is a small computer that costs about $5 and smaller than a credit card, designed by the Raspberry Pi Foundation (a nonprofit organization with the mission to teach computer science to students, especially those who lack of access to the requisite tools). The Raspberry Pi Zero was preceded by the Raspberry Pi Models A and  B. A detailed history of the Raspberry Pi and the different models of the Raspberry Pi is available on http://elinux.org/RPi_General_History. The Raspberry Pi Zero was released on 26th November 2015 (Thanksgiving Day).

Note

A fun fact for the readers is that one of the authors of this book, Sai Yamanoor, drove from San Francisco to Los Angeles (700+ miles for a round trip in one day) on the day after Thanksgiving to buy the Raspberry Pi Zero from a local store.

 

The features of the Raspberry Pi Zero

The Raspberry Pi Zero is powered by a 1 GHz BCM2835 processor and 512 MB RAM. BCM2835 is a System on a Chip (SoC) developed by Broadcom semiconductors. SoC is one where all the components required to run a computer are available on a single chip (for example, the BCM2835 includes CPU, GPU, peripherals such as USB interface). The documentation for the BCM2835 SoC is available at https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/README.md.

The Raspberry Pi Zero board version 1.3

Let's briefly discuss the features of the Raspberry Pi Zero using the preceding picture marked with numbered rectangles:

  1. The mini HDMI interface: The mini HDMI interface is used to connect a display to the Raspberry Pi Zero. The HDMI interface can be used to drive a display of maximum resolution of 1920x1080 pixels.
  2. USB On-The-Go interface: In the interest of keeping things low cost, the Raspberry Pi Zero comes with a USB On-The-Group (OTG) interface. This interface enables interfacing USB devices such as a mouse and keyboard. Using a USB OTG to USB-A female converter. We need a USB hub to interface any USB accessory.
  3. Power supply: The micro-B USB adapter is used to power the Raspberry Pi zero, and it draws about a maximum of 200 mA of current.
  4. micro SD card slot: The Raspberry Pi's operating system (OS) resides in a micro SD card and the bootloader on the processor loads it upon powering up.
  5. GPIO interface: The Raspberry Pi Zero comes with a 40-pin general purpose input/output (GPIO) header that is arranged in two rows of 20 pins. The Raspberry Pi Zero's GPIO interface is shipped without a soldered header. The GPIO header is used to interface sensors, control actuators, and interface appliances. The GPIO header also consists of communication interfaces such as UART and I2C. We will discuss the GPIO in detail in the second chapter.
  6. RUN and TV pins: There are two pins labeled as RUN below the GPIO header. These pins are used to reset the Raspberry Pi using a small tactile switch/push button. The TV pin is used to provide a composite video output.
  7. Camera interface: Raspberry Pi Zero boards (version 1.3 or higher) come with a camera interface. This enables interfacing a camera designed by the Raspberry Pi Foundation (https://www.raspberrypi.org/products/camera-module-v2/).

All these features of the Raspberry Pi have enabled them to be used by hobbyists in projects involving home automation, holiday decorations, and more, limited only by your imagination. Scientists have used them in experiments, including tracking of bees, tracking wildlife, perform computation-intensive experiments. Engineers have used the Raspberry Pi to build robots, mine bitcoins, check Internet speeds to send Twitter messages when the speeds are slow, and order pizza!