Sensors after-party

Calibrating the senors

Posted by TheBrightKnight on December 26, 2022 · 4 mins read

Now that we can get sensor readings, I wanted to calibrate them so all of them will be aligned with each other.
For our application, we need a base measurementĀ that we know is accurate - DS18B20Ā + the snow in my garden to the rescue!

We know that the temperature of snow with a bit of water to fill in the air insideĀ will be 0 degreesĀ Celsius, and we know that the DS18B20 probe is waterproof;
You see where Iā€™m getting here?

  1. Take a cup, fill it with snow, or ice from your freezer, or a bit of your mother-in-lawā€™s soul, and top it with veryĀ littleĀ water just to fill in the gaps
  2. Lower down your DS18B20 probe into the cup
  3. Start the Python script from the previous post, and hope to read 0 degreesĀ from the sensor
  4. If the sensor shows for example 0.64 degrees, you know itā€™s off by +0.64, if it shows -0.32, you know itā€™s off byā€¦ -0.32

We have a base measurement!
Now in our code, in the DS18B20 section we should add the calibration offset that we measured, i.e:

ds18b20_temp = round(read_temp()+0.64,2) Ā 

Next part includes calibrating both temperatureĀ and humidityĀ readings for all the other sensors.
For that we will need:

  • Sealed box or jar
  • Sodium Chloride (which is just regular table salt, Iā€™m not trying to get you on the no-fly listĀ šŸ˜„), donā€™t try to be sophisticated with pink salt from Walhalla or some S*!#
  • Bit of water

The reason for the salt is that in a sealed container of moist salts, the air above the salts will reach a known relative humidity.
The relative humidity above the salt does depend slightly on the temperature - so the temperature readings will help us here as well.

See the below table for the known relative humidity at different temperatures.

Salt 15Ā°C 20Ā°C 25Ā°C 30Ā°C 35Ā°C
Sodium Chloride 75.61 75.47 75.29 75.09 74.87

And for the fun part:

  • Pour 1cm of salt (0.4 Inch in the wrongĀ metric) into the box
  • Add a little water to the box so that the salt is wet;Ā The goal is to end up with wet salt, not to totally dissolve the salt.
  • place the sensors inside the box -Ā DO NOT get the salt or salt solution on the sensor
  • Seal the boxĀ - Wait at least an hour (!)

Lets calibrate the temperatures first - our sensors are now in a controlled sealed environment, so they should all show the same readingsĀ +- minor errors.
OurĀ DS18B20 is already calibrated, so we should align all the other sensors to it, for example - if the DS18B20 shows 23.3 degrees, and the BMP280 shows 23.8, we know that itā€™s off by -0.5 degrees.
Do it for all the sensors until they are all show the same temperature (+-)
Now that we have the temperature, according to the table above we should also know the humidity, for example - if we have 20 degrees inside the box, the humidity needs to be around 75.47% - take that measurement and calibrate your humidity readings according to it.

Write down your calibrations, as we will use it in the future in our sensor configurations.

Kudos!
We are ready for the next step - moving to the Arduino.

See you on the next post;
~TheBrightKnight