DESK-XZU-L/Peripherals/Power meter

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2026/06/25 DESK-XZU-L 2.x.x release



Peripheral Power meter[edit | edit source]

BORA Xpress EVBs has a INA226 device connected to the I2C bus. The following commands can be saved as a shell script (e.g. read_power_values.sh) and run to collect the measurements data:

root@onda:~# vim read_power_values.sh
#!/bin/sh

path_dev=/sys/devices/platform/axi/ff020000.i2c/i2c-0/0-0041/iio:device1

IN_VOLT0_RAW=$(cat "$path_dev/in_voltage0_raw")
IN_VOLT0_SCALE=$(cat "$path_dev/in_voltage0_scale")
IN_VOLT1_RAW=$(cat "$path_dev/in_voltage1_raw")
IN_VOLT1_SCALE=$(cat "$path_dev/in_voltage1_scale")
IN_VOLT0=$(echo "$IN_VOLT0_RAW*$IN_VOLT0_SCALE" | bc)
IN_VOLT1=$(echo "$IN_VOLT1_RAW*$IN_VOLT1_SCALE" | bc)
VOLTAGE=`awk "BEGIN {print ($IN_VOLT1-$IN_VOLT0)/1000}"`

IN_CURRENT3_RAW=`cat $path_dev/in_current3_raw`
IN_CURRENT3_SCALE=`cat $path_dev/in_current3_scale`
CURRENT=`awk "BEGIN {print ($IN_CURRENT3_RAW*$IN_CURRENT3_SCALE)/1000}"`

IN_POWER2_RAW=`cat $path_dev/in_power2_raw`
IN_POWER2_SCALE=`cat $path_dev/in_power2_scale`
POWER=`awk "BEGIN {print ($IN_POWER2_RAW*$IN_POWER2_SCALE)/1000}"`

echo "Voltage: ${VOLTAGE}, Current: ${CURRENT}, Power: ${POWER}"
root@onda:~# chmod u+x read_power_values.sh
root@onda:~# ./read_power_values.sh
Voltage: 3.28418, Current: 1.35225, Power: 4.425
root@onda:~#