Skip to content

HomeKit connected smart thermostat based on Arduino using HomeSpan.

License

Notifications You must be signed in to change notification settings

5hubh4m/homespan-thermostat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HomeSpan Thermostat

HomeKit connected smart thermostat based on Arduino using HomeSpan.

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 HomeKit compatible smart thermostat without the hassle of installing a C wire myself and/or having to buy an expensive smart thermostat. So I created my own with a Wi-Fi capable microcontroller.

Hardware

I used a Adafruit ESP32-S2 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 i.e 8) and the relay to a digital pin (10), 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.

Flashing the Code on the Microcontroller

Use the Arduino IDE to flash the code to the microcontroller. You could also do it using arduino-cli in either serial mode or OTA mode.

cd path/to/homespan_thermostat
arduino-cli compile -b esp32:esp32:adafruit_feather_esp32s2 --port PORT_PATH --protocol serial --upload

Or

cd path/to/homespan_thermostat
arduino-cli compile -b esp32:esp32:adafruit_feather_esp32s2 --port BOARD_IP --protocol network --upload

The latter will promt you for the OTA password. The default OTA password for HomeSpan is homespan-ota. It is recommended that you change it in the source code (see below) or using the O command of the HomeSpan CLI.

Configuration and Usage

There are a few parameters that need to be configured.

  • The Wi-Fi credentials can be defined in the source code as the macros WIFI_SSDI and WIFI_PASSWORD or can be set using the W command of the HomeSpan CLI.
  • The HomeKit pairing code can be defined in the source code as the macro HOMEKIT_PAIRING_CODE. Otherwise the default code 466-37-726 is used or it can be set using the S command of the HomeSpan CLI.
  • The HomeKit QR Setup ID can be defined in the source code as the macro HOMEKIT_PAIRING_QR_ID. Otherwise the default QR Setup ID HSPN is used or it can be set using the Q command of the HomeSpan CLI.
  • The OTA Password can be defined in the source code as the macro DEFAULT_OTA_PASSWORD. Otherwise the default password homespan-ota is used or it can be set using the O command of the HomeSpan CLI.

Pair the accessory to HomeKit. The general instructions are given here. That's pretty much it.

For my particular heating setup, I have enabled two heating modes: Heating, and Auto. Heating mode allows you to set a single Target Temperature which the thermostat will try to maintain. However, depending on how well insulated your home is, and how cold it is outside, it can lead to the heater turning on and off frequently consuming a lot of energy. Auto mode fixes that by allowing you to set two temperatures, a Heating Threshold and a Cooling Threshold. In this mode, the thermostat will only turn on if the temperature reaches below the Heating Threshold, and will provide heat until the Cooling Threshold is reached. This allows the heater to be on for a longer period of time, but also be turned off for a longer periods of time, which is more energy efficient than being turned on in bursts.

If you're connected to HomeKit, you should be able to control your heater using Siri.

This image shows how the this thermostat looks in the Home app.

About

HomeKit connected smart thermostat based on Arduino using HomeSpan.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages