UIFlow Guide
Measure current and voltage
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit
setScreenColor(0x000000)
ac_measure_0 = unit.get(unit.AC_MEASURE, unit.PORTA)
isdata = None
ac_measure_0.init_i2c_address(0x42)
print((str('FW VER:') + str((ac_measure_0.get_device_status(0xFE)))))
while True:
isdata = ac_measure_0.get_data_ready()
if isdata:
print((str('VOLTAGE:') + str((ac_measure_0.get_voltage_str()))))
print((str('CURRENT:') + str((ac_measure_0.get_current_str()))))
print((str('POWER:') + str((ac_measure_0.get_active_power_str()))))
print((str('KW/H') + str((ac_measure_0.get_kwh_str()))))
wait(1)
wait_ms(2)
ac_measure_0.init_i2c_address(0x42)
print((str('ready:') + str((ac_measure_0.get_data_ready()))))
print((str('active power:') + str((ac_measure_0.get_active_power_str()))))
print((str('active power raw:') + str((ac_measure_0.get_active_power_byte()))))
print((str('apparent power:') + str((ac_measure_0.get_apparent_power_str()))))
print((str('apparent power raw:') + str((ac_measure_0.get_apparent_power_byte()))))
print((str('current:') + str((ac_measure_0.get_current_str()))))
print((str('current coefficient:') + str((ac_measure_0.get_current_coeff()))))
print((str('current raw:') + str((ac_measure_0.get_current_byte()))))
print((str('firmware:') + str((ac_measure_0.get_device_status(0xFE)))))
print((str('kw:') + str((ac_measure_0.get_kwh_str()))))
print((str('kw raw:') + str((ac_measure_0.get_kwh_byte()))))
print((str('power factor:') + str((ac_measure_0.get_power_factor_str()))))
print((str('power factor raw:') + str((ac_measure_0.get_power_factor_byte()))))
print((str('voltage:') + str((ac_measure_0.get_voltage_str()))))
print((str('voltage coefficient:') + str((ac_measure_0.get_voltage_coeff()))))
print((str('voltage raw:') + str((ac_measure_0.get_voltage_byte()))))
ac_measure_0.set_current_coeff(100)
ac_measure_0.set_i2c_address(0x42)
ac_measure_0.set_save_coeff()
ac_measure_0.set_voltage_coeff(100)