Home>Posts>I/O Embedded & IoT, I/O HUB>How to Unleash Your BeagleBone: Battery Powering

How to Unleash Your BeagleBone: Battery Powering

By ·Categories: I/O Embedded & IoT, I/O HUB·Published On: August 12th, 2014·6.1 min read·

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


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.

369-00 USB5V

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

BeagleBone Black in Case with LED

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).


Create the file myprog.py

nano myprog.py

Enter the following program.

# Author : David St-Pierre   Aug 1, 2014
import Adafruit_BBIO.GPIO as GPIO
from time import sleep
toggle = 0
BUTTON = "P8_26"
LED_YEL = "P9_16"
#--------------GPIO SETUP------------------
#-------------WAIT TO START----------------
print("Press the button when you are ready to start")
while(GPIO.input(BUTTON) == 1):
print("Will begin in 10 seconds\nPress the button again to stop reading")
#---------------CONTINOUS LOOP TO READ SENSOR------------------
#---------------BLINK LED----------------------
   toggle = 0
   toggle = 1
#--------------INCLUDE YOUR TASK HERE -------------
#--------------EXIT ON BUTTON PRESS--------------
  if(GPIO.input(BUTTON) == 0):
   print("Button pressed \nExiting Program")

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

nano myboot.sh

Enter the following text.

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.


About the Author: Richard St-Pierre

Richard worked as the Senior Electrical Engineer at Logic Supply before relocating with his family in 2015. A general problem solver and well-known "Lab MacGyver", Richard is always on the lookout for creative approaches to design solutions and continues to explore new opportunities to build creative solutions to common challenges.
Follow OnLogic on LinkedIn

One Comment

  1. Ajeet kumar March 14, 2018 at 6:14 am

    Can i use both option at a time to power the Beaglebone board i.e. USB as well as Power adapter. Because i want to use USB only as a mass storage and for other communication (Ethernet,RS 232 etc) i want to use power adapter for power up the board.
    Please advice

Leave A Comment


Have a project? Let's talk

More Articles


Learn the 5 ways Fanless Computers can help your business

Get the Whitepaper
View All Articles

OnLogic Industrial Computers

Discover OnLogic's multitude of industrial computers that will help you to advance your IoT project

Shop OnLogic

Learn more at OnLogic.com

OnLogic Industrial PCs: Designed to last. Built to order. Delivered in days. Visit our online store at OnLogic.com