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:
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:
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;
}
}