Hi,
just want to share quick tip how to add Temperature Offset and Humidity Offset to your Tasmota powered devices.
Why? because sometimes instalation of the sensor is influenced by some heat source, which needs to be adjusted or you simply want to calibrate two or more sensors to report same values.
Bosh library supports this feature as many others, unfortunately in Tasmota this is doable kind of weird way - by rules… which I dont like at all… so what we can do about it?
(I assume one can grab source, editor and is able to build *.bin at the end)
Let’s jump to some files …
sonoff/i18n.h
add (to line 230 for example)
#define D_CMND_TEMPADJUST "TempOffset"
#define D_CMND_HUMADJUST "HumOffset"
sonoff/support_commands.ino
add (to the const kTasmotaCommands after D_CMND_BUTTONDEBOUNCE “|” )
D_CMND_TEMPADJUST "|" D_CMND_HUMADJUST "|"
add (to the TasmotaCommand after &CmndButtonDebounce, )
&CmndTempAdjust, &CmndHumAdjust,
add (before void CmndButtonDebounce(void) )
void CmndHumAdjust(void)
{
Settings.hum_adjust = XdrvMailbox.payload;
Response_P(S_JSON_COMMAND_NVALUE, XdrvMailbox.command, Settings.hum_adjust);
}
void CmndTempAdjust(void)
{
Settings.temp_adjust = XdrvMailbox.payload;
Response_P(S_JSON_COMMAND_NVALUE, XdrvMailbox.command, Settings.temp_adjust);
}
sonoff/settings.h
add (to the end of the struct SYSCFG { )
float temp_adjust;
float hum_adjust;
and then to the module you are using (I’ve done it for BMx and DHT so:
sonoff/xsns_09_bmp.ino
change
dtostrfd((bmp_temperature), Settings.flag2.temperature_resolution, temperature);
to
dtostrfd((bmp_temperature + (Settings.temp_adjust / 10)), Settings.flag2.temperature_resolution, temperature);
and
dtostrfd((bmp_sensors[bmp_idx].bmp_humidity), Settings.flag2.humidity_resolution, humidity);
to
dtostrfd((bmp_sensors[bmp_idx].bmp_humidity + (Settings.hum_adjust / 10)), Settings.flag2.humidity_resolution, humidity);
sonoff/xsns_06_dht.ino
change
Dht[sensor].t = ConvertTemp(Dht[sensor].t);
Dht[sensor].h = ConvertHumidity(Dht[sensor].h);
to
Dht[sensor].t = ConvertTemp(Dht[sensor].t + (Settings.temp_adjust / 10));
Dht[sensor].h = ConvertHumidity(Dht[sensor].h + (Settings.hum_adjust / 10));
(for other sensors you kind of got an idea what is needed … just locate where your module is manipulating final data and do your edits.)
Save, compile, reflash and you are good to go.
Usage:
Console: TempOffset 20 or TempOffset -20 … HumOffset 100 or HumOffset -50
note: because of fact Tasmota loves integers, defining float in console payload have to be done as integer. eg. 1.2 = 12
so TempOffset 5 = 0.5 degrees, TempOffset 50 = 5 degrees etc.
Enjoy your adjusted data from Tasmota in webinterface, mqtt …
Cheers