A Sonoff Switch Repurposed As A Thermostat

Underfloor heating is a wonderfully luxurious touch for a bedroom and en-suite bathroom, and [Andy] had it fitted so that he could experience the joy of walking on a toasty-warm floor in the morning. Unfortunately after about a year it stopped working and the culprit proved to be its thermostat. A replacement was eye-wateringly expensive, so he produced his own using an ESP8266-powered Sonoff wireless switch.

The thermostat has a thermistor as its temperature sensor, embedded in the floor itself. This could be brought to the ESP’s solitary ADC pin, but not without a few challenges along the way. The Sonoff doesn’t expose the pin, so some very fine soldering was the first requirement. A simple voltage divider allowed the pin to be fed, but through it he made the unfortunate discovery that the ESP’s analogue input has a surprisingly low voltage range. A new divider tying it to ground solved the problem, and he was good to go.

Rather than using an off-the-shelf firmware he created his own, and with a bit of board hacking he was able to hard wire the mains cabling and use one set of Sonoff terminals as a sensor connector. The whole fit neatly inside an electrical fitting box, so he’s back once more to toasty-warm feet.

This isn’t the first ESP thermostat we’ve featured, nor will it be the last. Here’s a particularly nice build from 2017.

14 thoughts on “A Sonoff Switch Repurposed As A Thermostat

      1. Try living in Arizona. You step on a bark/wood scorpion a few times and you’ll never walk around the house barefoot again. (Assuming you survive that is.)

  1. Good timing for this article for me. I just got several SONOFF units. Also I have ecobee units in each of the major areas of the house. Plus I do have vents controllers from another project. Each of these will work with IFTTT.

    Ecobee knows what the temperature of each room is the SONOFF could control the vents and now you have room control of HVAC.

    BUT I can’t seem to find the IFTTT command how to read the temperature of a room and thus control the vent.

    Any ideas?

    1. HVAC guy here, be careful about about your total airflow (CFM) and static pressure (in. WC). Units are engineered to operate correctly at certain conditions, if you start choking it down you can end up with drain pans overflowing or compressors dying.

      Easiest way to mitigate that risk is by installing a barometric damper somewhere that will dump the excess air into a common area. Best solution is a variable speed blower and compressor that will maintain proper air and refrigerant flow…

      1. The typical solution for this on these diy systems is ensuring that at least X% of reguaters are always open and to meet that percentage opening vents in common areas.

      2. To Mbc Mr. HVAC guy.

        You are correct. I had kind of forgotten it as I was looking into this. My frustration is that my unit can operate at either 3 ton or 5 ton and has a variable speed fan. Neither which I can figure how to operate remote and change the settings. Most of the time 3 ton is enough to keep up but unlike today it is taking all 5 tons.

        Any suggestions of how to control 3 VS 5 ton and speed of fan?

        My unit is Trane TAMYA0C60H51SBA

    1. How do you think a normal digital thermostat works? That relay is probably good for at least 50,000 cycles. If he programmed it with a 2deg offset like a normal thermostat it will last years at least.

        1. If switching a capacitive or inductive DC load, then the contactors can sometimes fail closed by essentially being welded together.
          Seen a few times with glowplug relays.

          But I’ve yet to see a relay fail catastrophically, usually it’s the thing it’s supposed to switch that fails due to a failed-closed relay, and that’s not as common with AC loads.

  2. Seems like they should start by embedding more than one temperature sensor in the floor when putting in (don’t know how likely sensors are to go bad/lifetime, but might be cheap insurance).
    Some kind of indipendent fail-safe would be nice too. (Cut the power if on for too long, e.g.)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.