This is how to scale ("calibrate") the load cells into usable units. This same method can be used for all sensors.

Theory

In general, we assume the output is linear and use linear scaling based on the formula for a straight line, Y=mX+b Where:

```Y is the desired output in engineering units (pounds, kilograms, stones, etc.)
m is the slope
X is the output from the Analog to Digital Converter (ADC) in counts
b is the intercept.
```

Two known points are required and two equations are solved simultaneously Usually one of the known points is Zero, and the other is a known weight. Zero is used as it is convenient and it simplifies the math. The other point is arbitrary but ideally is near the other end, near full scale (200 KG or 440 lbs if four 50KG load cells are used. (I usually just use my weight, 150 lbs).

Proceedure

Method 1 using algebra

With nothing on the scale, read the output of the HX711 ADC by running hx711:

```sudo hx711
```

It will read the HX711 chip 64 times, and display the output of the ADC in binary and decimal with one reading per line and the average of the 64 readings at the end:

```0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 0 1 1 n:    1546646     -
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 n:    1546794     -
. . .        . . .       . . .      . . .        . . .

0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 1 1 0 1 0 1 0 0 0 n:    1547088     -
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 0 n:    1546168     -
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 0 0 0 1 1 n:    1546118     -
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 1 1 1 n:    1546014     -
1546640
```

The numbers may be negative, it doesn't matter. Now put a know weight on the scale and run hx711 again. The numbers should be significantly different (much bigger).

Now you have two know points and can solve Y= mX + b for m and b.

Example

1. With nothing on the scale, read the output of the HX711 ADC by running hx711. In this case, the average was -345252.
2. Weigh yourself (235.2 lbs).
3. Then run sudo hx711 again while standing on the scale. The average was 1160807.
4. Now solve the two equations simultaneously:
```    0 = m * -345252 + b  [1]
235.2 = m * 1160807 + b  [2]
```

Rearrange equation 1 by subtracting b from both sides:

```   -b = m * -345252
```

Rearrange equation 1 by dividing both sides by -345252:

```   -b / -345252 = m  or
m= b/345252
```

Now substitute m in equation 2 and solve for b:

```234.2 = (b/345252) * 1160807  + b

234.2/b  = (1/345252) * 1160807 + 1

234.2/b = 1160807/345252 + 1

234.2/b = 34.6222157857

b = 234.2/34.6222157857
```
```b = 6.76444284934
```

Now solve for m by plugging b into equation 1 or 2. It doesn't matter, but the math is easier if you use equation 2:

```    0 = m * -345252 + 6.76444284934

-6.76444284934 = m * -345252

-6.76444284934/-345252  = m

.0000195927694824= m
```

Method 2 using graphical methods

The slope (m) is defined as rise over run (rise/run or rise divided by run). Using the numbers from the above example, the rise is the difference in the engineering units (the vertical or Y axis

```235.2 - 0 = 235.2
```

The run is the difference in the counts (horizontal or X axis:

```    1160807 - -345252 = 1506059
```

Now to calculate the slope by dividing rise by run:

```  m = 235.2/1506059
m = 0.000156169180623
```

Hivetool version 0.7.3 and greater

Hivetool version 0.7.2 and less