Adafruit IO Thermostat

Adafruit IO connected smart thermostat based on CircuitPython.

Background and Motivation

I have a 24 V Heat-only system with a 2-wire system (No C-wire, only R and W). It used a manual Honeywell single-point thermostat. I wanted to get the functionalities of a smart thermostat (potentially HomeKit compatible) without the hassle of installing a C-wire myself or having to buy with expensive smart thermostats. So I created a simple smart thermostat with an Wi-Fi capable microcontroller.

Hardware

I used a Adafruit ESP32S2 Feather board, along with a TMP36 analog temperature sensor, and a simple non-latching relay.

I wired up the TMP36 to an analog input pin (A5) and the relay to a digital pin (D10), and connected the relay to the R and W wires in my heating panel in the NO mode i.e when the relay is off, the heater is also off. The circuit diagram is given below.

This image shows how the components are wired to the microcontroller board.

Flasing the Code on the Microcontroller

As is with any CircuitPython device, you just need to copy the contents of the src folder to the root directory of the CIRCUITPY drive. If you’re using a different board, or different pins, or components (say, a digital temperature sensor), the relevant code is in src/code.py for you to change. Remember to enter the credentials for your Wi-Fi and Adafruit IO account in src/secrets.py.

I have included the prerequisited for my board in the src/lib folder. For a different board, you might need some more extra libraries.

The code should “just work”, however, this is rarely the case with hobby electronics; so use your judgement and a lot of testing to make sure to not fry your home heating system. I provide no gurantees whatsoever. However, feel free to file issues for important things!

Setting Up Adafruit IO

Below is a set of brief steps to setup your Adafruit IO accoount to interface with your smart thermostat.

  1. Setup an Adafruit IO account.
  2. Create the following feeds:
    1. config: This is to configure the status of your smart thermostat (0 = OFF, 1 = SINGLE POINT, 2 = DUAL POINT).
    2. tgt-temp: This is to set the target temperature in heat-only (SINGLE POINT) mode.
    3. min-temp: This is to set the lower bound (heating threshold) temperature in dual (DUAL POINT) mode.
    4. max-temp: This is to set the upper bound (cooling threshold) temperature in dual (DUAL POINT) mode.
    5. heater-on: This feed is where the status of the heater is published.
    6. curr-temp: This feed is where the current temperature is published.
  3. You can try creating a IO Dashboard so see some of the things. Here is a picture of how mine looks.

This image shows how the Adafruit IO Dashboard for the thermostat looks.

Homebridge Plugin

My ultimate goal was to integrate with HomeKit so I wrote a Homebridge plugin that talks to Adafruit IO to send commands to the thermostat. Find it here.

GitHub

View Github