Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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
Raspberry Pi cookbook for Python programmers

You're reading from   Raspberry Pi cookbook for Python programmers The Raspberry Pi Cookbook has over 50 tailor-made recipes for programmers to get the most out of Raspberry Pi using Python to unleash its huge potential.

Arrow left icon
Product type Paperback
Published in Apr 2014
Publisher
ISBN-13 9781849696623
Length 402 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (18) Chapters Close

Raspberry Pi Cookbook for Python Programmers
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with a Raspberry Pi Computer FREE CHAPTER 2. Starting with Python Strings, Files, and Menus 3. Using Python for Automation and Productivity 4. Creating Games and Graphics 5. Creating 3D Graphics 6. Using Python to Drive Hardware 7. Sense and Display Real-world Data 8. Creating Projects with the Raspberry Pi Camera Module 9. Building Robots 10. Interfacing with Technology Hardware and Software List Index

Connecting the Raspberry Pi


There are many ways to wire up the 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 recipe.

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 the 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 the Raspberry Pi over the network using VNC and Connecting remotely to the Raspberry Pi over the network using SSH (and X11 Forwarding).

How to do it…

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

The Raspberry Pi connection layout (Model B revision 2.0)

The description of the preceding figure is explained as follows:

  • Display: The Raspberry Pi supports the following three main display connections; if both HDMI and Composite video are connected, it shall default to the 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 connections; some support analogue (DVI-A), some digital (DVI-D), and some both (DVI-I). the 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.

    • Analogue

      An alternative display method is to use the analogue composite video connection (via the RCA 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.

      When using the RCA connection or a DVI input, audio has to be provided separately by the analogue audio connection.

    • Direct Display DSI

      A touch display produced by the 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: This provides an analogue audio output for headphones or amplified speakers. The audio can be switched between analogue (Stereo Socket) and digital (HDMI) 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 (Model B Only): 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).

  • USB (x1 Model A, x2 Model B) – Using a keyboard and mouse:

    The Raspberry Pi should work with most USB keyboards and mice available. However, you may encounter issues if your device draws more than 140mA, in which case a powered USB hub is recommended. 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 140mA 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 two mounting holes that are present on the revision 2 board.

    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, which can comfortably supply at least 700mA (1A or more recommended) 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 700mA or over.

You should aim to make all other connections to the Raspberry Pi before connecting the power. However, USB devices, audio, and network 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, the Raspberry Pi also has a number of additional connections.

Secondary hardware connections

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

  • P1 13 x 2 GPIO pin header: This is the main GPIO header of the Raspberry Pi used for interfacing directly with hardware components. We use this connection in Chapter 6, Using Python to Drive Hardware, Chapter 7, Sense and Display Real World Data, Chapter 9, Building Robots, and Chapter 10, Interfacing with Technology.

  • P5 8 x 2 GPIO pin header: This is present on board revision 2.0 only (no pins fitted).

  • P6 reset: This is present on board revision 2.0 only (no pins fitted). A reset is triggered when P6-Pin1 (reset) and P6-Pin2 (GND) are connected together.

  • P5 and P6 pin header

    Tip

    We use P5 and P6 in the A controlled shutdown button recipe in Chapter 6, Using Python to Drive Hardware.

  • P2/P3 GPU/LAN JTAG: The Joint Test Action Group (JTAG) is a programming and debugging interface used to configure and test processors. A specialist JTAG device is required to use this interface.

  • S5 Direct Camera CSI: This connection supports the Raspberry Pi Camera module (as used in Chapter 8, Creating Projects with the Raspberry Pi Camera Module).

  • S2 Direct Display DSI: This connection is intended to support a display (an add-on released by the Raspberry Pi Foundation).

You have been reading a chapter from
Raspberry Pi cookbook for Python programmers
Published in: Apr 2014
Publisher:
ISBN-13: 9781849696623
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