Book Image

Raspberry Pi 3 Cookbook for Python Programmers - Third Edition

By : Steven Lawrence Fernandes, Tim Cox
Book Image

Raspberry Pi 3 Cookbook for Python Programmers - Third Edition

By: Steven Lawrence Fernandes, Tim Cox

Overview of this book

Raspberry Pi 3 Cookbook for Python Programmers – Third Edition begins by guiding you through setting up Raspberry Pi 3, performing tasks using Python 3.6, and introducing the first steps to interface with electronics. As you work through each chapter, you will build your skills and apply them as you progress. You will learn how to build text classifiers, predict sentiments in words, develop applications using the popular Tkinter library, and create games by controlling graphics on your screen. You will harness the power of a built in graphics processor using Pi3D to generate your own high-quality 3D graphics and environments. You will understand how to connect Raspberry Pi’s hardware pins directly to control electronics, from switching on LEDs and responding to push buttons to driving motors and servos. Get to grips with monitoring sensors to gather real-life data, using it to control other devices, and viewing the results over the internet. You will apply what you have learned by creating your own Pi-Rover or Pi-Hexipod robots. You will also learn about sentiment analysis, face recognition techniques, and building neural network modules for optical character recognition. Finally, you will learn to build movie recommendations system on Raspberry Pi 3.
Table of Contents (23 chapters)
Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
Index

The hardware list


A summary of the hardware used in the chapters of this book is mentioned in this section.

Chapter 1

A summary of the hardware used in the chapters of this book is mentioned in this section.

This chapter describes the Raspberry Pi setup; the items mentioned include the following:

  • Raspberry Pi and its power supply
  • An HDMI display and HDMI cable/analog TV and an analog video cable
  • Keyboard
  • Mouse
  • Network cable/Wi-Fi adaptor

Chapters 2 – Chapter 7

No additional hardware has been used in these chapters, as they discuss purely software recipes.

Chapter 8

This chapter only uses the USB webcam hardware.

Chapter 9

The components used in this chapter are available at most electronic component retailers (such as those listed previously in the General electronic component retailers section). They are also available as a complete kit from Pi Hardware; where items are available from specific retailers, they are highlighted in the text.

The kit for controlling an LED includes the following equipment:

  • Four Dupont Female-to-Male Patch Wires (Pimoroni Jumper Jerky)
  • A mini breadboard (170 tie-point) or a larger one (Pimoroni)
  • An RGB LED (common-cathode) or 3 standard LEDs (ideally red/green/blue)
  • A breadboarding wire (solid core)
  • Three 470-ohm resistors

The kit for responding to a button includes the following equipment:

  • Two Dupont Female to Male Patch wires (Pimoroni Jumper Jerky)
  • A mini breadboard (170 tie-point) or a larger one (Pimoroni)
  • A push button to make switch and momentary switch (or a wire connection to make/break the circuit)
  • A breadboarding wire (solid core)
  • A 1K ohm resistor

The items used for the controlled shutdown button are as follows:

  • Three Dupont Female-to-Male Patch Wires (Pimoroni Jumper Jerky)
  • A mini breadboard (170 tie-point) or larger (Pimoroni)
  • A push-button switch (momentary close)
  • A normal LED (red)
  • Two 470-ohm resistors
  • A breadboarding wire (solid core)

The additional items used in the There's more... section of the recipe, A controlled shutdown button, are as follows:

  • A push button
  • A 470-ohm resistor
  • A pin header and two pins with a jumper connector (or optionally a switch)
  • A breadboarding wire (solid core)
  • Two 4 pin headers

The items used for the GPIO keypad input are as follows:

  • Breadboard: half-sized or larger (Pimoroni)
  • Seven Dupont Female-to-Male Patch Wires (Pimoroni Jumper Jerky)
  • Six push buttons
  • Six 470-ohm resistors
  • Alternatively, a self-solder DPad Kit (Pi Hardware)

The items used for multiplexed color LEDs are as follows:

  • Five Common-Cathode RGB LEDs
  • Three 470-ohm resistors
  • Vero-prototype board or large breadboard (Tandy)
  • A self-solder RGB-LED kit (Pi Hardware)

The items used for writing messages require the same items as the preceding recipe, plus the following:

  • A mounting stick, rubber bands, USB Wi-Fi, portable USB battery, and so on
  • A Tilt Switch (ball-bearing type is suitable) (4-Tronix)

Chapter 10

This chapter uses the following hardware:

  • A PCF8591 chip or module (DealExtreme SKU: 150190 or a Quick2Wire I2C Analogue Board Kit)
  • Adafruit I2C Bidirectional logic-level translator (Adafruit ID: 757)

Chapter 11

No additional hardware has been used in this chapter, as they discuss purely software recipes.

Chapter 12

Pi-Rover requires the following hardware or a hardware similar to that:

  • A giant paper clip (76 mm/3 inches) or a caster wheel
  • Motor and geared wheels (ModMyPi or PiBorg)
  • Battery/power source
  • Chassis: push nightlight
  • Motor driver/controller: Darlington Array Module ULN2003 (DealExtreme SKU - 153945)
  • Small cable ties or wire ties

The following list is also mentioned in the There's more... section:

  • PicoBorg Motor Controller (PiBorg PicoBorg)
  • Magician Robot Chassis (Sparkfun ID: 10825)
  • 4-Motor Smart Car Chassis (DealExtreme SKU: 151803)
  • 2-Wheel Smart Car Model (DealExtreme SKU: 151803)

The advanced motor control example uses the following item:

  • The H-Bridge motor controller (DealExtreme SKU: 120542 or GeekOnFire SKU: A2011100407)

The Hex Pod Pi-Bug requires the following hardware or similar:

  • Adafruit I2C 16-Channel 12-bit PWM/Servo Driver (Adafruit ID: 815)
  • MG90S 9g Metal Gear Servos (HobbyKing)
  • Three giant paper clips (76mm/3 inches)
  • Light gauge wire/cable ties
  • A small section of plywood or a fiberboard

A basic servo-based robot arm is used for the ServoBlaster example (4-Tronix MeArm).

The Infrared remote control example uses the following component:

  • TSOP38238 (Farnell 2251359)

The following hardware is used in the remaining sections to expand the available inputs/outputs, avoid obstacles, and determine the direction of the robot:

  • MCP23017 I/O Expander (Ciseco SKU: K002)
  • Micro switches
  • HC-SR04 Ultrasonic sensor (DealExtreme SKU: 133696)
  • The ultrasonic sensor uses a 2K ohm resistor and a 3K ohm resistor
  • XLoBorg: MAG3110 Compass Module (PiBorg XLoBorg)

Optionally, four Female-to-Male Dupont wires can be used to connect to the XLoBorg (Pimoroni Jumper Jerky)

Chapter 13

This chapter uses the following hardware:

  • Remote-controlled mains sockets (Maplin/Amazon)
  • Relay modules (Banggood 8-Way SKU075676)
  • The alternative is to use the 433Mhz RF Transmitter/Receiver (Banggood SKU075671)
  • LED 8x8 SPI Matrix Module MAX7219 (Banggood self-solder kit SKU072955)
  • RS-232 to USB Cable (Amazon/general computer supplies)
  • RS-232 null-modem cable/adaptor (Amazon/general computer supplies)
  • RS-232 TTL USB console cable (Adafruit ID: 70)
  • HC-05 Bluetooth master/slave module with PCB backplate (Banggood SKU078642)
  • USB Tenx Technology SAM missile launcher
  • OWI robotic arm with USB interface (Maplin/Amazon)

Chapter 14

No additional hardware has been used in this chapter, as they discuss purely software recipes.