Subscribe to Arduino Academy and start learning today for FREE!

Arduino UPS / Battery Shield

We just picked up a LIPO shield from Adafruit, which allows us to battery power our projects.

The shield contains a optional 2Ah LIPO battery, and recharges from a mini usb cable (same as a Kindle).

You can power your project from the shield on battery power, or plug in the cable, and it charges the battery and acts like a online UPS, powering your project. LED’s show power on, charging, charged, and low battery status, and you can monitor battery voltage on one of your analog pins.

Become the Maker you were born to be. Try Arduino Academy for FREE!

All we had to install was the extended headers, and the optional power switch (finally, you can power off the arduino). Stack the shield, plug in the battery and a usb cable for charging when necessary, and you are set to go.

We used a Ada Fruit RGB I2C LCD Shield
Make sure you download the Adafruit Libraries for the LCD.

// set up the voltage monitor
// select the input pin for the battery voltage. 
//Make sure you solder the correct pad on the bottom 
//of the power boost shield.
int sensorPin = A2;    
// variable to store the value coming from the battery
int sensorValue = 0;

//measure your AREF pin and replace our 
//measured value of 4.77v
float stepVolt = 4.77/1024.0;

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can’t use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

void setup() {
// Debugging output
//Serial.begin(9600);
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
lcd.setBacklight(YELLOW);
lcd.setCursor(0,0);
lcd.print(“Battery Voltage”);
}

void loop() {
sensorValue = analogRead(sensorPin);
lcd.setCursor(0,1);
lcd.print(sensorValue*stepVolt);
delay(5000);
}

Become the Maker you were born to be. Try Arduino Academy for FREE!

 

 

Subscribe
Notify of
guest
3 Comments
Inline Feedbacks
View all comments
JB
JB
2 years ago

Is there a way for the Arduino tell if it is running on battery vs external power?

aaa
aaa
4 years ago

What pin did you solder on to the powerboost shield?

Steve Spence
4 years ago

If you look at the code, I used A2, but you can choose whichever of the analog inputs you want. Just make sure code and solder bridge match.

Archives

3
0
Would love your thoughts, please comment.x
()
x