pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Unit AIN4-20mA

Example

Measure the current of the circuit

from m5stack import *
from m5stack_ui import *
from uiflow import *
import unit

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
ain420ma_0 = unit.get(unit.AIN_420MA, unit.PORTA)

ain420ma_0.init_i2c_address(0x55)
while True:
  print((str('version:') + str((ain420ma_0.get_firmware_status()))))
  print((str('value:') + str((ain420ma_0.get_adc_raw16_value()))))
  print((str('current:') + str((ain420ma_0.get_ain_current_value()))))
  wait_ms(2)

API

ain420ma_0.init_i2c_address(0x55)
  • Initialization of 4~20mA input unit
print((str('value:') + str((ain420ma_0.get_adc_raw16_value()))))
  • Obtain ADC raw 16-bit value
print((str('current:') + str((ain420ma_0.get_ain_current_value()))))
  • Obtain current value (mA)
print((str('version:') + str((ain420ma_0.get_firmware_status()))))
  • Obtain firmware version number
ain420ma_0.set_i2c_address(0x55)
  • Set I2C communication address
On This Page