Skip to content

calibrating

Steve Jarvis edited this page Aug 24, 2019 · 6 revisions

Using the lib here.

Calibrating

Created Saturday 26 January 2019

Run the below code. I didn't find the adjusters useful at all, moving by 1 and 10 is way too big and seems easier to just do the math than make them smaller increments and step through.

/* This is an example sketch on how to find correct calibration factor for your HX711:
   - Power up the scale and open Arduino serial terminal
   - After stabelizing and tare is complete, put a known weight on the load cell
   - Observe values on serial terminal
   - Adjust the calibration factor until output value is same as your known weight:
      - Sending 'l' from the serial terminal decrease factor by 1.0
      - Sending 'L' from the serial terminal decrease factor by 10.0
      - Sending 'h' from the serial terminal increase factor by 1.0
      - Sending 'H' from the serial terminal increase factor by 10.0
      - Sending 't' from the serial terminal call tare function
   - Observe and note the value of the new calibration factor
   - Use this new calibration factor in your sketch
*/

#include <HX711.h>

// Beetle pins we're using.
#define EXCIT_POS A0
#define EXCIT_NEG A1

long t;

HX711 load;

void setup() {
  Serial.begin(115200);
  load.begin(EXCIT_POS, EXCIT_NEG);
  load.set_scale();
  load.tare(50);
  Serial.println("Startup complete, ready to calibrate.");
}

void loop() {
  // Get current load
  float reading = load.get_units(10);
  float offset = load.get_offset();
  float scale = load.get_scale();
   
  Serial.print("Force output val: ");
  Serial.print(reading);
  Serial.print("Tare offset:      ");
  Serial.println(offset);
  Serial.print("Scale multiplier: ");
  Serial.println(scale);

  // Receive instructions from serial terminal
  if (Serial.available() > 0) {
    float i = 0.f;
    char inByte = Serial.read();
    if (inByte == 'l') i = -1.0;
    else if (inByte == 'L') i = -10.0;
    else if (inByte == 'h') i = 1.0;
    else if (inByte == 'H') i = 10.0;
    else if (inByte == 't') load.tare(50);
    if (i != 0) {
      load.set_scale(scale + i);
    }
  }

  delay(250);
}

Scale Multiplier

I hung nothing on the pedal (except the light rope used to hang other weights) and tared to get a tare offset of 275010. Then started hanging weights, it was already zero'd.

Don't worry about the multiplier or anything, just hang a known weight and record what the scale says. For example... Hanging 5kg we got about 114600. And at 15kg it read around 343300. Note these both varied by hundreds one second to the next, but those seemed to be roughly the median, watching numbers tick by.

For watts we actually need newtons, which are kg/m/s^2. With gravity, that's 9.8 newtons per kg.

So y = mx + b.

5kg (49 N)
5 * 9.8 = m * 114600 + 0
49 = m * 114600
49/114600 = m
0.00042757417 = m \

15kg 15 * 9.8 = m * 343300 + 0
147 = m * 343300
147 / 343300 = m
0.00042819691 = m \

So we'll go with a load multiplier of 0.0004278. The HX711 library divides by this multiplier, not multiplies, so we need to put it under 1.

1 / 0.0004278 = 2337.541

Scale Tare

Just tare the load cell and mark what offset it gets.

Gyro Tare

Same idea, run the programmed calibration and see what offset it comes up with.

Results

Bike Scale Mult Scale Offset Gyro Offset
Trek 1000 2337.541 243647 -39
Merckx -2719.66716169 -32000 3
Orbea -2491.63452396 3300 -50