I have been making a few electronic projects for the house for a long time, but I only recently revisited home assistant. I am on my third (or 4th maybe) iteration of the home thermostat and the latest version’s temperature sensor is not great.
I know my computers and wifi aren’t as reliable as I need for a thermostat, so I need to make sure it works without internet and without any other computers. But I can add some thermometers in the rest of the house and probably get better results.
So this is what I did.
- I have an esp32 on my wall, with a built in OLED. It it attached to a relay board to turn the heater on and off. I only have a heater in this part of the house, so I only turn the heater on or off.
- I bought some very cheap blue tooth temperature sensors from banggood. They were about $5 each and they can be flashed over bluetooth from a web page, which is just wild to me.
- I used ESPHome to read the temperature from these sensors.
Then comes the fun part. The sensors only report their temperature at 5min intervals (and I might even turn that down more). The less they report, the longer their batteries last.
The sensor in the thermostat measures temperature every 10s. So that is good for control. But it is too close to the ESP32 and it is getting too hot. It also is only in one room of the house (a room that is very sunny in the afternoons). So I know it is consistently wrong, and a different amount of wrong depending on the weather and the position of the sun.
So for each temperature sensor, I measure the difference between that sensor’s reported value and the most recent value of the thermostat temp. I run that through a low pass filter. Then I average these 4 offsets to get a number that represents the difference between the thermostat sensor, and the average temperature of the thermostat.
The thermostat reads in that offset from mqtt and uses it as an adjustment on its temperature sensor. The great part is, if the mqtt server goes down, or the temperature sensors run out of batteries, it will just go back to no offset (and the house will get a little colder, but not freeze any pipes or anything).
I’m really impressed with ESPHome firmware. It lets you basically just write a config file in yaml and it reads the file and creates pretty complex C++ to flash to an ESP device. It has good integration with Home Assistant. It really didn’t take me very long at all to get this (somewhat complicated) system of offsets working. If you’re flashing an ESP chip and you plan on connecting it to Home Assistant or MQTT, I suggest you check it out.
I am thinking of making the update rate on the thermometers even longer time frames. If this works, I don’t see any reason they would need to be updated more often then 4-5 times an hour. The offset is very slow to change, and they mostly track well with the sensor in the front room over short periods of time.