Extract Power/mW or Power Consumption from jtop in Python?

Hello,

I’m curious if from running the command jtop in the command line (monitors and shows power for the jetson nano) I can extract the Power/mW through some sort of python script?

I also know there is the tegrastats command as well which would be useful but I’m still not too sure how to extract something from that command.

Again I would like to do this in python- ideally I want to save motion detection values in an excel file but also store Power consumption in that excel file as well. So far I have been able to store thermal temperature in the excel file using ‘/sys/class/----/----0/temp1_input’. Can I somehow get some kind of power consumption or that exact number from jtop of Power/mW?

Thanks!

Hi Boskicl, you can read the power consumption data from the sysfs INA nodes, which is how tegrastats and jtop obtain the information.

For more info, please refer to this section of the L4T documentation:

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fpower_management_nano.html%23wwpID0E0UE0HA

Thank you this helps and I’m able to get to something like ‘/sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/in_current0_input’ which prints out a value. For some reason in the script the value is not updating? It stays the same.

Im running this:

with open('/sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/in_current0_input') as t:
	current = ((t.read()))
	print(current)

With this terminal command, I see the contents of the same file updating:

$ watch cat /sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/in_current0_input

So I am not sure why in your Python script it is not. How frequently is it being queried, and does the file read position get reset after t.read()?

Hey Dusty, I fixed it. I put it in the wrong loop. Dumb mistake. Thank you so much!