The first step is to compile the kernel with TI INA* support. This can be as a module or built-in. I chose the module route so that I can check that the module loaded with the lsmod command. Here's a screenshot of the Linux menuconfig showing the option you need to enable:
Loading the Module and Setup
Once your system is back up and running, it's a simple matter of loading the module and doing some setup. You could put this setup stuff in a script that runs on startup.modprobe ina2xx
echo 'ina219 0x40' > /sys/bus/i2c/devices/i2c-2/new_device
I connected the I2C from the INA219 IC to the I2C3 (i2c-2, above) port of the Wandboard. I also powered the INA219 with 3.3 V, taken from the Wandboard external expansion headers.
Reading Power Values
Simply type:
cat /sys/bus/i2c/devices/2-0040/power1_input
And you will see a large number. Divide this number by 1000000 to get the power in Watts. You can also run sensors if you have lmsensors installed. Awesome!
No comments:
Post a Comment