1
\$\begingroup\$

I'm using an ESP32-S3-WROOM-1U and a four load cells, connected in a full Wheatstone bridge to an HX711 to read the weight of an object.

I recorded data on 6 different occasions with the load cells loaded the exact same way. There was no physical movement between each of the runs and they were located indoors, here on my desk (i.e. temperature changes should be minimal).

However, I'm wondering why I see jumps in the data as I do. At the start of each recording, I tared the scale to start at 0. These are the recorded measurements for each run:

   
Run #1: enter image description here Run #2: enter image description here
Run #3: enter image description here Run #4: enter image description here
Run #5: enter image description here Run #6: enter image description here

What's the reason for the curves to look like this when the load on them has not changed, and how can it be fixed so that the result is a relatively flat line (I know that it will be bumpy w/o filtering but not to the degree I see here!) and be reproducible between different runs?

The four load cells are connected with a load cell combinator like:

enter image description here

The code I used to record the data is the following (compiled and loaded using Arduino IDE 2.2.1):

/*
 Example using the SparkFun HX711 breakout board with a scale
 By: Nathan Seidle
 SparkFun Electronics
 Date: November 19th, 2014
 License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
 
 This is the calibration sketch. Use it to determine the calibration_factor that the main example uses. It also
 outputs the zero_factor useful for projects that have a permanent mass on the scale in between power cycles.
 
 Setup your scale and start the sketch WITHOUT a weight on the scale
 Once readings are displayed place the weight on the scale
 Press +/- or a/z to adjust the calibration_factor until the output readings match the known weight
 Use this calibration_factor on the example sketch
 
 This example assumes pounds (lbs). If you prefer kilograms, change the Serial.print(" lbs"); line to kg. The
 calibration factor will be significantly different but it will be linearly related to lbs (1 lbs = 0.453592 kg).
 
 Your calibration factor may be very positive or very negative. It all depends on the setup of your scale system
 and the direction the sensors deflect from zero state

 This example code uses bogde's excellent library: https://github.com/bogde/HX711
 bogde's library is released under a GNU GENERAL PUBLIC LICENSE

 Arduino pin 2 -> HX711 CLK
 3 -> DOUT
 5V -> VCC
 GND -> GND
 
 Most any pin on the Arduino Uno will be compatible with DOUT/CLK.
 
 The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.
 
*/

#include "HX711.h" //This library can be obtained here http://librarymanager/All#Avia_HX711

#define LOADCELL_DOUT_PIN  37
#define LOADCELL_SCK_PIN  38
float cat_weight_minimum = 2;


HX711 scale;

float calibration_factor = 40560; //-7050 worked for my 440lb max scale setup.., 23750 for the 10kg version BS... 52460

void setup() {
  Serial.begin(115200);
  Serial.println("HX711 calibration sketch");
  Serial.println("Remove all weight from scale");
  Serial.println("After readings begin, place known weight on scale");
  Serial.println("Press + or a to increase calibration factor");
  Serial.println("Press - or z to decrease calibration factor");

  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale();
  scale.tare(); //Reset the scale to 0

  long zero_factor = scale.read_average(); //Get a baseline reading
  Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
  Serial.println(zero_factor);
}

void loop() {
  static int init = 0;
  static int i;

  scale.set_scale(calibration_factor); //Adjust to this calibration factor

  float lbs = scale.get_units(20); // Get weight in pounds
  float grams = lbs * 453.592; // Convert pounds to grams
  if (!init) {
    scale.tare();
    Serial.println("#, lbs, g, calib");
    init = 1;
  }
  Serial.print(i++);
  Serial.print(", ");
    
  //Serial.print("Reading: ");
  Serial.print(lbs, 2); // Display weight in pounds with two decimal places
  Serial.print(", ");

  //Serial.print(" (");
  Serial.print(grams, 0); // Display weight in grams with two decimal places
  Serial.print(" ,");

  //Serial.print(" Calibration Factor: ");
  Serial.print(calibration_factor);
  Serial.println();

  delay(2000); // Delay for 3 seconds before taking the next reading


  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == 't')
      scale.tare();
    if(temp == '+' || temp == 'z')
      calibration_factor += 10;
    if(temp == 'x')
      calibration_factor += 100;
     if(temp == 'c')
      calibration_factor += 1000;
    if(temp == 'm')
      calibration_factor -= 1000;
    if(temp == 'n')
      calibration_factor -= 100;
    else if(temp == '-' || temp == 'b')
      calibration_factor -= 10;

  }
}
\$\endgroup\$
3
  • \$\begingroup\$ It seems that only 2 wires of the cells are wired ? learn.sparkfun.com/tutorials/…? \$\endgroup\$
    – Antonio51
    Commented Nov 15, 2023 at 11:53
  • \$\begingroup\$ I'm not sure what you see, all three wires of each cell are hooked up to the combinator as shown in the above diagram. Is there a better way to connect them? \$\endgroup\$
    – stdcerr
    Commented Nov 16, 2023 at 2:30
  • 1
    \$\begingroup\$ You may have a general data transfer issue there. In Run 4 and 5 there are extended periods without data, the diagonal lines short before sample #300. \$\endgroup\$
    – Jens
    Commented Nov 16, 2023 at 22:56

1 Answer 1

3
\$\begingroup\$

It appears like one way to mitigate the huge fluctuations seen above, is to use full bridge load cells instead of half bridge sensors. The valueappears to be way more stable. I basically got rid of the load cell combinator and instead hooked the full bridge load cell directly to the HX711: Load cells seem to have standardized color codes for the wires and I connected them to the HX711 as follows:

load cell:    HX711
   red    ->  E-
   black  ->  E+
   white  ->  A-
   green  ->  A+

The results this generates is a lot better with noise in the +/-1g range, only which I can filter out with a simple low pass IIR filter like (SampleAvg * FILTER + SampleNew) / (FILTER + 1) Where FILTER is a number that ought to be chosen to match the specific application and SampleAvg is just as it says the result of the last filter calculation with the last result. This may create a curve like this: enter image description here with the FILTER value set to 5 where the blue line is the raw sensor input and the red line is the filtered output. This may need to be optimized on a per application basis.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.