0
\$\begingroup\$

I’m building a circuit with two load cells and I have some issues getting accurate measurements. At first I just soldered the load cells onto the load cell amplifier but as the connections seemed bad I added a wire to board terminal block to have a « cleaner » connection but that doesn’t seem to have changed anything. I built a custom PCB for the whole circuit as there is also a battery, on/off switch and an arduino. This is my first project, I’m fairly new to electronics. Please tell me if there is something I’m doing wrongly.

Schematic: board schematic

Board: board

Assembled device: Assembled device top Assembled device top closeup assembled device bottom

This is the code I ran to get the measurements:

#include <ArduinoBLE.h>
#include <HX711_ADC.h>
​
BLEService OneRM ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
BLEFloatCharacteristic OneRMCharacteristic("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", BLERead | BLENotify);
​
const int HX711_dout = 3;
const int HX711_sck = 2;
​
HX711_ADC LoadCell(HX711_dout, HX711_sck);
​
unsigned long t = 0;
​
void setup() {
  Serial.begin(57600);
  delay (10);
  Serial.println();
  Serial.println("Starting...");
​
  if (!BLE.begin()) {
    Serial.println("BLE Startup Failed.");
    while (1);
  } else {
    Serial.println("BLE Startup Worked.");
  }
​
  BLE.setLocalName("OneRM");
  BLE.setAdvertisedService(OneRM);
  OneRM.addCharacteristic(OneRMCharacteristic);
  BLE.addService(OneRM);
​
  BLE.advertise();
  Serial.println("Bluetooth device active, waiting for connections...");
​
  LoadCell.begin();
  float calibrationValue;
  calibrationValue = -50;
​
  unsigned long stabilizingtime = 2000;
  boolean _tare = true;
  LoadCell.start(stabilizingtime, _tare);
  if (LoadCell.getTareTimeoutFlag()) {
    Serial.println("Timeout, check MCU>HX711 wiring and pin designations");
    while (1);
  } else {
    LoadCell.setCalFactor(calibrationValue);
    Serial.println("Startup is complete");
  }
}
​
void loop() {
​
  static boolean newDataReady = 0;
  const int serialPrintInterval = 0;
​
  BLEDevice central = BLE.central();
​
  if (central) {
    Serial.print("Connected to central: ");
    Serial.println(central.address());
    while (central.connected()) {
      if (LoadCell.update()) newDataReady = true;
      if (newDataReady) {
        if (millis() > t + serialPrintInterval) {
          float i = LoadCell.getData();
          Serial.print("Load_cell output val: ");
          Serial.println(i);
          OneRMCharacteristic.writeValue(i);
          newDataReady = 0;
          t = millis();
        }
      }
​
      if (Serial.available() > 0) {
        char inByte = Serial.read();
        if (inByte == 't') LoadCell.tare();
      }
​
      if (LoadCell.getTareStatus() == true) {
        Serial.println("Tare complete");
      }
    }
​
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
  }
}
\$\endgroup\$
17
  • 1
    \$\begingroup\$ How have you determined that the measurements are not accurate? \$\endgroup\$
    – brhans
    Commented Mar 9, 2023 at 1:51
  • \$\begingroup\$ Connected to my computer, ran a load cell measuring program. And I then get random numbers that don’t really make sense when I interact with the sensors. I know sensors are accurate to about ~5% but the measurements are really completely wrong. \$\endgroup\$
    – tomcajot
    Commented Mar 9, 2023 at 3:04
  • \$\begingroup\$ What's a "load cell measuring program"? Is it sample code for your Nano? Are you using the HX711 library that Sparkfun provides? Can you edit your post to include the code? \$\endgroup\$
    – Matt S
    Commented Mar 9, 2023 at 3:12
  • 1
    \$\begingroup\$ How did you get your calibration factor? What's your expected data, and what are you actually receiving? \$\endgroup\$
    – Matt S
    Commented Mar 9, 2023 at 3:47
  • 1
    \$\begingroup\$ It seems that the main issue is that both load sensors weren't being pressed at the same time, I'll try to build a mechanical fixture for that and check the results I get back. Thank you for you time. \$\endgroup\$
    – tomcajot
    Commented Mar 11, 2023 at 5:26

0

Your Answer

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

Browse other questions tagged or ask your own question.