Datasheet

the battery needs recharging. Lipoly batteries are 'maxed out' at 4.2V and stick around 3.7V for much of the battery
life, then slowly sink down to 3.2V or so before the protection circuitry cuts it off. By measuring the voltage you can
quickly tell when you're heading below 3.7V
To make this easy we stuck a double-100K resistor divider on the BAT pin, and connected it to D9 (a.k.a analog #7
A7). You can read this pin's voltage, then double it, to get the battery voltage.
#define VBATPIN A7
float measuredvbat = analogRead(VBATPIN);
measuredvbat *= 2; // we divided by 2, so multiply back
measuredvbat *= 3.3; // Multiply by 3.3V, our reference voltage
measuredvbat /= 1024; // convert to voltage
Serial.print("VBat: " ); Serial.println(measuredvbat);
This voltage will 'float' at 4.2V when no battery is plugged in, due to the lipoly charger output, so its not a good way
to detect if a battery is plugged in or not (there is no simple way to detect if a battery is plugged in)
Average Power Draw w/SD Card
The average power draw of the ATSAMD21 + regulator circuitry is 11mA. Both the red and green LED each draw
1mA if you light them up.
Say you are running this sample sketch which logs the analog voltage on A0 to an SD card file once a second.
#include <SPI.h>
#include <SD.h>
// Set the pins used
#define cardSelect 4
File logfile;
// blink out an error code
void error(uint8_t errno) {
while(1) {
uint8_t i;
© Adafruit Industries https://learn.adafruit.com/adafruit-feather-m0-adalogger Page 23 of 47