Calibrating the scale using exercise weights

Dog Weight Scale Part 4: Calibration and its Difficulties

In my previous post I finished assembling the Dog Bed Weight Scale, at least enough to allow testing it. In this post, I relate how I calibrated and tested it.

Using the Bogde HX711 Load Cell Amplifier library and examples, and the Sparkfun HX711 Example Arduino Sketches, I quickly wrote a little Sketch to output the raw value from the scale (SCALE = 1.0 and OFFSET = 0L).  The library made talking to the HX711 trivial.

The HX711 library assumes a linear relationship of load sensor output to weight.  Using small exercise weights, I measured the average output for 5, 10, 15, 20, and 25 pounds. I’m using Pounds for the moment for my convenience; once all this works, I’ll switch to kg.

X Weight (lbs)Y Average reading
Weight vs. HX711 Output Value

Now for a little Algebra: the formula for a line is Y = MX + B, where M is the slope of the line and B is the intercept.  Put in terms of the HX711 library, M is the SCALE and B is the OFFSET.   Given two (X, Y) pairs, you can calculate the slope and intercept of the line:

M = (Y2 – Y1) / (X2 – X1)

B = Y – MX                      (using the M value calculated above)

I calculated M and B using the 5 and 10 lbs weights, the 10 and 15 lbs weights, etc.  I then averaged the M values and the B values, resulting in

M = 10831.330         B = 260248.752

So I plugged in the M value via hx711.set_scale() and the B value (rounded to an integer) via hx711.set_offset(). Impressively, my scale now reported in lbs; math works!

Next I wanted to check how linear the output was.

Because each sensor can take up to 50kg (about 110 lbs) and there are 4 sensors, the sensors (but not the plywood) can take a combined weight of 200kg (about 440 lbs).

I weighed myself on my bathroom scale (264.1 lbs) and stood in the center of my new Dog Scale (266.063 lbs).  If the scale were perfectly linear, and the calibration numbers were exactly correct, I should have weighed the same on the Dog scale as on the bathroom scale.  Instead, the Dog Scale weighed 0.7% high relative to the bathroom scale.  For our 44 lb dog, Pippa, that percentage would be about 1/3 lb (or about 150g), which isn’t too bad. By the way, I’m assuming the bathroom scale has no error, which of course isn’t true.

Another measurement I made was short-term noise.  I made 24 measurements of a zero weight and calculated the Standard Deviation.  3 Standard Deviations covers a good amount of the range of noise; for this measurement 3 Standard Deviations = 0.007 lbs.  That tells me that most of the time a single measurement will be +/-0.007 lbs from the average, which means that I don’t really have to average multiple readings to get a good measure (but I probably will anyway, just to be safe).

I also measured creep: the slow change in the reading of a constant weight over a long time. I don’t know much about creep, but Nate Seidle’s Beehive scale article talks about it in detail.  To measure it, I placed 25 lbs on the scale and left it for 2 days.  What began as 25.122 lbs ended up reading as 24.917 lbs, a creep of about 0.8%, with no sign of stopping.  So I should expect some creep during the 8-12 hours that Pippa might spend in bed.

Unlike a beehive, Pippa will shift about in her bed, sometimes lying near one edge, sometimes near another edge, and sometimes in the center.  To test how matched the load sensors are, I measured a 15 lb weight in the center of the scale and directly over each of the 4 sensors.

Measured weight of a 15 lb weight at the center and over each sensor

So Pippa’s measured weight could vary from reality by as much as 0.7 lbs depending only on her position in her bed.  That’s too much for what I want to do.

Unfortunately, I can’t correct for mismatch in the individual load sensors’ response curves.  The 4 sensors are wired together in one Wheatstone bridge, and calibration happens on the amplified output of that bridge.

I want to redesign the scale to have each load sensor connected to a separate amplifier and separate pins on the Arduino, so I can get a more accurate measure of Pippa’s weight as she shifts around on her bed.  Interestingly, that change will also enable the Arduino to calculate where Pippa is lying in the bed – that is, where her center of gravity is – which might be interesting information.

In my next post, I find the center of gravity of the top plywood piece, and attempt a way to mount the Load Sensors to the bottom plywood piece.