There is a simple Python API to read-out the data from the temperature and power sensors. This can be executed async from any other activity on the device.
#!/usr/bin/env python3
import time
from hailo_platform import Device
def _run_periodic(delay=1):
device_infos = Device.scan()
targets = [Device(di) for di in device_infos]
for i, target in enumerate(targets):
target.control.stop_power_measurement()
target.control.set_power_measurement()
target.control.start_power_measurement()
try:
while True:
for i, target in enumerate(targets):
time.sleep(delay)
power = target.control.get_power_measurement().average_value
temp = target.control.get_chip_temperature().ts0_temperature
print('[{}] {:.3f}W {:.3f}C'.format(device_infos[i], power, temp), end='\r')
except KeyboardInterrupt:
print('-I- Received keyboard intterupt, exiting')
for i, target in enumerate(targets):
target.control.stop_power_measurement()
if __name__ == "__main__":
_run_periodic()
Thanks Nadav, that is very helpful. I would also be interested in querying which temperature zone HAILO is in as well as the current clock frequency through the python interface. Is that possible?
It looks like my Current monitoring is set to Disabled. Is there any way to enable it or does this mean that my board is incompatible? I’m using the Raspberry Pi M2.2 board. I was hoping to measure power draw.
I support the question about the current monitoring being disabls on Hailo8l on RP5. I also have “Current Monitoring: Disabled”
I see the following output when attempt measuring power:
[HailoRT] [error] Firmware control has failed. Major status: 0x400300b4, Minor status: 0x400300b4
[HailoRT] [error] Firmware major status: CONTROL_PROTOCOL_STATUS_UNSUPPORTED_DEVICE
[HailoRT] [error] Firmware minor status: CONTROL_PROTOCOL_STATUS_UNSUPPORTED_DEVICE
[HailoRT] [error] Opcode HAILO_CONTROL_OPCODE_SET_POWER_MEASUEMENT is not supported on the current board.
The Raspberry PI Ai kit doesn’t have the INA component, and so it cannot measure the power drawn by the device. But, it still has the temperature sensor, and so you can measure the temperature of the chip periodically like this:
#!/usr/bin/env python3
import time
from hailo_platform import Device
def _run_periodic(delay=1):
target = Device()
try:
while True:
temp = target.control.get_chip_temperature().ts0_temperature
print(f'{temp:.2f} C', end='\r')
time.sleep(delay)
except KeyboardInterrupt:
print('-I- Received keyboard intterupt, exiting')
if __name__ == "__main__":
_run_periodic()
Thank you for the answer! I would suggest updating the corresponding User Guide. The guide mentions INA component, however, I do not remember the guide mentioning that AI KIT doesn’t have it.