Red Pitaya CPU temperature/voltage in Terminal
For the Aug 2017 eclipse measurements in South Carolina, despite the fans installed on each Red Pitaya, it was important to keep track of CPU temperature and voltage as each PiRadar node was unattended.
Shell script: monitor Red Pitaya CPU temperature: get_temperature.sh
#!/bin/sh
#
# based on www.kkn.net/~n6tv/xadc.sh
#
# works in Ash (Red Pitaya ecosystem 0.95) and Bash (ecosystem 0.97)
# path to IIO device
XADC_PATH=/sys/bus/iio/devices/iio:device0
# Note: used "cat" to work in Ash instead of the typically recommended Bash "<".
OFF=$(cat $XADC_PATH/in_temp0_offset)
RAW=$(cat $XADC_PATH/in_temp0_raw)
SCL=$(cat $XADC_PATH/in_temp0_scale)
FORMULA="(($OFF+$RAW)*$SCL)/1000.0"
VAL=$(echo "scale=2;${FORMULA}" | bc)
echo "in_temp0 = ${VAL} °C"
Shell script: monitor DC input voltage: get_voltage.sh
#!/bin/sh
# based on www.kkn.net/~n6tv/xadc.sh
#
# works in Ash (Red Pitaya ecosystem 0.95) and Bash (ecosystem 0.97)
# power supply voltages (predefined scaling)
# note that Ash doesn't have "array" so we use "set --"
# path to IIO device
XADC_PATH=/sys/bus/iio/devices/iio:device0
set -- "in_voltage0_vccint" \
"in_voltage1_vccaux" \
"in_voltage2_vccbram" \
"in_voltage3_vccpint" \
"in_voltage4_vccpaux" \
"in_voltage5_vccoddr" \
"in_voltage6_vrefp" \
"in_voltage7_vrefn"
for voltage do
RAW=$(cat ${XADC_PATH}/${voltage}_raw)
SCL=$(cat ${XADC_PATH}/${voltage}_scale)
FORMULA="(${RAW}*${SCL})/1000.0"
VAL=$(echo "scale=2;${FORMULA}" | bc)
echo "${voltage} = ${VAL} V"
done