Overview of the Hx711 Module
The Hx711 module is a breakout board for the Avia Semiconductor Hx711 24-bit ADC for weigh scales. It allows you to easily read load cells and scale sensors to measure weight. The module interfaces with microcontrollers like Arduino and Raspberry Pi using just two wires.
Some key features of the Hx711 include:
- Two selectable differential input channels
- On-chip active low noise programmable gain amplifier (PGA) with selectable gain of 32, 64 and 128
- On-chip power supply regulator for load-cell and ADC analog power supply
- On-chip oscillator requiring no external component with optional external crystal
- On-chip power-on-reset
- Simple digital control and serial interface: pin-driven controls, no programming needed
- Selectable 10SPS or 80SPS output data rate
- Simultaneous 50 and 60Hz supply rejection
- Current consumption including on-chip analog power supply regulator:
- Normal operation < 1.5mA
- Power down < 1uA
- Operation supply voltage range: 2.6 ~ 5.5V
- Operation temperature range: -40 ~ +85°C
- 16 pin SOP-16 package
Hx711 Pinout Configuration
Understanding the pinout of the Hx711 chip is essential to properly interface it with sensors and microcontrollers. Here is a table showing the pinout:
Pin | Name | Description |
---|---|---|
1 | VSUP | Power supply (2.7 – 5.5V) |
2 | BASE | Regulate output voltage (NC when not used) |
3 | AVDD | Analog supply voltage: 2.6 – 5.5V |
4 | VFB | Analog output voltage feedback input to regulate AVDD voltage (NC when not used) |
5 | AGND | Ground for analog power supply |
6 | VBG | Input to external 1.25V reference (NC when not used) |
7 | INA | Channel A negative input |
8 | INB | Channel B negative input |
9 | INNA | Channel A positive input |
10 | INNB | Channel B positive input |
11 | PD_SCK | Power down control (high active) and serial clock input |
12 | DOUT | Serial data output |
13 | XO | Crystal oscillator output |
14 | XI | Crystal oscillator input |
15 | RATE | Output data rate control |
16 | DVDD | Digital supply voltage: 2.6 – 5.5V |
And here is the pinout diagram:
+-------+
VSUP -|1 16|- DVDD
BASE -|2 15|- RATE
AVDD -|3 14|- XI
VFB -|4 13|- XO
AGND -|5 12|- DOUT
VBG -|6 11|- PD_SCK
INA -|7 10|- INNB
INB -|8 9|- INNA
+-------+
On the typical Hx711 breakout board, there are 4 pins you need to connect:
- VCC: Power supply, 2.7 to 5.5V
- GND: Ground
- DOUT: Data output to microcontroller
- SCK: Serial clock input
And it has 4 pins to connect to a load cell:
- E+: Excitation+
- E-: Excitation-
- A-: Signal-
- A+: Signal+
How the Hx711 Works
The Hx711 uses a two-wire interface (Clock and Data) for communication. The clock input is used to shift out the data serially on the data output pin.
It can interface directly with a bridge sensor, such as load cells, providing a differential input voltage. The Hx711 then converts this differential voltage to a 24-bit value using its internal ADC. The chip has an adjustable gain amplifier allowing you to adjust the sensitivity based on your expected load.
The Hx711 can be operated in two modes:
-
Channel A with selectable gain of 128 or 64. This is the default mode and is used for reading load cells.
-
Channel B with a fixed gain of 32. This mode is used for reading a second sensor.
The output data rate can be selected as 10SPS or 80SPS based on the RATE pin.
Interfacing with Arduino
To use the Hx711 with an Arduino, you can use the HX711 library available in the Arduino IDE library manager. First install the library, then use the following sample code:
#include "HX711.h"
const int DOUT = 2;
const int SCK = 3;
HX711 scale;
void setup() {
Serial.begin(9600);
scale.begin(DOUT, SCK);
scale.set_scale(2280.f);
scale.tare();
}
void loop() {
Serial.print("Weight: ");
Serial.print(scale.get_units(), 1);
Serial.println(" lbs");
delay(500);
}
The set_scale
function sets the calibration factor for the load cell. This factor is determined by calibrating the scale with known weights. The tare
function sets the current weight as the zero point.
Interfacing with Raspberry Pi
To interface the Hx711 with a Raspberry Pi, you can use the HX711 Python library. First install the library using pip:
pip install hx711
Then use the following sample code:
import RPi.GPIO as GPIO
import time
import sys
from hx711 import HX711
def cleanAndExit():
print("Cleaning...")
GPIO.cleanup()
print("Bye!")
sys.exit()
hx = HX711(5, 6)
hx.set_reading_format("MSB", "MSB")
hx.set_reference_unit(92)
hx.reset()
hx.tare()
while True:
try:
val = hx.get_weight(5)
print(val)
hx.power_down()
time.sleep(0.1)
hx.power_up()
time.sleep(0.1)
except (KeyboardInterrupt, SystemExit):
cleanAndExit()
FAQs
1. What is the Hx711 used for?
The Hx711 is primarily used for reading load cells to measure weight in weigh scales and other industrial control applications. It can also be used to read other sensors that output a differential voltage.
2. What is the difference between Channel A and Channel B?
Channel A has a selectable gain of 128 or 64 and is typically used for reading load cells. Channel B has a fixed gain of 32 and can be used to read a second sensor if needed.
3. How do I calibrate my Hx711 with a load cell?
To calibrate, you need to determine the calibration factor. Place a known weight on the scale and divide the result from the Hx711 by the known weight to get the calibration factor. Use this factor in your code with the set_scale
function.
4. What is the maximum weight the Hx711 can measure?
The maximum weight depends on the load cell being used. The Hx711 itself has a 24-bit resolution, meaning it can theoretically measure very small changes in weight. However, the load cell’s maximum capacity will determine the maximum weight that can be measured.
5. Can I use the Hx711 with a 3.3V microcontroller?
Yes, the Hx711 can operate with a supply voltage ranging from 2.7V to 5.5V, so it is compatible with both 3.3V and 5V microcontrollers.
Leave a Reply