Raspberry Pi Zero Cookbook

Book description

Over 80 practical and interesting recipes that explore the plethora of functionalities and opportunities available with Raspberry Pi Zero

About This Book

  • Deep dive into the components of the small yet powerful Raspberry Pi Zero

  • Get into grips with integrating various hardware, programming, and networking concepts with the so-called “cheapest computer”

  • Explore the functionalities of this $5 chip through practical recipes

  • Who This Book Is For

    This book is for programmers and hobbyists who are eager to dive deep into the Raspberry Pi Zero. If you have basic or zero knowledge of the Raspberry Pi Zero, or if you looking for examples of ways to utilize the Raspberry Pi’s GPIO interface, then this book is ideal for you. Basic knowledge of Python will be beneficial, and experience with circuitry and electronics will be needed for the later chapters in the book.

    What You Will Learn

  • Set up your Raspberry Pi Zero with the operating system, networking, and different interfaces

  • Get a hands-on introduction to Linux, Python, and shell scripts with the Raspberry Pi Zero

  • Become a master at driving GPIOs and controlling relays, motors, transistors, buzzers, audio, read switches, and interrupts with the Raspberry Pi Zero

  • Control GPIOs using the web interface and Node.js

  • Connect displays, LED matrixes, analog sensors, and digital sensors

  • Hack the Ethernet on the Raspberry Pi Zero

  • Make your Raspberry Pi Zero an IoT-based sensor node and remotely monitor your data

  • In Detail

    The Raspberry Pi Zero, one of the most inexpensive, fully-functional computers available, is a powerful and revolutionary product developed by the Raspberry Pi Foundation. The Raspberry Pi Zero opens up a new world for the makers out there. This book will give you expertise with the Raspberry Pi Zero, providing all the necessary recipes that will get you up and running.

    In this book, you will learn how to prepare your own circuits rather than buying the expensive add–ons available in the market. We start by showing you how to set up and manage the Pi Zero and then move on to configuring the hardware, running it with Linux, and programming it with Python scripts. Later, we integrate the Raspberry Pi Zero with sensors, motors, and other hardware. You will also get hands-on with interesting projects in media centers, IoT, and more.

    Style and approach

    This recipe-based book will ensure you gain an intermediate-level knowledge of the Raspberry Pi Zero. This book contains comprehensive illustrations with specific schematics for each circuit diagram.

    Table of contents

    1. Raspberry Pi Zero Cookbook
      1. Raspberry Pi Zero Cookbook
      2. Credits
      3. About the Author
      4. About the Reviewer
      5. www.PacktPub.com
        1. Why subscribe?
      6. Customer Feedback
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book 
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Kick-Start Your Raspberry Pi Zero
        1. Introduction
        2. Understanding the standard connectors and test points
          1. Getting ready
          2. How to do it...
        3. Reviewing power supply requirements
          1. How to do it...
        4. Choosing an operating system to install
          1. How to do it...
        5. Writing to an SD card with NOOBS
          1. Getting ready
          2. How to do it...
          3. There's more...
        6. Using Windows to write a Raspbian image to an SD card
          1. How to do it...
        7. Using OS X to validate a Raspbian image and write it to an SD card
          1. How to do it...
        8. Using Ubuntu 16.04 to validate a Raspbian image and write it to an SD card
          1. How to do it...
        9. Identifying RCA solder points for analog video connections
          1. Getting ready
          2. How to do it...
        10. Adding a USB extension over a USB OTG connector
          1. Getting ready
          2. How to do it...
        11. Connecting to displays and changing the configuration settings
          1. Getting ready
          2. How to do it...
            1. Initial Pi configuration
        12. Logging in to the RPZ desktop for the first time, creating users, and rebooting
          1. How to do it...
          2. There's more...
      9. 2. Setting Up Physical and Wireless Connections
        1. Introduction
        2. Controlling the RPZ from the UART GPIO port using the console cable
          1. Getting ready
          2. How to do it...
        3. Adding Wi-Fi dongle over USB OTG
          1. Getting ready
          2. How to do it...
        4. Hacking RPZ hardware to add up permanent Wi-Fi dongle
          1. Getting ready
          2. How to do it...
        5. Setting Up dynamic and static IP address for RPZ
          1. Getting ready
          2. How to do it...
        6. Pinging from another computer over same network
          1. Getting ready
          2. How to do it...
        7. SSHing your RPZ from your desktop computer
          1. Getting ready
          2. How to do it...
        8. Sharing a screen on your desktop computer
          1. Getting ready
          2. How to do it...
        9. Copying different files to and from your home network
          1. Getting ready
          2. How to do it...
        10. Adding USB functions to Raspbian Jessie
          1. Getting ready
          2. How to do it...
        11. Using a virtual serial adapter on USB OTG
          1. Getting ready
          2. How to do it...
        12. Programming over a virtual Ethernet modem on USB OTG
          1. Getting ready
          2. How to do it...
        13. Making your RPZ a USB mass storage device
          1. Getting ready
          2. How to do it...
          3. There's more...
      10. 3. Programming with Linux
        1. Navigating a filesystem and viewing and searching the contents of a directory
          1. Getting ready
          2. How to do it...
        2. Creating a new file, editing it in an editor, and changing ownership
          1. Getting ready
          2. How to do it...
        3. Renaming and copying/moving the file/folder into a new directory
          1. Getting ready
          2. How to do it...
        4. Installing and uninstalling a program
          1. Getting ready
          2. How to do it...
          3. There's more...
        5. Downloading a file from the Internet and deleting a file
          1. Getting ready
          2. How to do it...
        6. Changing to root and using superpowers
          1. Getting ready
          2. How to do it...
        7. Extracting a zipped file and zipping it back
          1. Getting ready
          2. How to do it...
        8. Searching executed code from the terminal's history
          1. Getting ready
          2. How to do it...
        9. Changing RPZ configuration settings from the command line
          1. Getting ready
          2. How to do it...
          3. There's more...
        10. Checking running processes and killing a process running in the background
          1. Getting ready
          2. How to do it...
        11. Creating our first shell program and automating a process
          1. Getting ready
          2. How to do it...
        12. Syncing with NTC servers to update the current time
          1. Getting ready
          2. How to do it...
        13. Running a background process in Linux
          1. Getting ready
          2. How to do it...
        14. Setting a file to run automatically on startup
          1. Getting ready
          2. How to do it...
        15. Using crontab to run a script automatically at predefined intervals
          1. Getting ready
          2. How to do it...
      11. 4. Programming with Python
        1. Introduction
        2. Choosing between Python 2 and 3
          1. Getting ready
          2. How to do it...
        3. Installing important Python packages
          1. Getting ready
          2. How to do it...
        4. Creating our first Python program and running loops
          1. Getting ready
          2. How to do it...
          3. There's more...
        5. Playing with strings
          1. Getting ready
          2. How to do it...
        6. Plotting graphs using Python
          1. Getting ready
          2. How to do it...
          3. There's more...
        7. Sending an e-mail from a Python Script
          1. Getting ready
          2. How to do it...
        8. Creating a program to log and append data to a CSV file
          1. Getting ready
          2. How to do it...
        9. Using a Python script to upload data online to a Google spreadsheet interface
          1. Getting ready
          2. How to do it
          3. There's more...
        10. Adding help and parameters to your Python Program
          1. Getting ready
          2. How to do it...
      12. 5. Getting Your Hands Dirty Using the GPIO Header
        1. Introduction
        2. Pin configurations and precautions for using the GPIO pins
          1. Getting ready
          2. How to do it...
        3. Using the GPIOs with the WiringPi library
          1. Getting ready
          2. How to do it...
        4. Connecting an LED with RPZ and controlling it using C, Python, and a shell
          1. Getting ready
          2. How to do it...
            1. Part 1 - blinking the LED using C
            2. Part 2 - blinking the LED using Python
            3. Part 3 - blinking the LED from the shell
        5. Basics of the UART port and getting data from the desktop on the serial port using Minicom
          1. Getting ready
          2. How to do it...
            1. Manually disabling the serial port
            2. Disabling the serial port the easy way
        6. Writing a Python/C program to get UART data in your code
          1. Getting ready
          2. How to do it...
        7. Basics of I2C and checking the I2C devices present on a port
          1. Getting ready
          2. How to do it...
        8. Basics of SPI and setting up an SPI module
          1. Getting ready
          2. How to do it...
        9. Converting a 5V signal into a 3.3V signal and slew rates
          1. Getting ready
          2. How to do it...
        10. Running RPZ on a battery
          1. Getting ready
            1. USB battery pack
            2. Prebuilt power convertor
            3. DIY power convertor
          2. How to do it...
            1. USB battery packs
            2. Prebuilt power convertor
            3. DIY voltage regulator
        11. Controlling GPIOs using a web interface
          1. Getting ready
          2. How to do it...
          3. How it works...
        12. Making RPZ a radio transmitter and sharing music
          1. Getting ready
          2. How to do it...
        13. Using a Node.js library to control the GPIOs
          1. Getting ready
          2. How to do it...
        14. Interfacing the ESP8266 WiFi module with RPZ
          1. Getting ready
          2. How to do it...
          3. There's more...
      13. 6. Controlling the LEDs and Displays
        1. Introduction
        2. Setting up brightness using PWM
          1. Getting ready
          2. How to do it...
        3. Monitoring Twitter/e-mails to blink an LED
          1. Getting ready
          2. How to do it...
        4. Connecting a seven-segment number display module to the RPZ
          1. Getting ready
          2. How to do it...
        5. Connecting an LED matrix display to the RPZ
          1. Getting ready
          2. How to do it...
        6. Connecting an RGB LED and generating different colors
          1. Getting ready
          2. How to do it...
        7. Interfacing the 16x2 LCD display with RPZ
          1. Getting ready
          2. How to do it...
        8. Connecting the 74HC595N shift register to control many LEDs
          1. Getting ready
          2. How to do it...
      14. 7. Controlling the Hardware
        1. Introduction
        2. Integrating voltage translators with the RPZ
          1. Getting ready
          2. How to do it...
        3. Controlling a stepper motor using a RPZ and motor drivers
          1. Getting ready
          2. How to do it...
        4. Connecting a DC motor and controlling its speed and direction
          1. Getting ready
          2. How to do it...
        5. Controlling high power AC load using relays
          1. Getting ready
          2. How to do it...
        6. Controlling high power DC load using MOSFETs
          1. Getting ready
          2. How to do it...
        7. Controlling a buzzer with an RPZ
          1. Getting ready
          2. How to do it...
        8. Monitoring the physical health of the RPZ hardware
          1. Getting ready
          2. How to do it...
        9. Interfacing the PiFace with the RPZ
          1. Getting ready
          2. How to do it...
      15. 8. Taking Digital Inputs to the Raspberry Pi Zero
        1. Introduction
        2. Interfacing push switches
          1. Getting ready
          2. How to do it...
        3. Interfacing toggle switches and setting debouncing
          1. Getting ready
          2. How to do it...
        4. Avoiding the floating states of the input line
          1. Getting ready
          2. How to do it...
        5. Interfacing a keypad with the RPZ
          1. Getting ready
          2. How to do it...
        6. Interfacing RTC to get accurate time
          1. Getting ready
          2. How to do it...
          3. There's more...
        7. Setting up Interrupts on a toggle switch through GPIO
          1. Getting ready
          2. How to do it...
        8. Interfacing RFID tags with the RPZ
          1. Getting ready
          2. How to do it...
        9. Interfacing a GPS module with the RPZ
          1. Getting ready
            1. Enabling the Google Geocoding API
          2. How to do it...
      16. 9. Interfacing Sensors with the Raspberry Pi Zero
        1. Interfacing any resistive sensor on GPIO
          1. Getting ready
          2. How to do it...
        2. Interfacing an LDO with the RPZ
          1. Getting ready
          2. How to do it...
        3. Interfacing an ultrasonic sensor with the RPZ
          1. Getting ready
          2. How to do it...
        4. Interfacing an analog-to-digital convertor to interface any analog sensor with the RPZ
          1. Getting ready
          2. How to do it...
        5. Interfacing an infrared receiver to read remote controls and control a TV with the RPZ
          1. Getting ready
          2. How to do it...
        6. Interfacing a motion sensor
          1. Getting ready
          2. How to do it...
        7. Interfacing a temperature humidity sensor using bit-banging
          1. Getting ready
          2. How to do it...
        8. Interfacing a gyroscope and accelerometer with the RPZ
          1. Getting ready
          2. How to do it...
        9. Pulling it all together with the Pi Sense Hat
          1. Getting ready
          2. How to do it...
      17. 10. Cooking up Projects to Amaze the World!
        1. Introduction
        2. Setting up hardware for home automation with the RPZ
          1. Getting ready
          2. How to do it...
        3. Setting up software for home automation with the RPZ
          1. Getting ready
          2. How to do it...
        4. Making the RPZ an IoT Sensor Node
          1. Getting ready
          2. How to do it...
        5. Making the RPZ a media center
          1. Getting ready
          2. How to do it...
        6. Controlling RPZ media center using IR remote
          1. Getting ready
          2. How to do it...
        7. Heartrate monitoring wearable device
          1. Getting ready
          2. How to do it...

    Product information

    • Title: Raspberry Pi Zero Cookbook
    • Author(s): Edward Snajder
    • Release date: March 2017
    • Publisher(s): Packt Publishing
    • ISBN: 9781786463852