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.
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());
}
}