Close

Temperature Correction

A project log for LoRaWAN Birdhouse

A Birdhouse with Internet

jan-schlieperJan Schlieper 10/24/2023 at 05:070 Comments

I finally got around to sorting the temperature calibration of the scale. The scale now has four values used for calculating the weight:

The first two are the ADC offset and factor. These are set when the scale gets calibrated for the first time. Both values are used in the HX711 library to calculate the weight. The scale also no longer does a tare (the results of a tare are sometimes very "dynamic"). The next two values are the offset and coefficient for the temperature correction. Weight and temperature correction get calculated using the following formulae:

weight = (adc_steps_measured - scaleOffset) / scaleFactor
correction = (temperatureCoefficient * current_temperature) + temperatureOffset

To determine the values for the temperature correction I created a gnuplot script which does all the required math. As input the script needs a couple of days/weeks worth of zero weight values measured by the scale at different temperatures. During that time the little bird is allowed to sleep in the birdhouse but not build a nest (the script needs values without any weight on the scale). The script shows the zero weight values taken at different temperatures in the first plot (please see the image below). Gnuplot then fits a linear equation through those measurement points using the Marquardt-Levenberg algorithm. The second plot then shows the offset and coefficient just calculated applied to the input data. If the result is satisfactory the temperature offset and coefficient can then be sent via LoRaWAN downlinks to the birdhouse.

Discussions