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

QtyPartWhat it does
1Arduino Unothe microcontroller board
1HX711 load cell amplifierDT goes LOW when a reading is ready; 25 SCK pulses clock out 24 bits, MSB first. The reading is grams × 100.

Wiring

#FromTo
1Arduino Uno 5VHX711 load cell amplifier VCC
2Arduino Uno GNDHX711 load cell amplifier GND
3Arduino Uno pin 3HX711 load cell amplifier DT
4Arduino Uno pin 2HX711 load cell amplifier SCK

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add an HX711 load cell amplifier from the parts palette.
  3. Wire 1. Connect Arduino Uno 5V to HX711 load cell amplifier VCC.
  4. Wire 2. Connect Arduino Uno GND to HX711 load cell amplifier GND.
  5. Wire 3. Connect Arduino Uno pin 3 to HX711 load cell amplifier DT.
  6. Wire 4. Connect Arduino Uno pin 2 to HX711 load cell amplifier SCK.
  7. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  8. 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