Arduino HX711 Load Cell Scale: Wiring, Code and Simulator
To build this Arduino HX711 Load Cell Scale project you need an Arduino Uno and an HX711 load cell amplifier. Clock 24 bits out of an HX711 load-cell amplifier by hand and convert to grams. Make the 4 connections in the wiring table, upload the Arduino C++ code, and set a load with the slider in the Inspector and watch the reading follow.
Open this circuit in the free Arduino Uno simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | Arduino Uno | the microcontroller board |
| 1 | HX711 load cell amplifier | DT goes LOW when a reading is ready; 25 SCK pulses clock out 24 bits, MSB first. The reading is grams × 100. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Arduino Uno 5V | HX711 load cell amplifier VCC |
| 2 | Arduino Uno GND | HX711 load cell amplifier GND |
| 3 | Arduino Uno pin 3 | HX711 load cell amplifier DT |
| 4 | Arduino Uno pin 2 | HX711 load cell amplifier SCK |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
- Add the parts. Add an HX711 load cell amplifier from the parts palette.
- Wire 1. Connect Arduino Uno 5V to HX711 load cell amplifier VCC.
- Wire 2. Connect Arduino Uno GND to HX711 load cell amplifier GND.
- Wire 3. Connect Arduino Uno pin 3 to HX711 load cell amplifier DT.
- Wire 4. Connect Arduino Uno pin 2 to HX711 load cell amplifier SCK.
- Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
- Run it. Press Run. Set a load with the slider in the Inspector and watch the reading follow.
Arduino C++ code
// Kitchen scale: read an HX711 load-cell amplifier (DT on pin 3, SCK on pin 2).
// Wait for DT to go LOW, then clock out 24 bits MSB first and one more pulse.
const int DT = 3, SCK_PIN = 2;
const float COUNTS_PER_GRAM = 100.0; // calibration for this load cell
long readHx711() {
while (digitalRead(DT) == HIGH) {}
long value = 0;
for (int i = 0; i < 24; i++) {
digitalWrite(SCK_PIN, HIGH);
delayMicroseconds(1);
value = (value << 1) | digitalRead(DT);
digitalWrite(SCK_PIN, LOW);
delayMicroseconds(1);
}
digitalWrite(SCK_PIN, HIGH); // 25th pulse: gain 128 for the next reading
delayMicroseconds(1);
digitalWrite(SCK_PIN, LOW);
if (value & 0x800000) value |= 0xFF000000; // sign-extend 24 bits
return value;
}
void setup() {
pinMode(DT, INPUT);
pinMode(SCK_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
Serial.print("Weight: ");
Serial.print(readHx711() / COUNTS_PER_GRAM, 0);
Serial.println(" g");
delay(300);
}
What to try
Set a load with the slider in the Inspector and watch the reading follow.
Frequently asked questions
How do I wire the HX711 Load Cell Scale project on an Arduino Uno?
Make 4 connections: Arduino Uno 5V to HX711 load cell amplifier VCC; Arduino Uno GND to HX711 load cell amplifier GND; Arduino Uno pin 3 to HX711 load cell amplifier DT; Arduino Uno pin 2 to HX711 load cell amplifier SCK.
What parts do I need for this Arduino project?
An Arduino Uno and an HX711 load cell amplifier.
Can I simulate this Arduino project online for free?
Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.
What does the code do?
Clock 24 bits out of an HX711 load-cell amplifier by hand and convert to grams.
More Arduino Uno projects
- Arduino LED Blink: Wiring, Code and Simulator
- Arduino LDR Light Sensor: Wiring, Code and Simulator
- Arduino NTC Thermistor Thermometer: Wiring, Code and Simulator
- Arduino PWM to Analog RC Filter: Wiring, Code and Simulator
- Arduino Capacitance Meter: Wiring, Code and Simulator
- Arduino DC Motor PWM Speed Control with MOSFET: Wiring, Code and Simulator