Hi all,
I have 4 half bridge load cells (See attached to see a picture of one), a HX711 and an Ardunio and I want to make a weighing scales (it will update a google sheet with my weight as I'm planning on losing a few pounds :))
I have done a fair amount of research (as my electrical knowledge is next to nothing at this point) and I think i want a to make a Wheatstone bridge. So I've wired them as the attached schematic (sorry about the crude use of MS paint).
I've checked the resistance coming out of the cells with no load and so I know its the red ones that need to be excited (is that the right word?).
I then upload the code below having installed the relevant library (GitHub - bogde/HX711: An Arduino library to interface the Avia Semiconductor HX711 24-Bit Analog-to-Digital Converter (ADC) for Weight Scales.). The print out from the serial monitor is increasing with no weight on it and also the read out is negative. I ignored this as I've read there is some sliding issue. and maybe once calibrated it would go away.
So I calibrated using a 3kg weight but the continuous increase continues. Any advice as to why this might be happening? Anyone had any experiences of using these load cells and can shed some light on what worked for them?
I've checked the voltage coming out of the Ardunio and it is a steady 4.8v.
Possible causes I can think of;
-
Faulty load cells, is there any standard test i can run on the load cells to determine if they are functioning as they should
-
Faulty wiring, at the moment I've just twisted the wires between load cells together as I will solder once I know its working and I don't have to take them apart again.
-
Faulty HX711, again is there any standard tests I can run to see if this isn't working as it should.
-
Faulty code, maybe the library isn't good, but others seemed to have used it and be fine.
On a Slightly different note. At the moment I've got them lying on chipboard and then putting another piece of chipboard on top. The cells have 2 rivots on the bottom which make them unstable, would this be causing measurement errors when calibrating? Hows best to mount them in place?
Any help would be greatly appreciated. I thought this project would be relatively simple and its really annoying that it is not working! Also I can't start dieting without a good spreadsheet to show me precisely my progress (defo not procrastination :D) .
Thanks,
Ben
Code:
#include "HX711.h"
HX711 scale;
void setup() {
Serial.begin(38400);
Serial.println("HX711 Demo");
Serial.println("Initializing the scale");
// parameter "gain" is ommited; the default value 128 is used by the library
// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0
scale.begin(A1, A0);
Serial.print("Raw ave(20): \t\t");
Serial.println(scale.read_average(20)); // print the average of 20 readings from the ADC
// Scale factor:
scale.set_scale(19150.f); // this value is obtained by calibrating the scale with known weights; see the README for details
scale.tare(); // reset the scale to 0
Serial.println("\nAfter setting up the scale:");
Serial.print("Raw: \t\t\t");
Serial.println(scale.read()); // print a raw reading from the ADC
Serial.print("Raw ave(20): \t\t");
Serial.println(scale.read_average(20)); // print the average of 20 readings from the ADC
Serial.print("Raw ave(5) - tare: \t");
Serial.println(scale.get_value(5)); // print the average of 5 readings from the ADC minus the tare weight, set with tare()
Serial.print("Calibrated ave(5): \t");
Serial.println(scale.get_units(5), 1); // print the average of 5 readings from the ADC minus tare weight, divided
// by the SCALE parameter set with set_scale
Serial.println("\nReadings:");
}
void loop() {
int t, i, n, T;
double val, sum, sumsq, mean;
float stddev;
n = 20;
t = millis();
i = sum = sumsq = 0;
while (i<n) {
val = ((scale.read() - scale.get_offset()) / scale.get_scale());
sum += val;
sumsq += val * val;
i++;
}
t = millis() - t;
mean = sum / n;
stddev = sqrt(sumsq / n - mean * mean);
Serial.print("Mean, Std Dev of "); Serial.print(i); Serial.print(" readings:\t");
Serial.print(sum / n, 3); Serial.print("\t"); Serial.print(stddev, 3);
// Note: 2 sigma is 95% confidence, 3 sigma is 99.7%
Serial.print("\nTime taken:\t"); Serial.print(float(t)/1000, 3); Serial.println("Secs\n");
}