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