pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Unit Weight-I2C

Example

Unit Weight-I2C weight measurement

from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
weight_i2c_0 = unit.get(unit.WEIGHT_I2C, unit.PORTA)

weight_i2c_0.init_i2c_address(0x26)
while True:
  print(weight_i2c_0.get_weight_int)
  wait_ms(2)

功能说明

weight_i2c_0.init_i2c_address(0x26)
  • Initialization of Weighing Acquisition Transmitter Unit
print((str('value:') + str((weight_i2c_0.get_adc_raw))))
  • Get ADC (Analog-to-Digital Converter) Raw Value
print((str('filter:') + str((weight_i2c_0.get_average_filter_level))))
  • Get Average Filter Level
print((str('detail:') + str((weight_i2c_0.get_device_spec(0xFE)))))
  • Get Device Specification Information
print((str('filter:') + str((weight_i2c_0.get_ema_filter_alpha))))
  • Get EMA (Exponential Moving Average) Filter Alpha Value
print((str('filter:') + str((weight_i2c_0.get_lowpass_filter))))
  • Get Low-Pass Filter Settings
print((str('weight:') + str((weight_i2c_0.get_weight_float))))
  • Get Measured Weight Value as Float
print((str('weight:') + str((weight_i2c_0.get_weight_int))))
  • Get Measured Weight Value as Integer
print((str('weight:') + str((weight_i2c_0.get_weight_str))))
  • Get Measured Weight Value as Float
weight_i2c_0.set_reset_offset()
  • Get Measured Weight Value as Integer
weight_i2c_0.set_average_filter_level(0)
  • Set Average Filter Level
weight_i2c_0.set_calibration(0, 0, 100, 100)
  • Set Calibration Parameters
weight_i2c_0.set_ema_filter_alpha(0)
  • Set EMA Filter Alpha Value
weight_i2c_0.set_i2c_address(0x26)
  • Set I2C Address
weight_i2c_0.set_lowpass_filter(True)
  • Set Low-Pass Filter Parameters
On This Page