Read Battery Voltage Script on ODROID-C0

This script read the voltage of battery from ADC channel 0.
Save the following code as readbatvol.sh in home directory.

#!/bin/sh
#
# Read Battery Voltage on ODROID-C0
#

ADCRES=0.004106
ADCVAL=$(cat /sys/class/saradc/saradc_ch0)
BATTVOL=$(echo $ADCRES*$ADCVAL | bc)
echo Battery voltage is $BATTVOL V

Please change the script permissions to execute with chmod.

sudo chmod a+x readbatvol.sh

Execute the script to read battery voltage.

./readbatvol.sh
en/c0_read_battery_voltage.txt · Last modified: 2016/04/04 18:33 by ruppi
CC Attribution-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0