DMS load cell with measuring amplifier HX711AD: Unterschied zwischen den Versionen

Aus HSHL Mechatronik
Zur Navigation springen Zur Suche springen
Onyesi-john.abiagam@stud.hshl.de (Diskussion | Beiträge)
Onyesi-john.abiagam@stud.hshl.de (Diskussion | Beiträge)
 
(19 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 22: Zeile 22:
| 1 || The mass must be determined using the HX711AD load cell via Arduino and Simulink. || 1 ||  Done
| 1 || The mass must be determined using the HX711AD load cell via Arduino and Simulink. || 1 ||  Done
|-
|-
| 2 || The measuring range must be determined. || 1 || In Progress
| 2 || The measuring range must be determined. || 1 || Done
|-
|-
| 3 || The measurement uncertainty (1σ) must be determined for the measuring range and displayed as a confidence interval. || 2 || In Progress
| 3 || The measurement uncertainty (1σ) must be determined for the measuring range and displayed as a confidence interval. || 2 || Done
|-
|-
| 4 || The <code>on/off</code> button starts the system. The sensor must first be calibrated and display 0&thinsp;g. || 1 ||  Done
| 4 || The <code>on/off</code> button starts the system. The sensor must first be calibrated and display 0&thinsp;g. || 1 ||  Done
|-
|-
| 5 || The weight must be referenced for the measuring range. || 1 || In Progress
| 5 || The weight must be referenced for the measuring range. || 1 || Done
|-
|-
| 6 || The measured values ​​must be filtered/smoothed over time. || 1 ||  Done
| 6 || The measured values ​​must be filtered/smoothed over time. || 1 ||  Done
Zeile 62: Zeile 62:
| Provides feedback sound when the weight becomes stable
| Provides feedback sound when the weight becomes stable
|}
|}
== Working principle ==
== Working principle ==


Zeile 68: Zeile 69:


=== DMS Load Cell ===
=== DMS Load Cell ===
==== Introduction ====


A DMS load cell converts mechanical force into an electrical signal. It consists of:
A DMS load cell converts mechanical force into an electrical signal. It consists of:
Zeile 76: Zeile 75:
* resistance changes when stretched or compressed   
* resistance changes when stretched or compressed   


[[Datei:Load cell2.png|thumb|center|350px|Figure 1: Structure and deformation of a load cell. Source: https://learn.sparkfun.com/tutorials/getting-started-with-load-cells]]
[[Datei:Load cell2.png|thumb|right|350px|Figure 1: Structure and deformation of a load cell. <ref>Source: https://learn.sparkfun.com/tutorials/getting-started-with-load-cells</ref>]]


<div style="clear: both;"></div>
<div style="clear: both;"></div>
Zeile 89: Zeile 88:
* output: small differential voltage   
* output: small differential voltage   


[[Datei:Full Wheatstone Bridge.png|thumb|center|300px|Figure 2: Wheatstone bridge configuration. Source: https://learn.sparkfun.com/tutorials/getting-started-with-load-cells]]
[[Datei:Full Wheatstone Bridge.png|thumb|right|300px|Figure 2: Wheatstone bridge configuration.<ref>Source: https://learn.sparkfun.com/tutorials/getting-started-with-load-cells</ref>]]


<div style="clear: both;"></div>
<div style="clear: both;"></div>
---


=== HX711AD Measuring Amplifier ===
=== HX711AD Measuring Amplifier ===
==== Introduction ====


The HX711AD processes the small differential signal from the load cell.   
The HX711AD processes the small differential signal from the load cell.   
Zeile 104: Zeile 99:
* a 24‑bit sigma‑delta ADC   
* a 24‑bit sigma‑delta ADC   


[[Datei:HX711 Module.png|thumb|center|350px|Figure 3: HX711 module and pin configuration. Source: https://justdoelectronics.com/load-cell-hx711-module/]]
[[Datei:HX711 Module.png|thumb|right|350px|Figure 3: HX711 module and pin configuration.<ref>Source: https://justdoelectronics.com/load-cell-hx711-module/</ref>]]


<div style="clear: both;"></div>
<div style="clear: both;"></div>
Zeile 118: Zeile 113:
** SCK (clock)   
** SCK (clock)   


[[Datei:Block Internal Hx711.png|thumb|center|350px|Figure 4: Source: https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf]]
[[Datei:Block Internal Hx711.png|thumb|right|350px|Figure 4 : Internal block diagram of the HX711.<ref>Source: https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf</ref>]]
 
<div style="clear: both;"></div>
 
=== Microcontroller (Arduino Uno R3) ===
 
The system uses a Funduino Uno R3, which is an Arduino-compatible board based on the ATmega328P microcontroller.
[[Datei:Arduino Uno R3.jpg|thumb|right|Figure 5: Funduino Uno R3 (Arduino-compatible microcontroller)<ref>Source: HSHL Wiki – Arduino Uno R3, https://wiki.hshl.de/wiki/index.php/Datei:Arduino_Uno_R3.jpg</ref>]]
 
==== Working Principle ====
 
* The Arduino reads the digital output from the HX711AD via two pins (DOUT and PD_SCK). The HX711 sends a 24-bit serial data stream that represents the amplified and digitised load cell signal.
* It processes this raw value using calibration parameters (offset and calibration factor) to compute the weight in grams.
* It applies a digital filter (recursive average) to smooth the measurement and calculates the moving standard deviation to assess stability.
* Based on the stability result, the Arduino activates the buzzer (by generating a 1 kHz square wave) and updates the LCD display via the I2C bus.
* It continuously monitors two pushbuttons connected to interrupt pins:
  * Power button: toggles the system on/off 
  * Tare button: resets the offset to zero the scale 
 
All control logic is implemented either as an Arduino sketch (uploaded via Arduino IDE) or as a Simulink model deployed to the hardware using the Arduino Support Package and IO Device Builder.
 
=== LCD (I2C) ===
 
The system uses a 16×2 character LCD with an I2C (Inter-Integrated Circuit) backpack. The I2C interface reduces the number of required microcontroller pins from 6 (parallel mode) to only 2: SDA (data) and SCL (clock). The backpack contains a PCF8574 I/O expander that converts I2C commands into parallel signals for the LCD.
 
==== Working Principle ====
 
* The microcontroller sends a byte sequence over the I2C bus.
* Each byte contains either a command (e.g., clear display, set cursor) or a character to display.
* The PCF8574 outputs the corresponding parallel data and control signals (RS, EN, RW, D4–D7) to the LCD.
* The LCD then updates its screen accordingly.


In this project, the LCD displays the current filtered weight in grams and a stability indicator ("Stable" / "Unstable").
[[Datei:LCD HD44780.jpg|thumb|right|Figure 6: I2C LCD Module.<ref>Source: HSHL Wiki – LCD HD44780 image, https://wiki.hshl.de/wiki/index.php/Datei:LCD_HD44780.jpg</ref>]]
<div style="clear: both;"></div>
=== Buzzer ===
A passive piezoelectric buzzer is used to provide acoustic feedback. It is connected to a single digital output pin of the microcontroller.


==== Working Principle ====


* The microcontroller generates a square wave (typically 1 kHz) on the output pin. 
* The buzzer converts the electrical pulses into audible sound via a piezoelectric element. 
* A short burst (e.g., 200 ms) is generated when the measurement becomes stable, indicating to the user that the reading can be recorded.
[[Datei:R12-KT-9.jpg|thumb|right|Figure 7: Buzzer Module.<ref>Source: HSHL Wiki – R12-KT-9 load cell image, https://wiki.hshl.de/wiki/index.php/Datei:R12-KT-9.jpg</ref>]]
<div style="clear: both;"></div>
=== Pushbuttons (Power and Tare) ===
Two momentary pushbuttons are used for user input. Both are connected to interrupt-capable digital pins on the microcontroller and configured with internal pull-up resistors (active LOW).
==== Working Principle ====
* When a button is pressed, the pin voltage goes from HIGH (5 V) to LOW (0 V).
* This falling edge triggers an interrupt service routine (ISR) in the software.
* Power button: toggles the system state (ON/OFF). When OFF, the LCD is cleared and the buzzer is disabled.
* Tare button: resets the current weight reading to 0 g by updating the offset calibration parameter. This allows the user to zero the scale with any container placed on it.
[[Datei:Push button.png|thumb|right|Figure 8: Pushbuttons for power and tare control.<ref>Source: Funduino Shop – Push button component, https://funduinoshop.com/bauelemente/taster-und-schalter/taster/taster-klein-mit-rundem-knopf</ref>]]
<div style="clear: both;"></div>
<div style="clear: both;"></div>


Zeile 196: Zeile 244:
* Offset is the average ADC value with no load applied   
* Offset is the average ADC value with no load applied   
* Calibration factor converts ADC units to mass (units per gram)   
* Calibration factor converts ADC units to mass (units per gram)   
To reference the weight for the measuring range, both the offset and the calibration factor must be determined. The offset is obtained by measuring the sensor output at zero load (tare), while the calibration factor is calculated using a known reference weight. This ensures that the raw ADC values are correctly mapped to real weight values across the entire measuring range and provides accurate and consistent measurements.




Zeile 248: Zeile 297:
* Breadboard   
* Breadboard   
* Jumper wires   
* Jumper wires   
=== Circuit Description ===
=== Circuit Description ===
* The load cell is connected to the HX711AD measuring amplifier using a Wheatstone bridge configuration.
* The load cell is connected to the HX711AD measuring amplifier using a Wheatstone bridge configuration.
Zeile 257: Zeile 307:
** Power button: controls the system state
** Power button: controls the system state
** Tare button: resets the measured value to 0 g
** Tare button: resets the measured value to 0 g
{| style="width:100%; text-align:center;"
|-
| [[Datei:Weight DMS Circuit bb.png|thumb|700px|Figure 9: Schematic Diagram of the Weight Scale]]
| [[Datei:Weight circuit.jpg|thumb|700px|Figure 10: Complete weight circuit]]
|}
<div style="clear:both;"></div>


[[Datei:Weight circuit.jpg|right|700px|thumb|Complete weight circuit]]
<div style="clear:both;"></div>


= Software =
= Software =
Zeile 268: Zeile 322:


All hardware pin connections follow the definitions given in [[#PinAssignment|Section 3.1 (Pin Assignment)]]. The software uses those same pin numbers for digital I/O, interrupts, and I2C communication.
All hardware pin connections follow the definitions given in [[#PinAssignment|Section 3.1 (Pin Assignment)]]. The software uses those same pin numbers for digital I/O, interrupts, and I2C communication.
==== Operational Flowchart ====
Figure 11 shows the overall working of the weighing scale system. It outlines the sequence of operations from reading the HX711 sensor, converting the raw ADC value to grams, filtering the signal, evaluating stability, triggering the buzzer when a stable weight is detected, and updating the LCD with the measured weight.
[[Datei:DMS Flowchart.jpg|thumb|right|400px|Figure 11: Operational flowchart of the weighing scale system]]
<br clear="all">
== Arduino IDE ==
== Arduino IDE ==
The main program loop performs the following steps:
The main program loop performs the following steps:
Zeile 283: Zeile 344:
* HX711.h – for communicating with the HX711 amplifier.
* HX711.h – for communicating with the HX711 amplifier.
* LiquidCrystal_I2C.h – for the I2C LCD display.
* LiquidCrystal_I2C.h – for the I2C LCD display.
=== Arduino Implementation ===
<syntaxhighlight lang="cpp">
#include "HX711.h"              // HX711 load cell interface
#include <Wire.h>              // I2C communication library
#include <LiquidCrystal_I2C.h> // LCD display library
// Pin configuration
const uint8_t HX711_DT = 10;    // HX711 data pin
const uint8_t HX711_SCK = 9;    // HX711 clock pin
// Object initialization
HX711 scale(HX711_DT, HX711_SCK);  // Create HX711 object
LiquidCrystal_I2C lcd(0x27, 16, 2); // Initialize 16x2 LCD
// Filter variables
float filteredWeight = 0; // Stores filtered weight value
float alpha = 0.5;        // Low-pass filter coefficient
void loop() {
  // Read sensor every 50 ms to control update rate
  if (millis() - lastRead > 50) {
    lastRead = millis(); // Update timestamp
    // Read raw weight from HX711 (converted to units(gram))
    float weight = scale.get_units();
    // Apply recursive low-pass filter to reduce noise
    filteredWeight = alpha * weight + (1 - alpha) * filteredWeight;
    // Update LCD with current weight
    lcd.setCursor(0, 0);  // First row
    lcd.print("Weight:");
    lcd.setCursor(0, 1);  // Second row
    lcd.print(filteredWeight, 1); // Display filtered value (1 decimal place)
    lcd.print(" g  ");    // Append unit and clear old characters
  }
}
</syntaxhighlight>
The complete implementation, including stability detection, buzzer control, and interrupt-based button handling, is available in the SVN repository( link to be Updated shortly).
== Simulink ==
== Simulink ==
For advanced signal processing and data logging, a Simulink model was created using the Arduino Support Package for Simulink. The model uses the same pin assignments as defined in [[#PinAssignment|Section 3.1 (Pin Assignment)]].
For advanced signal processing and data logging, a Simulink model was created using the Arduino Support Package for Simulink. The model uses the same pin assignments as defined in [[#PinAssignment|Section 3.1 (Pin Assignment)]].
 
[[Datei:DMS Simulink Screenshot.png|thumb|right|950px|Figure 12: Simulink model of the weighing system.]]
Model Overview
Model Overview


* HX711 Read Block (custom block using IO Device Builder) – reads the 24-bit value via DOUT (pin 10) and PD_SCK (pin 9).
* HX711 Read Block (custom block using IO Device Builder) – reads the 24-bit value via DOUT (Digital Pin 10) and PD_SCK (Digital Pin 9).
[[Datei:Simulink weight model.png|thumb|right|Simulink model of the weighing system.]]
* Calibration & Scaling – subtracts offset and multiplies by scale factor.
* Calibration & Scaling – subtracts offset and multiplies by scale factor.
* Digital Filter – first-order recursive (IIR) low-pass filter with smoothing factor α = 0.1, used to reduce measurement noise.
* Digital Filter – first-order recursive (IIR) low-pass filter with smoothing factor α = 0.1, used to reduce measurement noise.
* Stability Detection – moving standard deviation computed over a sliding window of recent samples; the window size is adjustable and was tuned experimentally.
* Stability Detection – moving standard deviation computed over a sliding window of recent samples; the window size is adjustable and was tuned experimentally.
* Display – filtered weight on a Scope and/or LCD (custom block using IO Device Builder).
* Display – filtered weight on a Scope and/or LCD (custom block using IO Device Builder).
* Button Inputs – external interrupt-based inputs (using Arduino Support Package for Simulink) for the power button (pin 2) and tare button (pin 3), enabling immediate event-driven response.
* Button Inputs – external interrupt-based inputs (using Arduino Support Package for Simulink) for the power button (Interrupt Pin 3) and tare button (Interrupt Pin 2), enabling immediate event-driven response.


Note: The Simulink Arduino support package does not natively support the HX711 and LCD; custom blocks were created using the IO Device Builder.
Note: The Simulink Arduino support package does not natively support the HX711 and LCD; custom blocks were created using the IO Device Builder.
Zeile 303: Zeile 408:
Although readings above 1000 g were observed during testing, these values are outside the specified operating range and are not considered for accuracy evaluation.
Although readings above 1000 g were observed during testing, these values are outside the specified operating range and are not considered for accuracy evaluation.


 
[[Datei:Loadcell Result.png|thumb|950px|Figure 13:Simulink Scope showing filtered weight, signal stability, and stability detection]]
== 7.1 Calibration and Tare ==
== Calibration and Tare ==


The system was calibrated using a two-point procedure consisting of offset and scale factor determination.
The system was calibrated using a two-point procedure consisting of offset and scale factor determination.
Zeile 310: Zeile 415:
* Offset was obtained as the average of raw readings with no load applied.
* Offset was obtained as the average of raw readings with no load applied.
* Scale factor was determined using a known reference mass to convert raw ADC values into grams.
* Scale factor was determined using a known reference mass to convert raw ADC values into grams.
The calibration was applied directly within the processing chain to produce real-time weight measurements.
The calibration was applied directly within the processing chain to produce real-time weight measurements.


Zeile 317: Zeile 421:
Correct operation of the tare function was verified through observation, where applying tare reset the displayed weight to zero and removing the load resulted in a corresponding negative reading.
Correct operation of the tare function was verified through observation, where applying tare reset the displayed weight to zero and removing the load resulted in a corresponding negative reading.


== 7.2 Noise and Filtering Performance ==
== Noise and Filtering Performance ==


The raw and filtered signals were observed using the Simulink Scope. The applied recursive (IIR) low-pass filter provided smoothing of the signal, reducing short-term fluctuations.
The raw and filtered signals were observed using the Simulink Scope. The applied recursive (IIR) low-pass filter provided smoothing of the signal, reducing short-term fluctuations.
Zeile 325: Zeile 429:
Overall, the filter improved signal stability without significantly altering the measured value under steady-state conditions.
Overall, the filter improved signal stability without significantly altering the measured value under steady-state conditions.


 
== Stability Detection ==
 
== 7.3 Stability Detection ==


The stability detection mechanism was evaluated by observing the standard deviation of recent measurements in Simulink.
The stability detection mechanism was evaluated by observing the standard deviation of recent measurements in Simulink.
Zeile 336: Zeile 438:


Once stability was detected, the buzzer was activated, providing an audible confirmation to the user.
Once stability was detected, the buzzer was activated, providing an audible confirmation to the user.
== Measurement Uncertainty (1σ) ==
The measurement uncertainty was determined using the low-pass filtered (LPF) signal as the mean value. The standard deviation (σ) was calculated from the last five raw measurements for a constant reference weight.
'''Reference weight:''' 397 g
{| class="wikitable"
! Reference Weight !! Measured Value (LPF) !! Standard Deviation (σ)
|-
| 397 g || 396.45 g || 0.02 g
|-
| 397 g || 396.45 g || 0.01 g
|-
| 397 g || 396.46 g || 0.01 g
|-
| 397 g || 396.48 g || 0.01 g
|-
| 397 g || 396.46 g || 0.01 g
|}
The results show only small variations, indicating stable system behavior. The average standard deviation is approximately 0.015 g.
The measurement result can therefore be expressed as a confidence interval:
<math>Weight = 396.45\ \text{g} \pm 0.012\ \text{g}</math>


= Video =
= Video =
= Datasheets=
== Datasheets ==
 
* [https://www.mouser.lt/datasheet/2/1398/Soldered_100382_load_cell_sensor_1kg-3532410.pdf Load Cell Sensor (1kg) Datasheet] <br>
* [https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf HX711 Load Cell Amplifier Datasheet] <br>


= Related Links =
= Related Links =
*[https://wolles-elektronikkiste.de/hx711-basierte-waage HX711 based weight scale]
*[https://wolles-elektronikkiste.de/hx711-basierte-waage HX711 based weight scale]
*[https://wiki.hshl.de/wiki/index.php/LCD_Modul_16x02_I2C LCD Modul 16x02 I2C (HSHL Wiki)]
*[https://learn.sparkfun.com/tutorials/getting-started-with-load-cells Getting Started with Load Cells – SparkFun]
*[https://justdoelectronics.com/load-cell-hx711-module/ Load Cell with HX711 Module – Tutorial]
*[https://funduinoshop.com/bauelemente/taster-und-schalter/taster/taster-klein-mit-rundem-knopf Push Button Component – Funduino Shop]
= SVN-Repository =
= SVN-Repository =
  https://svn.hshl.de/svn/HSHL_Projekte/trunk/Arduino_Sensorsammlung
  https://svn.hshl.de/svn/HSHL_Projekte/trunk/Arduino_Sensorsammlung

Aktuelle Version vom 10. April 2026, 14:20 Uhr

fig. 1: DMS load cell with measuring amplifier HX711AD
Autor: Onyesi John Abiagam
Sprache: DE EN

Introduction

A weighing scale is a measurement system used to determine the mass of an object by converting mechanical force into a readable value.

This system is based on a DMS load cell in combination with the HX711AD measuring amplifier. The applied force is converted into an electrical signal, which is processed and displayed as a weight value.

The signal is acquired using a microcontroller-based system and processed using Simulink. Calibration, signal filtering, stability detection, and tare functionality are implemented to ensure accurate and stable measurements.

Requirements

Table 1: Requirements for the Unit
Req. Description Priority Progress
1 The mass must be determined using the HX711AD load cell via Arduino and Simulink. 1 Done
2 The measuring range must be determined. 1 Done
3 The measurement uncertainty (1σ) must be determined for the measuring range and displayed as a confidence interval. 2 Done
4 The on/off button starts the system. The sensor must first be calibrated and display 0 g. 1 Done
5 The weight must be referenced for the measuring range. 1 Done
6 The measured values ​​must be filtered/smoothed over time. 1 Done
7 A beep must indicate when the measured value is stable/constant. 1 Done
8 The sensor system must display the weight in g on a display. 1 Done
9 The tara button resets the current weight to 0 g (recalibration). 1 Done

Required Components

Component Function
DMS Load Cell (1 kg) Converts mechanical force into a small electrical signal
HX711AD Measuring Amplifier Amplifies the tiny load-cell signal and converts it into a 24-bit digital value
Microcontroller (Arduino Uno R3) Central control unit that reads sensor data, processes signals, and controls peripherals such as the display, pushbutton, and buzzer
LCD Display (I2C) Displays the measured weight
Pushbuttons Provide user input for system control functions such as tare (zeroing) and power operation
Buzzer Provides feedback sound when the weight becomes stable

Working principle

This section describes the complete working principle of the system, including force sensing with the DMS load cell, signal amplification and digitization using the HX711AD, and data processing by the microcontroller. Additionally, it covers user interaction via pushbuttons and the output of measurement results through the display and feedback sound using the buzzer.


DMS Load Cell

A DMS load cell converts mechanical force into an electrical signal. It consists of:

  • a deformable metal body
  • strain gauges attached to the surface
  • resistance changes when stretched or compressed
Figure 1: Structure and deformation of a load cell. [1]

Working Principle

When force is applied:

  • the metal body deforms
  • strain gauges change resistance
  • gauges are wired in a Wheatstone bridge
  • deformation → bridge becomes unbalanced
  • output: small differential voltage
Figure 2: Wheatstone bridge configuration.[2]

HX711AD Measuring Amplifier

The HX711AD processes the small differential signal from the load cell. It includes:

  • a programmable gain amplifier (PGA)
  • a 24‑bit sigma‑delta ADC
Figure 3: HX711 module and pin configuration.[3]

Working Principle

Signal processing steps:

  • load cell outputs a millivolt‑level differential signal (A+, A−)
  • PGA amplifies the signal
  • 24‑bit ADC converts it to digital
  • microcontroller reads data via:
    • DOUT (data)
    • SCK (clock)
Figure 4 : Internal block diagram of the HX711.[4]

Microcontroller (Arduino Uno R3)

The system uses a Funduino Uno R3, which is an Arduino-compatible board based on the ATmega328P microcontroller.

Figure 5: Funduino Uno R3 (Arduino-compatible microcontroller)[5]

Working Principle

  • The Arduino reads the digital output from the HX711AD via two pins (DOUT and PD_SCK). The HX711 sends a 24-bit serial data stream that represents the amplified and digitised load cell signal.
  • It processes this raw value using calibration parameters (offset and calibration factor) to compute the weight in grams.
  • It applies a digital filter (recursive average) to smooth the measurement and calculates the moving standard deviation to assess stability.
  • Based on the stability result, the Arduino activates the buzzer (by generating a 1 kHz square wave) and updates the LCD display via the I2C bus.
  • It continuously monitors two pushbuttons connected to interrupt pins:
 * Power button: toggles the system on/off  
 * Tare button: resets the offset to zero the scale  

All control logic is implemented either as an Arduino sketch (uploaded via Arduino IDE) or as a Simulink model deployed to the hardware using the Arduino Support Package and IO Device Builder.

LCD (I2C)

The system uses a 16×2 character LCD with an I2C (Inter-Integrated Circuit) backpack. The I2C interface reduces the number of required microcontroller pins from 6 (parallel mode) to only 2: SDA (data) and SCL (clock). The backpack contains a PCF8574 I/O expander that converts I2C commands into parallel signals for the LCD.

Working Principle

  • The microcontroller sends a byte sequence over the I2C bus.
  • Each byte contains either a command (e.g., clear display, set cursor) or a character to display.
  • The PCF8574 outputs the corresponding parallel data and control signals (RS, EN, RW, D4–D7) to the LCD.
  • The LCD then updates its screen accordingly.

In this project, the LCD displays the current filtered weight in grams and a stability indicator ("Stable" / "Unstable").

Figure 6: I2C LCD Module.[6]

Buzzer

A passive piezoelectric buzzer is used to provide acoustic feedback. It is connected to a single digital output pin of the microcontroller.

Working Principle

  • The microcontroller generates a square wave (typically 1 kHz) on the output pin.
  • The buzzer converts the electrical pulses into audible sound via a piezoelectric element.
  • A short burst (e.g., 200 ms) is generated when the measurement becomes stable, indicating to the user that the reading can be recorded.
Figure 7: Buzzer Module.[7]

Pushbuttons (Power and Tare)

Two momentary pushbuttons are used for user input. Both are connected to interrupt-capable digital pins on the microcontroller and configured with internal pull-up resistors (active LOW).

Working Principle

  • When a button is pressed, the pin voltage goes from HIGH (5 V) to LOW (0 V).
  • This falling edge triggers an interrupt service routine (ISR) in the software.
  • Power button: toggles the system state (ON/OFF). When OFF, the LCD is cleared and the buzzer is disabled.
  • Tare button: resets the current weight reading to 0 g by updating the offset calibration parameter. This allows the user to zero the scale with any container placed on it.
Figure 8: Pushbuttons for power and tare control.[8]

Technical Overview

  • The system consists of a DMS load cell, an HX711AD measuring amplifier, a microcontroller, an LCD, a buzzer, and two push buttons (power and tare).
  • The load cell converts the applied force into an electrical signal, which is amplified and digitized by the HX711AD.
  • The digital data is read and processed by the microcontroller.
  • The measured weight is displayed on the LCD.
  • A buzzer indicates when a stable measurement is reached.
  • The power button controls the system state, and the tare button resets the measured value to 0 g.

Pin Assignment

This section describes the electrical connections between the load cell, the HX711AD,the buzzer,LCD and push buttons and the microcontroller.

Load Cell to HX711

Load Cell Wire Function HX711 Pin Description
Red Excitation + (E+) E+ Supplies voltage to the bridge
Black Excitation − (E−) E− Ground reference
White Signal + (S+) A+ Positive input signal
Green Signal − (S−) A− Negative input signal
Yellow (optional) Shield GND EMI protection

HX711 to Microcontroller

HX711 Pin Function Microcontroller Pin Description
VCC Power Supply 5V / 3.3V Power input
GND Ground GND Common reference
DOUT Data Output Digital Input Sends measurement data
PD_SCK Clock Input Digital Output Controls data read

Microcontroller Peripherals

Component Function Microcontroller Pin Description
LCD Display output I2C (SDA/SCL) Displays measured weight
Buzzer Acoustic feedback Digital Output Indicates stable measurement
Push Button (Power) System control Interrupt Pin (e.g., D2) Starts or stops the system
Push Button (Tare) Reset function Interrupt Pin (e.g., D3) Resets measured value to 0 g

Measurement method

This section describes the processing steps used to convert raw sensor data into a stable and meaningful weight measurement. The method includes calibration, signal filtering, and stability evaluation.

Calibration and Weight Calculation

The raw digital value from the HX711 is converted into a weight value using calibration parameters:

Weight = (Raw ADC value − Offset) / Calibration factor

where:

  • Raw ADC value is the digital output from the HX711
  • Offset is the average ADC value with no load applied
  • Calibration factor converts ADC units to mass (units per gram)

To reference the weight for the measuring range, both the offset and the calibration factor must be determined. The offset is obtained by measuring the sensor output at zero load (tare), while the calibration factor is calculated using a known reference weight. This ensures that the raw ADC values are correctly mapped to real weight values across the entire measuring range and provides accurate and consistent measurements.


Filtering

To reduce noise, a recursive average filter is applied:

y[n] = α · x[n] + (1 − α) · y[n−1]

where:

  • x[n] is the current measurement
  • y[n] is the filtered value
  • α is the filter coefficient (0 < α < 1)


Stability Detection

The stability of the measurement is evaluated using the standard deviation:

σ = sqrt( (1/N) · Σ (x_i − μ)^2 )

where:

  • x_i is the i-th sample in the measurement window
  • μ is the mean of the samples
  • N is the number of samples in the window

A measurement is considered stable when the standard deviation falls below a defined threshold.

Measurement Output

The final result is expressed as:

Weight = μ ± σ

where:

  • μ: mean value
  • σ: standard deviation (measurement uncertainty)

Measuring Circuit

Components

  • DMS load cell ( 1Kg)
  • HX711AD measuring amplifier
  • Microcontroller (Arduino Uno R3)
  • LCD (I2C)
  • Buzzer
  • Push button (power)
  • Push button (tare)
  • Breadboard
  • Jumper wires

Circuit Description

  • The load cell is connected to the HX711AD measuring amplifier using a Wheatstone bridge configuration.
  • The HX711AD is powered by the microcontroller and shares a common ground with all components.
  • The HX711AD transmits digital measurement data to the microcontroller via the DOUT and PD_SCK pins.
  • The LCD is connected to the microcontroller via the I2C interface (SDA and SCL).
  • A buzzer is connected to a digital output pin to provide feedback sound.
  • Two push buttons are connected to interrupt-capable pins:
    • Power button: controls the system state
    • Tare button: resets the measured value to 0 g
Figure 9: Schematic Diagram of the Weight Scale
Figure 10: Complete weight circuit


Software

The software for this project is implemented in two environments:

  • Arduino IDE for low-level hardware control (reading the HX711, driving the LCD, buttons, and buzzer).
  • Simulink (MATLAB) for signal processing, data logging, and visualisation.

All hardware pin connections follow the definitions given in Section 3.1 (Pin Assignment). The software uses those same pin numbers for digital I/O, interrupts, and I2C communication.

Operational Flowchart

Figure 11 shows the overall working of the weighing scale system. It outlines the sequence of operations from reading the HX711 sensor, converting the raw ADC value to grams, filtering the signal, evaluating stability, triggering the buzzer when a stable weight is detected, and updating the LCD with the measured weight.

Figure 11: Operational flowchart of the weighing scale system


Arduino IDE

The main program loop performs the following steps:

  • Read the raw 24-bit value from the HX711.
  • Apply a recursive average filter to reduce noise.
  • Convert the filtered value to grams using calibration parameters (offset and scale factor).
  • Check stability by computing the standard deviation of recent measurements.
  • If stable, activate the buzzer briefly.
  • Update the LCD with the current weight.
  • Handle button interrupts for power (on/off) and tare (zeroing).

Required Libraries

  • HX711.h – for communicating with the HX711 amplifier.
  • LiquidCrystal_I2C.h – for the I2C LCD display.

Arduino Implementation

#include "HX711.h"              // HX711 load cell interface
#include <Wire.h>              // I2C communication library
#include <LiquidCrystal_I2C.h> // LCD display library

// Pin configuration
const uint8_t HX711_DT = 10;    // HX711 data pin
const uint8_t HX711_SCK = 9;    // HX711 clock pin

// Object initialization
HX711 scale(HX711_DT, HX711_SCK);   // Create HX711 object
LiquidCrystal_I2C lcd(0x27, 16, 2); // Initialize 16x2 LCD

// Filter variables
float filteredWeight = 0; // Stores filtered weight value
float alpha = 0.5;        // Low-pass filter coefficient

void loop() {

  // Read sensor every 50 ms to control update rate
  if (millis() - lastRead > 50) {
    lastRead = millis(); // Update timestamp

    // Read raw weight from HX711 (converted to units(gram))
    float weight = scale.get_units();

    // Apply recursive low-pass filter to reduce noise
    filteredWeight = alpha * weight + (1 - alpha) * filteredWeight;

    // Update LCD with current weight
    lcd.setCursor(0, 0);   // First row
    lcd.print("Weight:");

    lcd.setCursor(0, 1);   // Second row
    lcd.print(filteredWeight, 1); // Display filtered value (1 decimal place)
    lcd.print(" g   ");    // Append unit and clear old characters
  }
}

The complete implementation, including stability detection, buzzer control, and interrupt-based button handling, is available in the SVN repository( link to be Updated shortly).


Simulink

For advanced signal processing and data logging, a Simulink model was created using the Arduino Support Package for Simulink. The model uses the same pin assignments as defined in Section 3.1 (Pin Assignment).

Figure 12: Simulink model of the weighing system.

Model Overview

  • HX711 Read Block (custom block using IO Device Builder) – reads the 24-bit value via DOUT (Digital Pin 10) and PD_SCK (Digital Pin 9).
  • Calibration & Scaling – subtracts offset and multiplies by scale factor.
  • Digital Filter – first-order recursive (IIR) low-pass filter with smoothing factor α = 0.1, used to reduce measurement noise.
  • Stability Detection – moving standard deviation computed over a sliding window of recent samples; the window size is adjustable and was tuned experimentally.
  • Display – filtered weight on a Scope and/or LCD (custom block using IO Device Builder).
  • Button Inputs – external interrupt-based inputs (using Arduino Support Package for Simulink) for the power button (Interrupt Pin 3) and tare button (Interrupt Pin 2), enabling immediate event-driven response.

Note: The Simulink Arduino support package does not natively support the HX711 and LCD; custom blocks were created using the IO Device Builder.

Measurement

This section presents the experimental results obtained from the implemented weighing system. The measurements include calibration data, noise analysis, filter performance, stability detection, and the final measurement uncertainty over the intended operating range (0–1000 g), corresponding to the rated capacity of the load cell.

Although readings above 1000 g were observed during testing, these values are outside the specified operating range and are not considered for accuracy evaluation.

Figure 13:Simulink Scope showing filtered weight, signal stability, and stability detection

Calibration and Tare

The system was calibrated using a two-point procedure consisting of offset and scale factor determination.

  • Offset was obtained as the average of raw readings with no load applied.
  • Scale factor was determined using a known reference mass to convert raw ADC values into grams.

The calibration was applied directly within the processing chain to produce real-time weight measurements.

The tare function was implemented to allow zeroing of the system during operation. When activated, the current measured value was stored as a new offset, enabling subsequent measurements to be referenced relative to the applied load.

Correct operation of the tare function was verified through observation, where applying tare reset the displayed weight to zero and removing the load resulted in a corresponding negative reading.

Noise and Filtering Performance

The raw and filtered signals were observed using the Simulink Scope. The applied recursive (IIR) low-pass filter provided smoothing of the signal, reducing short-term fluctuations.

The effect of the filter depended on the chosen smoothing factor (α). While increased smoothing improved noise reduction, it also introduced a risk of attenuating rapid changes in the measured weight if not carefully tuned.

Overall, the filter improved signal stability without significantly altering the measured value under steady-state conditions.

Stability Detection

The stability detection mechanism was evaluated by observing the standard deviation of recent measurements in Simulink.

During dynamic conditions (e.g., when a load was applied), the standard deviation increased, indicating an unstable signal. As the measurement settled, the standard deviation decreased accordingly.

A predefined threshold was used to determine stability. When the standard deviation dropped below this threshold, the system indicated a stable condition (logical output = 1).

Once stability was detected, the buzzer was activated, providing an audible confirmation to the user.

Measurement Uncertainty (1σ)

The measurement uncertainty was determined using the low-pass filtered (LPF) signal as the mean value. The standard deviation (σ) was calculated from the last five raw measurements for a constant reference weight.

Reference weight: 397 g

Reference Weight Measured Value (LPF) Standard Deviation (σ)
397 g 396.45 g 0.02 g
397 g 396.45 g 0.01 g
397 g 396.46 g 0.01 g
397 g 396.48 g 0.01 g
397 g 396.46 g 0.01 g

The results show only small variations, indicating stable system behavior. The average standard deviation is approximately 0.015 g.

The measurement result can therefore be expressed as a confidence interval:

Weight=396.45g±0.012g

Video

Datasheets

Related Links

SVN-Repository

https://svn.hshl.de/svn/HSHL_Projekte/trunk/Arduino_Sensorsammlung



→ zurück zum Hauptartikel: HSHL-Mechatronik-Baukasten | Arduino Sensorsammlung | Sensorinbetriebnahme mit Arduino und Simulink