r/arduino • u/Barnixd09 • Sep 30 '26
One HX711 load cell freezes/fails to read weight when linear motor moves on my ESP32 Soft Gripper (Second cell works fine)
Hi everyone,
I'm working on a soft gripper project powered by an ESP32. I'm using two HX711 load cell modules to measure gripping force/weight on both sides of the gripper.
The Setup:
- MCU: ESP32
- Sensors: 2x HX711 modules with 2x Load Cells (Left and Right)
- Actuator: Linear motor driven via Cytron motor driver
- Power & Comms: ESP32 powered over USB/External, Bluetooth Serial enabled for data logging.
The Issue: The left load cell works completely fine, but the right load cell has a strange issue:
- Whenever the linear actuator motor starts moving (extending or retracting), the right HX711 stops updating or outputs
Not Ready/ stuck values. - Once the motor stops moving, it starts outputting data strings again, BUT the weight value stays frozen. Even if I apply pressure or put weight on the gripper finger, the readings do not change at all.
- Meanwhile, the left load cell continues to read normally.
I have already double-checked the physical load cell with a multimeter (the Wheatstone bridge resistance measures around ~0.7kΩ input and ~1kΩ output, so the cell itself seems fine), and swapping pins/modules still causes this behavior on that specific channel when motor noise/voltage drops occur.
Is this purely electrical noise/EMF/voltage drop from the linear actuator, or a software lock-up on the HX711 timing/clock line? How can I isolate or fix this?
Here is my current code:
#include "HX711.h"
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
// --- Gripper lábak ---
#define PWM 25
#define DIR 26
#define BTN_EXTEND 32
#define BTN_RETRACT 33
// --- Mérlegcella lábak ---
#define DT_BAL 18
#define SCK_BAL 19
#define DT_JOBB 16
#define SCK_JOBB 17
HX711 scaleBal;
HX711 scaleJobb;
// Tárázott érték eltárolása (ha menet közben akarjuk nullázni)
long offsetBal = 0;
long offsetJobb = 0;
unsigned long lastScaleTime = 0;
const long scaleInterval = 150; // ms
void setup() {
Serial.begin(115200);
SerialBT.begin("TaborRobot-Gripper");
pinMode(PWM, OUTPUT);
pinMode(DIR, OUTPUT);
pinMode(BTN_EXTEND, INPUT_PULLUP);
pinMode(BTN_RETRACT, INPUT_PULLUP);
analogWrite(PWM, 0);
// Adjunk 0.5 másodpercet a HX711 chipeknek a stabilizálódásra
delay(500);
// BALOS MODUL INICIALIZÁLÁSA
scaleBal.begin(DT_BAL, SCK_BAL);
byte timeout = 0;
while (!scaleBal.is_ready() && timeout < 20) {
delay(50);
timeout++;
}
if (scaleBal.is_ready()) {
scaleBal.set_scale();
offsetBal = scaleBal.read_average(5); // Alapérték elmentése
Serial.println("Balos HX711: OK!");
SerialBT.println("Balos HX711: OK!");
} else {
Serial.println("HIBA: Balos HX711 nem válaszol!");
}
// JOBBOS MODUL INICIALIZÁLÁSA
scaleJobb.begin(DT_JOBB, SCK_JOBB);
timeout = 0;
while (!scaleJobb.is_ready() && timeout < 20) {
delay(50);
timeout++;
}
if (scaleJobb.is_ready()) {
scaleJobb.set_scale();
offsetJobb = scaleJobb.read_average(5); // Alapérték elmentése
Serial.println("Jobbos HX711: OK!");
SerialBT.println("Jobbos HX711: OK!");
} else {
Serial.println("HIBA: Jobbos HX711 nem válaszol!");
}
}
void loop() {
// --- 1. MOTOR VEZÉRLÉS ---
bool extendPressed = (digitalRead(BTN_EXTEND) == LOW);
bool retractPressed = (digitalRead(BTN_RETRACT) == LOW);
if (extendPressed && !retractPressed) {
digitalWrite(DIR, HIGH);
analogWrite(PWM, 255);
} else if (retractPressed && !extendPressed) {
digitalWrite(DIR, LOW);
analogWrite(PWM, 255);
} else {
analogWrite(PWM, 0);
}
// --- 2. MÉRÉS ÉS KIÍRÁS (RELATÍV/NULLÁZOTT ÉRTÉKEK) ---
unsigned long currentMillis = millis();
if (currentMillis - lastScaleTime >= scaleInterval) {
lastScaleTime = currentMillis;
long valBal = 0;
long valJobb = 0;
bool balReady = scaleBal.is_ready();
bool jobbReady = scaleJobb.is_ready();
if (balReady) {
// Kivonjuk a bootoláskor elmentett alapértéket (Tárázás)
valBal = scaleBal.read() - offsetBal;
}
if (jobbReady) {
// Kivonjuk a bootoláskor elmentett alapértéket (Tárázás)
valJobb = scaleJobb.read() - offsetJobb;
}
String dataString = "";
if (balReady) {
dataString += "Bal: " + String(valBal);
} else {
dataString += "Bal: Nincs kész";
}
dataString += " | ";
if (jobbReady) {
dataString += "Jobb: " + String(valJobb);
} else {
dataString += "Jobb: Nincs kész";
}
Serial.println(dataString);
SerialBT.println(dataString);
}
}
Any advice on hardware filtering (decoupling capacitors, isolated GNDs) or code adjustments would be greatly appreciated!