Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Getting Started with Python for the Internet of Things

You're reading from   Getting Started with Python for the Internet of Things Leverage the full potential of Python to prototype and build IoT projects using the Raspberry Pi

Arrow left icon
Product type Course
Published in Feb 2019
Publisher
ISBN-13 9781838555795
Length 732 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (5):
Arrow left icon
Tim Cox Tim Cox
Author Profile Icon Tim Cox
Tim Cox
Prof. Diwakar Vaish Prof. Diwakar Vaish
Author Profile Icon Prof. Diwakar Vaish
Prof. Diwakar Vaish
Sai Yamanoor Sai Yamanoor
Author Profile Icon Sai Yamanoor
Sai Yamanoor
Steven Lawrence Fernandes Steven Lawrence Fernandes
Author Profile Icon Steven Lawrence Fernandes
Steven Lawrence Fernandes
Srihari Yamanoor Srihari Yamanoor
Author Profile Icon Srihari Yamanoor
Srihari Yamanoor
+1 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (37) Chapters Close

Title Page
Copyright and Credits
About Packt
Contributors
Preface
1. Getting Started with a Raspberry Pi 3 Computer FREE CHAPTER 2. Dividing Text Data and Building Text Classifiers 3. Using Python for Automation and Productivity 4. Predicting Sentiments in Words 5. Detecting Edges and Contours in Images 6. Building Face Detector and Face Recognition Applications 7. Using Python to Drive Hardware 8. Sensing and Displaying Real-World Data 9. Building Neural Network Modules for Optical Character Recognition 10. Arithmetic Operations, Loops, and Blinky Lights 11. Conditional Statements, Functions, and Lists 12. Communication Interfaces 13. Data Types and Object-Oriented Programming in Python 14. File I/O and Python Utilities 15. Requests and Web Frameworks 16. Awesome Things You Could Develop Using Python 17. Robotics 101 18. Using GPIOs as Input 19. Making a Gardener Robot 20. Basics of Motors 21. Bluetooth-Controlled Robotic Car 22. Sensor Interface for Obstacle Avoidance 23. Making Your Own Area Scanner 24. Basic Switching 25. Recognizing Humans with Jarvis 26. Making Jarvis IoT Enabled 27. Giving Voice to Jarvis 28. Gesture Recognition 29. Machine Learning 30. Making a Robotic Arm 1. Other Books You May Enjoy Index

Connecting to Raspberry Pi


There are many ways to wire up Raspberry Pi and use the various interfaces to view and control content. For typical use, most users will require power, display (with audio), and a method of input such as a keyboard and mouse. To access the internet, refer to the Networking and connecting your Raspberry Pi to the internet via the LAN connector or Using built-in Wi-Fi and Bluetooth on Raspberry Pi recipes.

Getting ready

Before you can use your Raspberry Pi, you will need an SD card with an operating system installed or with the New Out Of Box System (NOOBS) on it, as discussed in the Using NOOBS to set up your Raspberry Pi SD card recipe.

The following section will detail the types of devices you can connect to Raspberry Pi and, importantly, how and where to plug them in.

As you will discover later, once you have your Raspberry Pi set up, you may decide to connect remotely and use it through a network link, in which case you only need power and a network connection. Refer to the following sections: Connecting remotely to Raspberry Pi over the Network using VNC and Connecting Remotely to Raspberry Pi over the Network using SSH (and X11 Forwarding).

How to do it...

The layout of Raspberry Pi is shown in the following diagram:

The Raspberry Pi connection layout (Model 3 B, Model A+, and Pi Zero)

More information about the preceding figure is listed as follows:

  • Display: The Raspberry Pi supports the following three main display connections; if both HDMI and composite video are connected, it will default to HDMI only:
    • HDMI: For best results, use a TV or monitor that has an HDMI connection, thus allowing the best resolution display (1080p) and also digital audio output. If your display has a DVI connection, you may be able to use an adapter to connect through the HDMI. There are several types of DVI connection; some support analogue (DVI-A), some digital (DVI-D), and some both (DVI-I). Raspberry Pi is only able to provide a digital signal through the HDMI, so an HDMI-to-DVI-D adapter is recommended (shown with a tick mark in the following screenshot). This lacks the four extra analogue pins (shown with a cross mark in the following screenshot), thus allowing it to fit into both DVI-D and DVI-I type sockets:

HDMI-to-DVI connection (DVI-D adaptor)

If you wish to use an older monitor (with a VGA connection), an additional HDMI-to-VGA converter is required. Raspberry Pi also supports a rudimentary VGA adaptor (VGA Gert666 Adaptor), which is driven directly off of the GPIO pins. However, this does use up all but four pins of the 40-pin header (older 26-pin models will not support the VGA output):

HDMI-to-VGA adapter

    • Analogue: An alternative display method is to use the analogue composite video connection (via the phono socket); this can also be attached to an S-Video or European SCART adapter. However, the analogue video output has a maximum resolution of 640 x 480 pixels, so it is not ideal for general use:

3.5 mm phono analogue connections

When using the RCA connection or a DVI input, audio has to be provided separately by the analogue audio connection. To simplify the manufacturing process (by avoiding through-hole components), the Pi Zero does not have analogue audio or an RCA socket for analogue video (although they can be added with some modifications):

    • Direct Display DSI: A touch display produced by Raspberry Pi Foundation will connect directly into the DSI socket. This can be connected and used at the same time as the HDMI or analogue video output to create a dual display setup.
  • Stereo analogue audio (all except Pi Zero): This provides an analogue audio output for headphones or amplified speakers. The audio can be switched via Raspberry Pi configuration tool on the desktop between analog (stereo socket) and digital (HDMI), or via the command line using amixer or alsamixer.

Note

To find out more information about a particular command in the Terminal, you can use the following man command before the terminal reads the manual (most commands should have one):

 

 man amixer

Some commands also support the --help option for more concise help, shown as follows:

 amixer --help

  • Network (excluding models A and Pi Zero): The network connection is discussed in the Networking and connecting your Raspberry Pi to the internet via the LAN connector recipe later in this chapter. If we use the Model A Raspberry Pi, it is possible to add a USB network adapter to add wired or even wireless networking (refer to the Networking and connecting your Raspberry Pi to the internet via a USB Wi-Fi dongle recipe).
  • Onboard Wi-Fi and Bluetooth (Model 3 B only): The Model 3 B has built-in 802.11n Wi-Fi and Bluetooth 4.1; see the Using the built-in Wi-Fi and Bluetooth on Raspberry Pi recipe.
  • USB (1x Model A/Zero, 2x Model 1 B, 4x Model 2 B and 3 B): Using a keyboard and mouse:
    • Raspberry Pi should work with most USB keyboards and mice. You can also use wireless mice and keyboards, which use RF dongles. However, additional configuration is required for items that use the Bluetooth dongles.
    • If there is a lack of power supplied by your power supply or the devices are drawing too much current, you may experience the keyboard keys appearing to stick, and, in severe cases, corruption of the SD card.

Note

USB power can be more of an issue with the early Model B revision 1 boards that were available prior to October 2012. They included additional Polyfuses on the USB output and tripped if an excess of 140 mA was drawn. The Polyfuses can take several hours or days to recover completely, thus causing unpredictable behavior to remain even when the power is improved.

 

You can identify a revision 1 board, as it lacks the four mounting holes that are present in the later models.

    • Debian Linux (upon which Raspbian is based) supports many common USB devices, such as flash storage drives, hard-disk drives (external power may be required), cameras, printers, Bluetooth, and Wi-Fi adapters. Some devices will be detected automatically, while others will require drivers to be installed.
  • Micro USB power: The Raspberry Pi requires a 5V power supply that can comfortably supply at least 1,000 mA (1,500 mA or more is recommended, particularly with the more power-hungry Model 2 and Model 3) with a micro USB connection. It is possible to power the unit using portable battery packs, such as the ones suitable for powering or recharging tablets. Again, ensure that they can supply 5V at 1,000 mA or over.

You should aim to make all other connections to Raspberry Pi before connecting the power. However, USB devices, audio, and networks may be connected and removed while it is running, without problems.

There's more...

In addition to the standard primary connections you would expect to see on a computer, Raspberry Pi also has a number of other connections.

Secondary hardware connections

Each of the following connections provides additional interfaces for Raspberry Pi:

  • 20 x 2 GPIO pin header (Model A+, B+, 2 B, 3 B, and Pi Zero): This is the main 40-pin GPIO header of Raspberry Pi used for interfacing directly with hardware components. The chapters in this book are also compatible with older models of Raspberry Pi that have a 13 x 2 GPIO pin header.
  • P5 8 x 2 GPIO pin header (Model 1 B revision 2.0 only): We do not use this in the book.
  • Reset connection: This is present on later models (no pins fitted). A reset is triggered when Pin 1 (reset) and Pin 2 (GND) are connected together. We use this in the A controlled shutdown button concept in Chapter 7, Using Python to Drive Hardware.
  • GPU/LAN JTAG: The Joint Test Action Group (JTAG) is a programming and debugging interface used to configure and test processors. These are present on newer models as surface pads. A specialist JTAG device is required to use this interface. We do not use this in the book.
  • Direct camera CSI: This connection supports Raspberry Pi Camera Module. Note that the Pi Zero has a smaller CSI connector than the other models, so it requires a different ribbon connector.
  • Direct Display DSI: This connection supports a directly connected display, such as a 7-inch 800 x 600 capacitive touch screen.
You have been reading a chapter from
Getting Started with Python for the Internet of Things
Published in: Feb 2019
Publisher:
ISBN-13: 9781838555795
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image