Book Image

Learning Beaglebone Python Programming

Book Image

Learning Beaglebone Python Programming

Overview of this book

Table of Contents (19 chapters)


The BeagleBone Black is a powerful system that can be used in a huge number of cool projects and is a great platform to learn about embedded systems and embedded Linux, but it can be difficult for beginners to find the resources they need to get started with it. The goal of this book is to use the Python programming language to introduce you to many of the different hardware interfaces available on the BeagleBone Black, and to teach you how to use them to communicate with external hardware with the help of the PyBBIO and Adafruit_BBIO Python libraries. This book will take you through the system, from initial setup to creating complete programs, and each new concept along the way is introduced with practical and contextual examples.

What this book covers

Chapter 1, Before We Begin, introduces you to the BeagleBone Black and to each of its hardware interfaces that are used throughout the book.

Chapter 2, Getting Started, takes you through the initial steps to get your BeagleBone Black setup and ready to use, and briefly introduces you to the PyBBIO and Adafruit_BBIO Python libraries.

Chapter 3, Digital Outputs, goes more in depth into using the GPIO modules to generate digital outputs, and guides you through your first hardware interface programs to blink some LEDs.

Chapter 4, PWM and ADC Subsystems, describes in more detail the pulse width modulation and analog-to-digital converter subsystems, and guides you through using them to fade LEDs, control servo motors, measure light levels, and more. It also introduces some basic concepts for analog signal conditioning.

Chapter 5, User Input, presents some methods of using external hardware to interface with your BeagleBone programs, including potentiometers, buttons, and rotary encoders.

Chapter 6, Program Output, covers some methods of using external hardware to provide feedback to the user, from LED and LCD displays to sending e-mails and text messages.

Chapter 7, Serial Communication, describes in more depth the UART, I2C, and SPI serial subsystems and how they can be used to communicate with external digital devices.

Chapter 8, Interfacing with External Devices, walks you through the steps required to interface with a new digital device by writing a Python module to communicate with an accelerometer over I2C.

Chapter 9, Using the Network, shows you some ways of taking advantage of the BeagleBone Black's network connection to remotely control and monitor your applications.

Chapter 10, A Practical Example, walks you through using what you've learned to build a BeagleBone Black weather station with remote monitoring and automatic over/under temperature e-mail or text message alarms.

Appendix A, The BeagleBone Black Pinout, provides you with a visual description of the BeagleBone Black's expansion headers and the different ways each pin can be used.

Appendix B, Disabling HDMI, teaches you to disable the HDMI output.

What you need for this book

This book specifically targets the BeagleBone Black. It also assumes a Windows OS where setup steps are required to be run on a desktop or laptop PC, as in my experience Windows has been the main OS of folks who are just starting out with BeagleBone.

Who this book is for

If you are a Python programmer and have never had any experience with embedded Linux and hardware development, this book is for you. Some previous Linux experience will be helpful, but is not required.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, folder names, filenames, file extensions, pathnames, and user input are shown as follows: "This will open the crontab file in nano, which is a command line text editor."

A block of code is set as follows:

def loop():
    print "switch state:", digitalRead(SW_PIN)
run(setup, loop)

Any command-line input or output is written as follows:

root@beaglebone:/var/lib/cloud9# ping -c 3
PING ( 56(84) bytes of data.

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Select Obtain IP address automatically and click on OK."


Warnings or important notes appear in a box like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.


Image Disclaimer

This book includes images of breadboard wiring which were generated using Fritzing (, and schematics generated using Eagle ( It also includes some screen captures of a Rigol oscilloscope.