HX711 Calibration Factor Issue

Hi All,

I am working on a HX711 scale project and would appreciate some help in figuring out an issue with the HX711 calibration factor in the library I’m using…

I have a script that uses the common HX711 library and load cell hardware to weigh a keg of beer. I went through the standard calibration process (with the scale hooked up to my Arduino) and determined a calibration factor that works well (-8980). This was verified with a 10# weight on the scale and is repeatable. However, when I try to use that same calibration factor in my Particle script, it does not return the same results as when run in the Arduino calibration code. With nothing on the scale it reads 14.5 pounds and with the 10# weight on it reads 21 pounds. I’ve tried several times to get it to recognize correctly but haven’t had any success.

On the other hand, if I just use the raw load cell/HX711 values (without inputting a calibration factor) I can set a high value (full keg) and low value (empty keg) and then compute how full the keg is as a percentage, and this works well.

I would like to get the calibration factor working so I can set high and low keg values in pounds instead of raw data values.

Why would the calibration factor from Arduino not work in the Particle code? Isn’t the calibration value a factor of the scale hardware and setup/mounting itself? The code shouldn’t effect the accuracy of the calibration factor, right? Is there a gain or other setting that I am missing?

Please see relevant code below and let me know if you have any suggestions. Thanks!

// This #include statement was automatically added by the Particle IDE.
#include <HX711ADC.h> //version 0.0.2

//User-inputs to calibrate the keg weight sensors 
double Keg1_Empty=8.5; 
double Keg1_Full=48.5; 

#define Keg1_SCK A1
#define Keg1_DT A0

int Keg1;

double Keg1_Current_Reading;

HX711ADC scale1(Keg1_DT,Keg1_SCK);

void setup() {

//Particle.variable("Status", Status);
Particle.variable("Keg1", Keg1_Current_Reading);

scale1.set_scale(-8980);

scale1.power_up();
}

void loop() {

//Read current values
Keg1_Current_Reading = scale1.get_units(10);

//Convert Keg Readings into % Full values
Keg1=(Keg1_Current_Reading/Keg1_Full*100);
}

Hi @JakeOz -

Welcome to Particle forum!!

Hmmm ok, I see the sensor is hooked up to the A1 pin? Remember Particle device Analogue pins will map input voltages between 0V and 3.3V to integer values ranging from 0-4095 and not 0-1024 like Arduino.

My suspicion is you might have to recalibrate and get a calibration factor suitable for this. Also remember to check whether a pull-up or pull down resistor is needed on the A1 pin in connection with the HX711. I will also check again, used them some time ago.

Hope this helps :wink:
Friedl.

Hi @JakeOz

Have a look here. Seems no additional resistor is required.

Regards,
Friedl.

Which Particle device are you using?
How are you powering the device?
How does your wiring look?
Are you powering the scales with 5V in both instances?
The HX711 Particle library also provides functions to calculate the calibration factor. Why not just use its results?
Also the scale factor is not the only thing you need to consider. You also need to tare the scales.

@friedl_1977, the HX711 does communicate digitally with the controller, the ADCs on the controller are not used for the measurement. The A# pins are used as mere digital GPIOs for the communication with the sensor.

2 Likes

@ScruffR

My sincerest apologies :relaxed:

I will hook up two today with a default sketch and see what I can find, I am sure I have an old Uno lying around that I can dust off. I may have it confused with the thé ACS sensors :see_no_evil:

1 Like

HI @JakeOz -

Ok so… @ScruffR was correct, again :wink:

See there serial monitor results. On the left Serial Monitor via Workbench on Photon and the right, Arduino Uno IDE. As you can see Calibration factor is the same.

Make sure of:

  1. Powering HX711 in both cases from 3V3 pin (or of you used the 5V pin on Arduino, you need to supply 5V here as well. As Photon does not have a 5V pin, you will have to use a step-up voltage converter I would guess.

  2. You are supplying power in the same manner

  3. Your wiring form the load cell to the device is still the same length as it used to be. As they work with resistance, the smallest change can have an affect,

  4. You are indeed using the same load cell… each one will have to be calibrated individually. This can very easily be done using the sample sketch from Sparkfun

Hope this resolves the issue!! Sorry it took a while, I had to dismantle another project to get the load cells :slight_smile:

Regards, Friedl.

1 Like

When powering the Photon via USB you will have 5V on Vin (available as output voltage).

When powering the Photon via 3v3 or any other device via LiPo that is not an option - that’s why I asked for actual controller used and also how the system is powered :wink:

1 Like

Damn… of course yes!! I will blame too much Calculus and Chem for these oversights. Time to spend more time tinkering again :rofl:

1 Like

@friedl_1977 @ScruffR
Thank you both for taking the time to reply.

I had taken some photos of my setup to share and as I was about to upload them I reread ScruffR’s post and realized my foolish mistake: I had not included the scale.tare function in the original code I was trying to get to work.

It is included in the HX711 calibration code which is why things always worked well on the Arduino.

That seems to be what was causing my problem as the calibration factor now appears to be accurate in the Particle code as well.

Crisis averted, appreciate the help!

Cheers!

2 Likes

Hi @JakeOz -

Glad you found the problem!! Would you mind marking it as solved please? :wink:

Regards,
Friedl