Load Cell Amplifier HX711: Interfacing with STM32

by Marwen Maghrebi

In this article, we explore the Load Cell Amplifier HX711 and its integration with STM32 microcontrollers to achieve precise weight measurements.

STM32 microcontroller interfaced with HX711 load cell amplifier for precise weight measurement.

Things used in this project

Software apps and online services:

1- STMicroelectronics STM32CubeMX

2- STMicroelectronics STM32CubeIDE

3- Proteus 8

Load Cell Amplifier HX711 with STM32 Microcontroller: A Comprehensive Guide

Accurate weight measurement is crucial in various applications, from industrial scales to kitchen devices. The SparkFun Load Cell Amplifier HX711, combined with an STM32 microcontroller, provides a robust solution for precise weight measurements. This article explores the integration of the HX711 with an STM32 microcontroller, offering a detailed guide on setup, calibration, and implementation.

Understanding Load Cells with STM32 Integration

  • What is a Load Cell?
    A load cell is a transducer that converts force into an electrical signal. This signal’s magnitude is directly proportional to the force applied. There are various types of load cells, including hydraulic, pneumatic, and strain gauge.
  • Strain Gauge Load Cells
    Strain gauge load cells are the most commonly used in industrial applications. They offer high stiffness, excellent resonance values, and long life cycles. These load cells operate on the principle that a strain gauge deforms when the load cell material deforms. This deformation changes the strain gauge’s electrical resistance, proportional to the strain, which can be measured and calibrated to determine the applied load.

A typical strain gauge load cell consists of four strain gauges arranged in a Wheatstone bridge configuration. The output signal is usually in the millivolt range and requires amplification before it can be processed.High-resolution ADCs, such as the 24-bit ADC in the HX711, can directly read these signals.

Load Cell Amplifier HX711 board for precise weight measurement with STM32

Overview of the HX711 Load Cell Amplifier for STM32 Projects

The HX711 is a precision 24-bit ADC designed for weigh scales and industrial control applications. It features:

Load Cell Amplifier HX711 with STM32 in a Typical Weigh Scale Application Block Diagram
  • Two selectable differential input channels
  • On-chip active low noise PGA with selectable gain of 32, 64, and 128
  • On-chip power supply regulator for the load cell and ADC analog power supply
  • On-chip oscillator with optional external crystal
  • On-chip power-on-reset
  • Simple digital control and serial interface
  • Selectable 10SPS or 80SPS output data rate
  • Simultaneous 50 and 60Hz supply rejection
  • Low current consumption: < 1.5mA during operation, < 1µA in power down mode
  • Wide operating supply voltage range: 2.6V ~ 5.5V
  • Operation temperature range: -40℃ ~ +85℃

Pin Description of HX711 Load Cell Amplifier for STM32 Interfacing

Key Electrical Characteristics of the Load Cell Amplifier HX711

To initiate this project, we’ll configure GPIO pins PA1 (DT) and PA2 (SCK) for interfacing with the HX711 load cell, ensuring accurate weight measurement. We’ll then enable the TIM1 timer to create precise microsecond delays for the HX711 communication protocol, crucial for reliable data acquisition. Finally, we’ll integrate the HX711 into our system, using the STM32’s UART interface to transmit weight data to a serial monitor for real-time observation. This approach demonstrates effective utilization of the HX711 in embedded applications for precise weight detection.

STM32CubeMX Configuration:

  • Open CubeMX & Create New Project Choose The Target MCU STM32F103C6 & Double-Click Its Name
  • Go To The Clock Configuration & Set The System Clock To 8MHz

Configuration for the GPIO Mode:

  • Configure The GPIO Pins PA1 as Output Pin
  • Configure The GPIO Pins PA2 as Input Pin

Configuration for the TIMER Mode:

  • In the Categories tab, select the TIM1
  • Enable Internal Clock
  • In the Parameter settings tab, set the (Prescaler=0 & Counter Peroid 65535) 

Configuration for the UART Mode:

  • Enable USART1 Module (Asynchronous Mode)
  • Set the USART1 communication parameters (baud rate = 9600, parity=NON, stop bits =1, and word length = 8bits)
  • Generate The Initialization Code & Open The Project In CubeIDE

STM32CubeIDE Configuration:

  • Write The Application Layer Code
  • hx711.h , hx711.c
  • main.c

Proteus Configuration :

  • Open Proteus & Create New Project and click next

  • Click on Virtual Instruments Mode then choose DC VOLTMETER

  • Click on Pick Device
  • Search for STM32F103C6 & RES & CAPACITOR & HX711 & CAP-ELEC  & LOADCELL & EN4403 
  • Click on Terminal Mode then choose (DYNAMIC&POWER &GROUND)
  • finally make the circuit below and start the simulation
Load Cell Amplifier HX711 circuit design for weight measurement with STM32.

That’s all!
If you have any questions or suggestions don’t hesitate to leave a comment below

You Might Also Like

Leave a Comment


Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00