I'm in the process of building a small wearable device (the be better bracelet) and I wanted it to be as small as possible. I originally powering the wearable with a coin cell battery, but realized pretty quickly that those batteries didn't have the required mAh for my project (which includes a haptic motor).
I needed a way to track battery life and current over time; I also wanted a way to easily trigger or record "events" (an action taken to take the project out of sleep). I didn't want to spend a lot of money on tools, so I looked into building something leveraging one of the 20+ un-used Adafruit Feathers (and FeatherWing accessories) in my electronics toolbox.
I knew that Adafruit had a INA219 current sensor FeatherWing... so I wired that to an Cortex M0 (with an ATWINC1500) feather and a TFT device. This allows me to see updates on the screen, send readings to Adafruit IO, and record data to an SD card.
I wanted something easily portable and extendable, so I:
- added a small Lipo battery to the logging device
- printed an enclosed case
- added an on/off rocker switch
- added two 2.1mm female panel mounts: input for a battery or other power input and an output to the device I'm measuring
- two banana clip female panel mounts - to either "trigger" an event (e.g. sends a HIGH output to simulate a button push) or to track an incoming event (I manually pushed a button on the wearable)
Sure, I'll be posting my code. I don't do anything special for creating a header row... when I start the program, it creates the file (or removes it, if it already exists), then I write a line for the columns.
File dataFile = SD.open(datafile, FILE_WRITE);
String dataString = "date, bus voltage, shunt voltage, current (mA), load voltage, power";
// if the file is available, write to it:
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
}