The Arduino library can be downloaded from the github page here:
This project utilizes the ATmega328's internal 1.1V bandgap reference to allow for accurate measurements of external voltages. From these measurements the library is able to measure the external voltage, allowing users to choose what to do in undervoltage/overvoltage/overcurrent cases within their projects. External components are kept to an absolute minimum, requiring only the battery and a shunt resistor (which isn't needed if you don't care about current draw). It is worth noting that as the project stands right now for Arduino boards there is no way to prevent current from the USB programmer from going into the battery and causing problems. As a result, be sure to have the battery disconnected whenever programming. See the github page for some simple circuit guidelines for this library. This library is also capable of monitoring the battery while the Arduino is powered by a boost converter for those who need 5V instead of whatever the battery happens to be at.
For anyone curious about what's happening behind the scenes the battery voltage is calculated by:
where A terms represent the ADC value returned by reading the pin.
The current is found using the equation:
For anyone interested the full derivations are available in the logs of this project.
This project is still ongoing, and awaiting parts for thorough testing.