ESP32 Strain Gauge Project

I am looking at making a strain gauge with an ESP 32, Wheaton stone bridge made up off 121 ohm resistors, a 121 ohm strain gauge and HX711 amplifier. When I upload my code I get sporadic values or values the will steadily increase or decrease. I have included my code and some wiring diagrams:

#include "HX711.h"
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 18; // Data pin
const int LOADCELL_SCK_PIN = 19; // Clock pin

HX711 scale;

// OLED display configuration
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET    -1
#define SCREEN_ADDRESS 0x3C  // I2C address of the OLED display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
  // Start serial communication for debugging
  Serial.begin(9600);
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

  // Initialize OLED display
  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }

  display.display();  // Clear the buffer
  delay(2000);  // Pause for 2 seconds
  
  // Tare the scale to zero it out
  Serial.println("Taring the scale. Please ensure no weight is applied.");
  delay(2000); // Wait for stabilization
  scale.tare();
  Serial.println("Taring complete.");

  // Set scale calibration factor
  // Replace with the calibration factor determined experimentally
  scale.set_scale(2280.0); // Example calibration factor
}

void loop() {
  if (scale.is_ready()) {
    // Read the weight or force
    float weight = scale.get_units(3); // Average of 3 readings

    // Display on OLED
    display.clearDisplay();
    display.setTextSize(1);      
    display.setTextColor(SSD1306_WHITE);  
    display.setCursor(0, 0);
    display.print("Measured weight/force: ");
    display.print(weight);
    display.println(" units");  // Replace "units" with "grams" or "kg" after calibration

    display.display();  // Show the updated display

    // Display on Serial Monitor
    Serial.print("Measured weight/force: ");
    Serial.print(weight);
    Serial.println(" units");  // Replace "units" with "grams" or "kg" after calibration

  } else {
    Serial.println("HX711 not found. Check connections.");
  }

  delay(500); // Delay for readability
}



How sporadic? Within accuracy and drift specs for the unknown gauge?

That is normal for a set-up that use long wires, solderless breadboards and cheap gauges.

I have included a photo of my serial monitor and the strain gauge data sheet. The values hover around zero, but after a minute or two, they steadily increase.


Is the strain gauge mounted?

Replace the image of the serial monitor data with text of the data in a code block.

Yes it is

The three resistors and the guage are all sensitive to changes in temperature, so that is why you have the drift. As previously mentioned, your set-up just makes things worse.

Do you have any recommendation how to reduce the drift and noise in the system

If you are trying to make precision measurements, then use a dummy gauge to compensate for the strain gauge temperature drift and use low temperature coefficient precision resistors.

If you are just trying to see if something is bending, then just take zero strain measurements as often as you can, average them and subtract that from you strain measurement.

In either case, don't use a solderless breadboard and keep all wires between the gauge and amplifier as short as possible.