Nano ESP32 connected with HX711

Hi everyone,

I am really a newbie in this kind of thing and I need help. I try to make the Iot scale with Nano ESP32 and HX711 but I can't even make the scale work. I've try this code with UNO board and it work well but when I try on Nano ESP32 it keep showing "HX711 not found." If anyone can help, Thank a lot.

// Calibrating the load cell
#include "HX711.h"

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 6;
const int LOADCELL_SCK_PIN = 7;

HX711 scale;

void setup() {
  Serial.begin(57600);
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
}

void loop() {

  if (scale.is_ready()) {
    scale.set_scale();    
    Serial.println("Tare... remove any weights from the scale.");
    delay(5000);
    scale.tare();
    Serial.println("Tare done...");
    Serial.print("Place a known weight on the scale...");
    delay(5000);
    long reading = scale.get_units(10);
    Serial.println("Result: ");
    Serial.println(reading);
  } 
  else {
    Serial.println("HX711 not found.");
  }
  delay(1000);
}

Welcome to the forum

The Uno runs at 5V and the Nano ESP32 runs at 3.3V

Could this be the cause of your problem ?

Might be..., First I connected the HX711 with VBUS (should be 5V caused I connected Nano ESP32 with my laptop) but the result shows "HX711 not found." But after I changed from VBUS to 3.3V pin, the result keep showing (the scale doesn't response to the weight I put on the scale)

"Tare... remove any weights from the scale.
Tare done...
Place a known weight on the scale...Result:
0"

Is it possible that the Nano ESP32 don't read the "void set up" part? So, the scale begin didn't work. Because I changed the code by adding the Serial.print in void setup but it didn't show in the serial monitor.

#include "HX711.h"

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 6;
const int LOADCELL_SCK_PIN = 7;

HX711 scale;

void setup() {
  Serial.begin(57600);
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

  Serial.print("Starting...");
}

void loop() {

  if (scale.is_ready()) {
    scale.set_scale();    
    Serial.println("Tare... remove any weights from the scale.");
    delay(5000);
    scale.tare();
    Serial.println("Tare done...");
    Serial.print("Place a known weight on the scale...");
    delay(5000);
    long reading = scale.get_units(10);
    Serial.println("Result: ");
    Serial.println(reading);
  } 
  else {
    Serial.println("HX711 not found.");
  }
  delay(1000);
}

Connect Vcc to 5V (VBUS) and Vdd to 3.3V

what is Vdd? I used the HX711 from M5 stack. it has only 4 channels: DAT, CLK, 5V, and GND

OK the M5 does not have Vdd.
The Nano ESP is 3.3V I/O so you must use 3.3V.
Connecting the Nano pins to 5V may have damaged them so first try to use different pins.

If you still have problems, try the basic example
Go to Menu File -> Examples -> HX711 Arduino Library -> HX711_basic_example

I did use the basic code just change the pin number, because the pins in an example are for UNO.

So you are now using pins 2 and 3 and what does the serial monitor show?

I use pin 7 and 8 because pin 2 and 3 in Nano ESP is analog pin. The result is the same. Keep printing "HX711 reading: 0" even I put something on the scale, it read as 0

No D2 nad D3 are digital pins
I think you have your pin numbers mixed up
Show a diagram of how you have the scale connected.
Please post a datasheet for the scale.

Do you mean by how I connect ESP, HX711, and scale? here is the diagram. and I did change the pin to D2 and D3 but the result is the same. I also change the PIN number in the code to D2 (5) and D3 (6). There are a little confusion in the pin number in Nano ESP. The numbers are different from the one showing in the board.

#include "HX711.h"

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 5;
const int LOADCELL_SCK_PIN = 6;

HX711 scale;

void setup() {
  Serial.begin(57600);

  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

}

void loop() {

  if (scale.is_ready()) {
    long reading = scale.read();
    Serial.print("HX711 reading: ");
    Serial.println(reading);
  } else {
    Serial.println("HX711 not found.");
  }

  delay(1000);
  
}

You can use D2 and D3 in the code.

However if it is still reading 0 then either your scale is bad or it's not connected correctly.
Do you have a datasheet for the scale?

what is data sheet for the scale?
But if scale is bad or connect it wrong, it shouldn't work on UNO. And I just find something there is different in the speed of UNO and ESP32 which might related, but I didn't get it?

You are correct.
Then the only difference is that the Uno is 5V and the ESP is 3.3V and there is nothing in the M5 stack documentation that says it will work at 3.3V

they are.... they are compatible with 2.6-5.5V

This one will work with 3.3V DAT and CLK signals
You connect Vcc to 5V and Vdd to 3.3V

I wonder which choice you made here --

That's the data sheet for the HX711 part. The M5 stack module makes no claims about 3.3V.
The exitation voltage for the loadcell may not be high enough when that module is used with 3.3V

I have the espressif ESP32 core installed which includes the Arduino Nano ESP32 board and it does not have those options. It works with either the GPIO numbers or the Dn and An designations.