I built a battery monitoring system using a picaxe and an lcd. It monitors battery voltage, charge current, discharge current, remaining battery capacity, and status (charging, discharging, low battery and float). It dumps this info out the serial port at regular intervals. Will post the whole project after I get the final current sensors built, and test the thing for a few weeks.
In the meantime, here's a little bash script I cooked up which collects the data from the serial port, and writes it to a csv file for later spreadsheeting. The string from the picaxe already has the commas inserted, and looks like this;
12.84, -16.8, +0.0, 84, DisCharging
12.84, -16.8, +0.0, 84, DisCharging
12.82, -16.8, +0.0, 83, DisCharging
12.82, -0.0, +41.3, 83, Charging
12.84, -0.0, +41.3, 84, Charging
12.82, -0.0, +41.3, 84, Charging
The script adds a timestamp to each record, and the saved filename is date coded. It starts a new file every midnight.
Data in the csv file looks like this;
16:41:13, 12.84, -16.8, +0.0, 84, DisCharging
16:43:13, 12.84, -16.8, +0.0, 84, DisCharging
16:45:13, 12.82, -16.8, +0.0, 83, DisCharging
16:47:13, 12.82, -0.0, +41.3, 83, Charging
16:49:13, 12.84, -0.0, +41.3, 84, Charging
16:51:13, 12.82, -0.0, +41.3, 84, Charging
And here's the script.
#!/bin/bash
stty -F /dev/ttyS0 ispeed 9600 ospeed 9600
stty -F /dev/ttyS0
NOWTIME=`date +%H:%M:%S`
NOWDATE=`date +%Y%m%d`
echo $NOWDATE $NOWTIME
while true
do
read LINE < /dev/ttyS0
NOWTIME=`date +%H:%M:%S`
NOWDATE=`date +%Y%m%d`
echo $NOWTIME"," $LINE
echo $NOWTIME"," $LINE >> $NOWDATE".csv"
done
Amanda