modelKitchenScale

Kitchen scale: I2C screen, microcontroller, HX711, gauge bridge, load cell body, weight; tare button

Extends from Modelica.Icons.Example (Icon for runnable examples).

Information

A complete kitchen scale, from the mass placed on the pan to the display:

load + pan (masses) → g, weight (weight: a force) → loadCell (load cell body, which deforms) → bridge (gauges: the strain unbalances the bridge, 1 mV/V at full load) → hx (HX711: amplification × 128 and 24-bit conversion) → mcu (program kitchen_scale.py) → lcd (Grove LCD RGB screen, I2C bus).

The program uses two off-the-shelf MicroPython drivers, unmodified: hx711_gpio.py (robert-hh/hx711) and driver_grove_lcd_rgb.py. It tares at start-up (the 200 g pan becomes the zero), converts the HX711 points into grams with a calibration constant (429.497 points per gram) and shows the result to the nearest gram. Only the characters that change are sent to the screen: each one costs an I2C transaction. Pressing the TARE button (GP0, interrupt on falling edge) resets the display to zero, bowl included.

Scenario:

  • t = 0 to 1.1 s: start-up, tare of the empty pan ("Tare...");
  • t = 2 s: a 350 g bowl is placed → "350 g";
  • t = 3.5 s: TARE pressed → "Tare...", then "0 g" around 4.2 s;
  • t = 4.5 to 5.5 s: 250 g of flour are poured → the display rises up to "250 g".

To watch: the icon of lcd during the animated replay; hx.code (the raw points, noise included); mcu.GP6.v and mcu.GP7.v (the HX711 frames); mcu.GP4.v/mcu.GP5.v (the I2C bus, active only when the display changes).

Lab ideas: calibrate the scale (find 429.497 points per gram again from a known mass); tune the filter of the driver (set_time_constant) and observe the trade-off between stability and speed; increase hx.noiseLsb; set hx.rate to 80 samples per second.

Components

TypeNameDefaultDescription
MCUmcuscriptPath = Resources/Scripts/MCU/kitchen_scale.py - imports the drivers hx711_gpio.py and driver_grove_lcd_rgb.py placed next to it
MicroPythonMCU.Peripherals.I2cGroveLcdRgblcd16x2 screen with RGB backlight, carrying the pull-ups of the I2C bus
MicroPythonMCU.Peripherals.Weighing.Hx711hxConverter, with realistic noise (25 LSB, i.e. 0.06 g)
MicroPythonMCU.Peripherals.Weighing.WheatstoneBridgebridgeFour gauges bonded to the load cell body
MicroPythonMCU.Peripherals.Weighing.LoadCellloadCell5 kg load cell body
Modelica.Mechanics.Translational.Sources.ForceweightThe weight of what is on the pan (pan included)
Modelica.Blocks.Math.GaingWeight = mass × g
Modelica.Blocks.Math.AddtotalMassTotal mass on the load cell body
Modelica.Blocks.Sources.ConstantpanPan: 200 g, always present - the tare at start-up makes them disappear
Modelica.Blocks.Sources.TimeTableloadWhat is placed (kg): a 350 g bowl at t = 2 s, then 250 g of flour poured between 4.5 and 5.5 s
Modelica.Electrical.Analog.Sources.ConstantVoltagevcc3.3 V supply of the button pull-up
Modelica.Electrical.Analog.Basic.ResistorrPullPull-up resistor: button released, GP0 reads 1
Modelica.Electrical.Analog.Basic.VariableConductorbuttonTARE button: contact to ground (controlled conductance, no ideal switching)
Modelica.Blocks.Math.BooleanToRealcontactPressed: 0.1 Ω; released: 1 GΩ
Modelica.Blocks.Sources.BooleanTablepressTARE pressed from t = 3.5 s to 3.7 s, bowl in place
Modelica.Electrical.Analog.Basic.Groundground
Modelica.Electrical.Analog.Basic.GroundgroundBtn
Modelica.Electrical.Analog.Basic.GroundgroundLcd