"Hack" a laptop battery, see what's going on in its head. Send commands to reset and change values, read the voltage, temperature, charge rate, anything the controller can report. And more. With the awesome flexibility of
phi_prompt, this little program has a nice menu-based UI that scales to whatever type of LCD you happen to have (I can only imagine how it looks on 20x4)! Plus, if you have a battery whose controller isn't supported yet (I only have bq2040 support embedded, but it's pretty easy to add a whole new command library that you can select from the menus).
Menus:
- Setup
- Test SMBus - checks for proper connection and response from the selected address
- Scan SMBus - scans all usable SMBus addresses and displays the devices that respond to their address
- Enter Address - directly enter a binary address to contact on SMBus for all functions
- Command Set - change the command set that's used for built-in functions in Read Info and Single Command (only one is included, for the bq2040, but more can be easily added)
- Read Info
- Battery ID - displays manufacturer, model, chemistry info
- Charge Data - displayes voltage, amps, percent charge, and temperature twice a second
- Statistics - Manufacturing date and cycle count
- Control
- Single Command - displays a full, labeled list of all known commands within the command set - select one, and it'll show you the formatted result (volts, amps, percent, string, hex, etc).
- Write Word - modify a value on the battery's controller, if it can be modified. Many parameters, like the serial number, cycle count, max charge, etc., can be written by referencing the chip's datasheet. Most changes are temporary, but should last long enough to put it back into a PC and see your changed values (like modifying the string "Dell" into "Hell" for kicks).
- Read Word - reads a raw hex value from the controller.
- Read Block - reads a text string onto the display, if it's a proper block value.
The code is pretty huge, compiles to 19450 bytes (obviously only compatible with 328p's). Strings for the commands account for about 580 bytes of it, the rest is pretty much code and libraries.
It makes use of the
phi_prompt library by liudr (primarily), as well as
I2C Master to more accurately harness the power of the ATMega's TWI interface to emulate SMBus instead of true I2C (repeated starts, commands, etc). It works a treat!
Configure your LCD and button arrangement by reading over the top of the file (all neatly consolidated for semi-readability), then upload away!
Planning on doing some kinda video soon with this thing, but meanwhile, here are some teaser pics.


And the code is attached!

edit: Ugh, it's amazing how much trouble a "<" where a "<=" should go can cause. Quick fix for selecting command set. =P
edit: Updated with histogram on charge data.