Accurate Thermal Control with Basic Space Heaters

Victor ChangVictor Chang
6 min read

There’s a problem with temperature-controlled space heaters — they’re all terrible at temperature control.

Hear me out

It’s physically impossible for any (self-contained) space heater to maintain a target temperature with any respectable precision. And I do mean maintain. As in, if I want 70° F, I don’t want 69° or 71° F. In practice, my house thermostat is able to maintain the room temperature between 69.5 and 70.0° F. Space heaters cannot dream of achieving this precise range and I observe them varying by more than 10 degrees.

Why is that? Simple. The thermometer is inside the space heater. That means the thermometer is measuring a temperature that’s higher than the room temperature due to being influenced by the heater itself.

Designers can apply some tricks to alleviate this issue, such as placing the thermometer as far from the heating element as possible, but space heaters are only so big and the thermometer can only be so far. Real thermostats sit on walls, tens of feet away from any vents/registers, for a reason.

Since we know that the thermometer would be reading an elevated temperature when the heater is on, let’s logic out what would happen if we actually tried to maintain 70° F. Let’s be naive and make the heater turn off once the thermometer reads 70.5° (a reasonable cut-off point you can have with a wall thermostat). The heater heats itself up and almost immediately reaches 70.5° F. Now the heater turns off while the room temperature barely budged.

Obviously not a functional approach, so let’s be less naive: Give the heater some wiggle room. Wait until the temperature reading is far higher than the target temperature before turning off. Can there be any precision with this approach? No, and that is just an unavoidable fact of physical reality.

What can be done?

The thermometer has to be detached from the space heater. Perhaps there are high end models with remote sensors, but I have not found them and they likely cost more than it’s worth. Instead, I’ve set out to solve this with my own thermometer, a smart plug, and Home Assistant automations.

Thermometer

Get anything that can integrate with Home Assistant. Ideally with frequent reports and precise readings. I have seen some that only report at 0.5° F increments and that’s simply too wide for my tastes, but you can always make do with accepting a slightly looser control of the room’s temperature range.

I personally use the SHT40-series thermometer and ESP8266/ESP32 microcontrollers running ESPHome to have good precision and frequent readings.

Specifically, in ESPHome I have the temperature polled every second and the temperature is averaged out like so:

    sliding_window_moving_average:
        window_size: 60
        send_every: 30

This applies a moving average of the last minute’s worth of readings, and reports the temperature to Home Assistant every 30 seconds.

Of course, you should put the sensor a good distance away from the space heater.

Smart Plug

Optimistically, you can use anything that integrates with Home Assistant. But there are two things to consider:

Don’t burn your house down

Space heaters can use basically the entire amperage of the circuit and can lead to melting/burning cheap smart plugs that exaggerate the amperage they support. Do your research and find a trustworthy brand/model. Did you know that your usual wall outlet is rated for 15A but your usual cheap smart plugs (and extension cables, for that matter) are only rated 13A? And that’s still just their marketed claim — they could have secretly cheapened out even further. Crazy…

But in any case, monitor the temperature of the smart plug at the beginning until you’re sure it handles the load. I’ve also gone a step farther and only use the medium power (900W or 8A) setting on the space heater.

What happens if the network or Home Assistant goes down?

If the smart plug was on and Home Assistant can no longer instruct it to turn off, will the heater turn the room into a sauna? How can we implement safety cut-offs?

You can use the heater itself where you heat the room to the max temperature you’d want it to reach and then slowly lower the target temperature until it switches off, but that depends on a trust that no person or pet would ever accidentally change that setting.

Maybe some smart plugs have timers where it can automatically turn off after a set time, but is that on-device or cloud-dependent?

I went with the timer option, and to make sure the timeout runs on-device, I opted to use ESPHome on a Sonoff S31. This enables me to put a 1 hour timeout straight into the smart plug’s firmware so it is for sure running on-device. At the same time, I make sure that it doesn’t turn back on after a power outage. The YAML config is pretty simple:

switch:
  - platform: gpio
    name: "${name} Relay"
    pin: GPIO12
    id: relay
    # Stay off after a power outage.
    restore_mode: RESTORE_DEFAULT_OFF
    # For use with the space heater:
    on_turn_on:
      - script.stop: turn_off_after_one_hour
      - script.execute: turn_off_after_one_hour
    on_turn_off:
      - script.stop: turn_off_after_one_hour

# For use with the space heater:
script:
  - id: turn_off_after_one_hour
    then:
      - delay: 60min
      - switch.turn_off: relay

Automations in Home Assistant

Let’s set up automations to use a space heater to keep a room between 71° and 71.5° F.

There is a gotcha I’ve learned the hard way and I’ll explain it now and help you avoid it. First, consider this setup:

alias: Corner Bedroom Heater - Turn off if above 71.5F
description: ""
triggers:
  - entity_id:
      - sensor.corner_bedroom_temperature
    above: 71.5
    trigger: numeric_state
actions:
  - type: turn_off
    device_id: <your device id>
    entity_id: <your entity id>
    domain: switch
mode: single

This is how one would naively configure to have the smart plug turn off if the temperature is above 71.5° F. But its major flaw is that Home Assistant has to observe the moment when the number goes from <=71.5 to >71.5. If there is any sort of lapse in communication, or Home Assistant was updating/restarting, it is possible for it to miss the moment that the value changed to >71.5. When that happens, this automation will not trigger and it will not instruct the smart plug to turn off.

Instead, you have to poll the value. The best you can do with the available automation syntax is a poll every minute, so let’s do that where we poll on the 0th second of every minute:

alias: Corner Bedroom Heater - Turn off if above 71.5F
description: ""
triggers:
  - seconds: "0"
    trigger: time_pattern
conditions:
  - condition: numeric_state
    entity_id: sensor.corner_bedroom_temperature
    above: 71.5
actions:
  - type: turn_off
    device_id: <your device id>
    entity_id: <your entity id>
    domain: switch
mode: single

This way, things that could cause the previous setup to fail would be rectified within a minute. I suppose you could create a duplicate automation entry that triggers on the 30th second of every minute to bring the latency down to 30 seconds too. Up to you.

Here would be the corresponding “turn on” automation:

alias: Corner Bedroom Heater - Turn on if below 71F
description: ""
triggers:
  - seconds: "0"
    trigger: time_pattern
conditions:
  - condition: numeric_state
    entity_id: sensor.corner_bedroom_temperature
    below: 71
actions:
  - type: turn_on
    device_id: <your device id>
    entity_id: <your entity id>
    domain: switch
mode: single

And that’s the bare minimum automation setup. You can of course add any other conditions you’d like, such as only triggering during the evening:

  - condition: time
    after: "17:00:00"
    before: "22:00:00"

And in that case, you probably want a final shut-off automation or else the smart plug might run the heater for up to an hour longer.

alias: Corner Bedroom Heater - Turn off at the end
description: ""
mode: single
triggers:
  - at: "22:01:00"
    trigger: time
conditions: []
actions:
  - type: turn_off
    device_id: <your device id>
    entity_id: <your entity id>
    domain: switch

That’s all there is to it! Guess which room used a space heater?

0
Subscribe to my newsletter

Read articles from Victor Chang directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Victor Chang
Victor Chang