So, you’ve been tinkering with the BeagleBone Black for a while now and you’ve gotten comfortable with the basics. You may have already expanded the file system, installed WiFi or even looked into getting your BeagleBone ready for a more industrial project. Now you’re on the lookout for new projects and you’d like to take your BeagleBone out of the workshop. But there’s a problem: as versatile and capable as the BBB is, it relies on a constant source of power.

The solution? Freeing your BeagleBone from the leash of it’s USB or power cable. This tutorial will walk you through the steps in battery powering your BeagleBone so you can take your next project on the road.

Special thanks to contributing author: David St-Pierre

What You Will Need

Introduction

In order to have the best battery life, we need a high efficiency voltage regulator. A switching regulator that can deliver 5 volts at 1 ampere or more is ideal. We also want this project to be easy to build. LiPo cells would be nice but “AA” are more readily available.

The BeagleBone will be running ‘head-less’ with no keyboard or display. We could connect with a wireless link (which would also requires more power), but this may not always be practical (ex: while riding a bicycle, motorcycle or driving a car) – Always use care when using a moving vehicle. A simpler approach is to use a basic push-button to start the BeagleBone program, and request an orderly shutdown and an LED to display status.

Step 1 – Wiring The Circuit

There are two basic ways to power the BeagleBone. You can apply a regulated 5V to the barrel jack, or provide power over the USB cable. Use which ever method is more convenient for you.

I chose to provide the power using the USB cable approach. This makes it easy to plug-in the USB cable provided with the BeagleBone. There are also many USB DC power options available on the market (including automotive auxiliary power 12V outlet adapters!).

Switching Voltage Regulator

Wiring Connections:

Battery(+) to Voltage Regulator Input

Battery(-) to Voltage Regulator Ground

Regulator Output to BeagleBone +5V

Regulator Ground to BeagleBone Ground

Note: The author mounted the voltage regulator in an ‘Altoid’ (candy mint tin) container.

Step 2 – Circuit Verification

[CAUTION] Test the power circuit *carefully* before connecting to the BeagleBone. Make sure the output voltage reads 5.0V and verify that the polarity (+/- ) is correct.

Power up with the battery circuit to the BeagleBone and SSH (putty) and verify that the system is working.

Step 3 – Adding Push Button And LED

We will use the push-button switch to signal that we want our program to start some measurement or task. The LED will provide useful status information. This will allow very simple two-way communication. Alternately, we could use the ‘USR’ LEDs on the BeagleBone. An external LED is more visible.

Push Button Connection

PushButton Switch pin 1 to BeagleBone (P8-26)

PushButton Switch pin 2 to Resistor (330 Ohms) and then to BeagleBone (P8-45)Ground

LED Connection

LED Anode(+) to BeagleBone (P9-14)

LED Cathode(-)to Resistor (330 Ohms) and then to BeagleBone (P9-1) Ground

The switch assembly in the photo is an OMRON A3DT-7111 with an OMRON A3DT-500GY LED.

Step 4 – Starting A Program, Measuring And Shutting Down

We need to know the status of the BeagleBone at many stages.

First the LED can tell us if the BeagleBone has completed booting up. This can be done by blinking the LED. This tells us that our program has started and we can start to make measurements or begin some control task. This is where the push-button can be used to signal that we are ready to go. Once the program has started its task, we change the LED to solid or change the flashing rate. When we are all done and want to power-off, we can press the push-button to request an orderly shutdown to begin.

Let’s look at this control in steps.

Create a (python) program task to run (example provided).

Download myprog.py File (and save it without the txt extension).

or

Create the file myprog.py

nano myprog.py

Enter the following program.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 #!/bin/python #------------------------------------------ # Author : David St-Pierre Aug 1, 2014 #--------------IMPORTS--------------------- import Adafruit_BBIO.GPIO as GPIO from time import sleep #--------------VARIABLES------------------- toggle = 0 BUTTON = "P8_26" LED_YEL = "P9_16" #--------------GPIO SETUP------------------ GPIO.setup(LED_YEL,GPIO.OUT) GPIO.setup(BUTTON, GPIO.IN) #-------------WAIT TO START---------------- print( "Press the button when you are ready to start" ) while (GPIO.input(BUTTON) == 1): GPIO.output(LED_YEL, GPIO.HIGH) sleep(1) GPIO.output(LED_YEL, GPIO.LOW) sleep(1) #--------------START----------------------- print( "Will begin in 10 seconds

Press the button again to stop reading" ) GPIO.output(LED_YEL,GPIO.HIGH) sleep(10) GPIO.output(LED_YEL,GPIO.LOW) sleep(1) #---------------CONTINOUS LOOP TO READ SENSOR------------------ while (True): #---------------BLINK LED---------------------- if (toggle): GPIO.output(LED_YEL,GPIO.LOW) toggle = 0 else : GPIO.output(LED_YEL,GPIO.HIGH) toggle = 1 #--------------INCLUDE YOUR TASK HERE ------------- sleep(2) #--------------EXIT ON BUTTON PRESS-------------- if (GPIO.input(BUTTON) == 0): print( "Button pressed

Exiting Program" ) exit()

Create a script file that will be called at Boot-up.

nano myboot.sh

Enter the following text.

#!/bin/bash python /root/home/myprog.py sudo shutdown -h now

Save and exit {ctrl+o, enter, ctrl+x}.

Note the full path name of ‘myprog.sh’ must be specified.

Make the script executable.

chmod a+x myboot.sh

Finally let’s create a cron job that will execute at boot-up.

crontab -e

And add the following:

@reboot /root/home/myboot.sh

Process Review

Once power is applied, the BeagleBone starts to boot. As part of the completion of the boot process the cron job starts (@reboot) and calls the script that we have created. The script in turn calls our task program.

The python task program starts flashing the LED to indicate that boot is complete and our program has started to execute. The program then looks for a signal from the push-button switch. This allows time for the user to set-up the environment or measurement conditions.

A button press, starts the active portion of the program (what you want to do). The LED state is changed to acknowledge and indicate this new state. After a period of time, you can end the task by pressing the button once more. The task now exits and returns to the script that started the measurement or control cycle.

Next, the shutdown command is executed. This request provides an orderly close and powers down the BeagleBone. Time to review the data, and investigate the results collected by the BeagleBone.