i have a bunch of ds18b20 sensors attached to my raspberry that read various temperatures on my hydronic system and the room temperature ...
the problem i that when put together, to read the same temperature, the deviation of readings is high from 1 sensor to another. i try to do a calibration like in this site https://www.instructables.com/Calibrati ... duino-UNO/.
the only way i could do this was to create a virtual temperature sensor that will display the calculated temperature from this script:
Code: Select all
return {
on = {
devices = { 'EXTERIOR_raw' } -- the physical temperature sensore
},
execute = function(dz, device)
-- Calibration values
local rawHigh = 97.3 -- Raw temperature read at the boiling point of water
local rawLow = -0.5 -- Raw temperature read in the ice bath
local rawRange = rawHigh - rawLow
local referenceHigh = 99.2 -- Temperature for the boiling point of water at atmospheric pressure
local referenceLow = 0 -- Temperature for the Triple-point bath
local referenceRange = referenceHigh - referenceLow
-- Function to perform temperature correction and rounding
local function correctTemperature(inTemp)
local corrected = (((inTemp - rawLow) * referenceRange) / rawRange) + referenceLow
return math.floor(corrected * 10 + 0.5) / 10 -- Round to 1 decimal place
end
-- Updating the virtual sensor with the calculated value
if (device.name == 'EXTERIOR_raw') then
local inTemp = device.temperature
local correctedTemp = correctTemperature(inTemp)
dz.devices('EXTERIOR').updateTemperature(correctedTemp)
end
end
}
the problem is i need to do this for every sensor i have. and are couple of them (7 for the moment and more are to come) witch lead to a lot of scripts and a lot of new sensors to display.
is there a simpler way to use this type of calibration? some type of advanced calibration directly on the physical sensor?