[esp32] random outputs with 4*50kg load cell & hx711

Im completely new to electronics so i thought maybe there is something obviously wrong that i am not aware of..

Im trying to build a scale with four 50 kg half-bridge load cells (so ~200 kg total) using esp32 & hx711 module & HX711_ADC example (code is down below to see my pins) & ive seen people on youtube doing same wiring i did & even same library, and it worked with them smoothly even with longer wires than mine (they all used arduino idk if it matters?)

This is my wiring, i even shortened them for less noise (they are not exactly all same length but based on googling it doesnt matter) I soldered the white & black together, used two different esp32 boards (i thought maybe it was the problem, i even used two different hx711 modules) i ordered new load cells but i dont have time to wait for them to arrive and put all the blame on the components when i dont think i tried everything to make it work

I used multimeter to make sure the red wire is the middle where black/white with red gives 1k ohm while black&white gives 2k ohm

I considered reversing the white wires so they be in place of the black ones and vice versa, but because I soldered them I cant desolder at the moment, still i dont think thats the issue..

I used same tutorial as this one (https://youtu.be/LIuf2egMioA?si=JyZUX49JpAa99yyG)

This is the code:


/*
   -------------------------------------------------------------------------------------
   HX711_ADC
   Arduino library for HX711 24-Bit Analog-to-Digital Converter for Weight Scales
   Olav Kallhovd sept2017
   -------------------------------------------------------------------------------------
*/

/*
   This example file shows how to calibrate the load cell and optionally store the calibration
   value in EEPROM, and also how to change the value manually.
   The result value can then later be included in your project sketch or fetched from EEPROM.

   To implement calibration in your project sketch the simplified procedure is as follow:
       LoadCell.tare();
       //place known mass
       LoadCell.refreshDataSet();
       float newCalibrationValue = LoadCell.getNewCalibration(known_mass);
*/

#include <HX711_ADC.h>
#if defined(ESP8266)|| defined(ESP32) || defined(AVR)
#include <EEPROM.h>
#endif

//pins:
const int HX711_dout = 33; //mcu > HX711 dout pin
const int HX711_sck = 25; //mcu > HX711 sck pin

//HX711 constructor:
HX711_ADC LoadCell(HX711_dout, HX711_sck);

const int calVal_eepromAdress = 0;
unsigned long t = 0;

void setup() {
  Serial.begin(115200); delay(10);
  Serial.println();
  Serial.println("Starting...");

  LoadCell.begin();
  //LoadCell.setReverseOutput(); //uncomment to turn a negative output value to positive
  unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
  boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
  LoadCell.start(stabilizingtime, _tare);
  if (LoadCell.getTareTimeoutFlag() || LoadCell.getSignalTimeoutFlag()) {
    Serial.println("Timeout, check MCU>HX711 wiring and pin designations");
    while (1);
  }
  else {
    LoadCell.setCalFactor(1.0); // user set calibration value (float), initial value 1.0 may be used for this sketch
    Serial.println("Startup is complete");
  }
  while (!LoadCell.update());
  calibrate(); //start calibration procedure
}

void loop() {
  static boolean newDataReady = 0;
  const int serialPrintInterval = 0; //increase value to slow down serial print activity

  // check for new data/start next conversion:
  if (LoadCell.update()) newDataReady = true;

  // get smoothed value from the dataset:
  if (newDataReady) {
    if (millis() > t + serialPrintInterval) {
      float i = LoadCell.getData();
      Serial.print("Load_cell output val: ");
      Serial.println(i);
      newDataReady = 0;
      t = millis();
    }
  }

  // receive command from serial terminal
  if (Serial.available() > 0) {
    char inByte = Serial.read();
    if (inByte == 't') LoadCell.tareNoDelay(); //tare
    else if (inByte == 'r') calibrate(); //calibrate
    else if (inByte == 'c') changeSavedCalFactor(); //edit calibration value manually
  }

  // check if last tare operation is complete
  if (LoadCell.getTareStatus() == true) {
    Serial.println("Tare complete");
  }

}

void calibrate() {
  Serial.println("***");
  Serial.println("Start calibration:");
  Serial.println("Place the load cell an a level stable surface.");
  Serial.println("Remove any load applied to the load cell.");
  Serial.println("Send 't' from serial monitor to set the tare offset.");

  boolean _resume = false;
  while (_resume == false) {
    LoadCell.update();
    if (Serial.available() > 0) {
      if (Serial.available() > 0) {
        char inByte = Serial.read();
        if (inByte == 't') LoadCell.tareNoDelay();
      }
    }
    if (LoadCell.getTareStatus() == true) {
      Serial.println("Tare complete");
      _resume = true;
    }
  }

  Serial.println("Now, place your known mass on the loadcell.");
  Serial.println("Then send the weight of this mass (i.e. 100.0) from serial monitor.");

  float known_mass = 0;
  _resume = false;
  while (_resume == false) {
    LoadCell.update();
    if (Serial.available() > 0) {
      known_mass = Serial.parseFloat();
      if (known_mass != 0) {
        Serial.print("Known mass is: ");
        Serial.println(known_mass);
        _resume = true;
      }
    }
  }

  LoadCell.refreshDataSet(); //refresh the dataset to be sure that the known mass is measured correct
  float newCalibrationValue = LoadCell.getNewCalibration(known_mass); //get the new calibration value

  Serial.print("New calibration value has been set to: ");
  Serial.print(newCalibrationValue);
  Serial.println(", use this as calibration value (calFactor) in your project sketch.");
  Serial.print("Save this value to EEPROM adress ");
  Serial.print(calVal_eepromAdress);
  Serial.println("? y/n");

  _resume = false;
  while (_resume == false) {
    if (Serial.available() > 0) {
      char inByte = Serial.read();
      if (inByte == 'y') {
#if defined(ESP8266)|| defined(ESP32)
        EEPROM.begin(512);
#endif
        EEPROM.put(calVal_eepromAdress, newCalibrationValue);
#if defined(ESP8266)|| defined(ESP32)
        EEPROM.commit();
#endif
        EEPROM.get(calVal_eepromAdress, newCalibrationValue);
        Serial.print("Value ");
        Serial.print(newCalibrationValue);
        Serial.print(" saved to EEPROM address: ");
        Serial.println(calVal_eepromAdress);
        _resume = true;

      }
      else if (inByte == 'n') {
        Serial.println("Value not saved to EEPROM");
        _resume = true;
      }
    }
  }

  Serial.println("End calibration");
  Serial.println("***");
  Serial.println("To re-calibrate, send 'r' from serial monitor.");
  Serial.println("For manual edit of the calibration value, send 'c' from serial monitor.");
  Serial.println("***");
}

void changeSavedCalFactor() {
  float oldCalibrationValue = LoadCell.getCalFactor();
  boolean _resume = false;
  Serial.println("***");
  Serial.print("Current value is: ");
  Serial.println(oldCalibrationValue);
  Serial.println("Now, send the new value from serial monitor, i.e. 696.0");
  float newCalibrationValue;
  while (_resume == false) {
    if (Serial.available() > 0) {
      newCalibrationValue = Serial.parseFloat();
      if (newCalibrationValue != 0) {
        Serial.print("New calibration value is: ");
        Serial.println(newCalibrationValue);
        LoadCell.setCalFactor(newCalibrationValue);
        _resume = true;
      }
    }
  }
  _resume = false;
  Serial.print("Save this value to EEPROM adress ");
  Serial.print(calVal_eepromAdress);
  Serial.println("? y/n");
  while (_resume == false) {
    if (Serial.available() > 0) {
      char inByte = Serial.read();
      if (inByte == 'y') {
#if defined(ESP8266)|| defined(ESP32)
        EEPROM.begin(512);
#endif
        EEPROM.put(calVal_eepromAdress, newCalibrationValue);
#if defined(ESP8266)|| defined(ESP32)
        EEPROM.commit();
#endif
        EEPROM.get(calVal_eepromAdress, newCalibrationValue);
        Serial.print("Value ");
        Serial.print(newCalibrationValue);
        Serial.print(" saved to EEPROM address: ");
        Serial.println(calVal_eepromAdress);
        _resume = true;
      }
      else if (inByte == 'n') {
        Serial.println("Value not saved to EEPROM");
        _resume = true;
      }
    }
  }
  Serial.println("End change calibration value");
  Serial.println("***");
}

Welcome to the forum

What voltage does the HX711 require and how is it powered in your project noting that the ESP32 is a 3.3V device

i just uploaded a pic of the hx711 i use, but i think it works with esp32 since ive seen it working with other people online

I power my esp 32D via type c from my laptop

(post deleted by author)

you don't appear to have stated what problems you are getting? e.g. incorrect output for a given load, noisy output, etc

maybe worth trying a different library, e.g. https://github.com/RobTillaart/HX711

don't upload photos of screen output they waste space, are difficult to read and cannot be copied- copy the text and paste using < code/ >

upload a schematic of your wiring?

I did mention it gives me random outputs, the loadcell doesnt seem to respond at all

I dont have a schematic but i did upload a photo of my wirings,

Hx711 pins:
Vcc > the esp32 vcc
Gnd > gnd
Dt > gpio 33
Sck > gpio 25

Powered via type c to my laptop

The rest are just like the photo i uploaded ( E+, E-, A+, A-)

I did mention it gives me random outputs, the loadcell doesnt seem to respond at all

I dont have a schematic but i did upload a photo of my wirings,

Hx711 pins:
Vcc > the esp32 vcc
Gnd > gnd
Dt > gpio 33
Sck > gpio 25

Powered via type c to my laptop

The rest are just like the photo i uploaded ( E+, E-, A+, A-)

Your two or more topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

Is it ok if i deleted the post and then repost it?

Once the topic has replies you cannot delete it. If you wanted the topic moved to a new forum category then you could have flagged it and asked a moderator to move it

DRAW a picture of all the wires and where they connect. Now take a picture, make sure it is very easy to read. Everything yiou have posted so far is not usable.
For a scale the concept of what was expected vs what actually happens is very easy. Tell us what weight you placed on the load cell, and what your code displays.
It would be helpful to know you did a calibration run and tared the scale before hand.
NOTE a 50gm weight will not create a reading of 50, it could be 1842 or many other values which is why calibration is mandatory.
The library HX711 by Rob Tillaart is what I used and has 16 sample sketches including calibration and full functioning scales (2 types)

Start trouble shooting by disconnecting the HX711 module and measure the resistance between E- and GND of the module on opposite sides of the board.
You should measure close to zero ohms.
There is (was) a batch of boards out there without a ground plane, that severed that link.
Report back.
Leo..

But you substituted a 5volt-logic board for a 3.3volt-logic board.

The Hx711 board you have is 5volt-only.

  1. you should have used a Sparkfun HX711 board, which is designed for both logics.

or

  1. you can power the board with 5volt, from the 5volt/USB pin of the ESP32
    and
    use a voltage divider on the data out pin, to drop the 5volt data signal to a safe 3.3volt for the ESP: 1k resistor between Dout and ESP pin, 2k2 resistor between ESP pin and ESP ground.
    Don't worry about the CLK pin of the HX711. It's an input pin.

If you have done it all correctly, then you should measure between 4.25 and 4.30volt exactly! between the E+ and E- pins of the HX711.
Leo..

But i did I look up the XFW HX711 module datasheet and it should handle 3.3V! & I’ve seen people who have had the sensor work well with them while using esp32

I just disconnected the hx711 and used the multimeter

E- with gnd gives 0 ohm indeed! What should i do next?

But i did I look up the XFW HX711 module datasheet and it should handle 3.3V! & I’ve seen people who have had the sensor work well with them while using esp32

It can, but the built-in 4.3volt analogue excitation voltage regulator on that board won't work. Because it needs at least 4.6volt to do what it's designed for.
If you power the board with 3.3volt, then you have a lower and more noisy excitation voltage, which could infliuence stability.
Note that this board has two supply pins, a 5volt VCC (analogue) and a 3.3volt VDD (digital) pin.

See post#14, point#2 how to safely use your current 5volt-only board.
Leo..

I tried to place different weights, 200 grams and even 50 kg, and each time it gave me random outputs, i used same library/ steps as this video (https://youtu.be/LIuf2egMioA?si=JyZUX49JpAa99yyG)

This is my drawing, does it help?

Hmm, I unfortunately dont have a voltage divider or the SparkFun module.. Does this mean im at a dead end?

Any resistors in your parts box?