pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Unit Weight

Example

Gets the Weight of the Unit Weight weighing

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

weigh_0 = unit.get(unit.WEIGHT, unit.PORTA)

while True:
  print(weigh_0.weight)
  wait(0.1)
  if btnA.isPressed():
    wait(0.1)
    weigh_0.zero()
  wait_ms(2)

API

print((str('weight:') + str((weigh_0.weight))))
  • Read the raw weight value from the HX711
print((str('raw data:') + str((weigh_0.rawData))))
  • Obtain the scaled weight value based on calibration
weigh_0.set_calibrate_scale(200)
  • Calibrate the scale using a known weight
weigh_0.zero()
  • Set the tare weight to zero out the scale
On This Page