Skip to content
My Account

HomeKit

ESP8266 HomeKit Thermostat with OLED Display

A HomeKit thermostat on an ESP8266 that heats and cools, with a DHT22 sensor, a small OLED display and UP and DOWN buttons that change the set temperature by 0.5 degrees.

  • ESP8266
  • HomeKit
  • 3 min read
No ratings yet, be the first.

A HomeKit thermostat built on an ESP8266. It measures the temperature with a DHT22 sensor, has a small OLED display, and lets you change the set temperature with two buttons, next to the Home app. It can both heat and cool, as the HomeKit Accessory Protocol thermostat service allows.

It is a test setup, and a fun one, that combines the thermostat with an OLED display. It was built to see whether the code and the hardware work together.

What it does

FeatureDetails
HomeKit thermostatAppears in the Home app as a thermostat that can heat and cool
Temperature sensorA DHT22 (AM2302)
DisplayA small I²C OLED display
UP and DOWN buttonsChange the set temperature in steps of 0.5 °C
UpdatesOver the air, through Life Cycle Manager 2
No cloudControl stays on your own network

Hardware

ComponentNotes
ESP8266 moduleAn Ai-Thinker ESP8266 module of the ESP-12 type. See the ESP8266 pinout
AM2302 (DHT22) sensorTemperature and humidity, on a breakout with the pins marked minus, OUT and plus
OLED displayI²C, with VCC, GND, SCL and SDA pins. See the SSD1306 OLED display guide
3 push buttonsUP, DOWN and RESET
2 NPN transistorsDrawn as 2N222 in the diagram, with 10 kΩ resistors, for the automatic programming circuit
100 nF capacitorBetween the supply and ground at the module
USB-serial (FTDI) adapterFor flashing and for power in this test setup. Set it to 3.3 V logic

Wiring

The Fritzing diagram at the top of this page shows the whole build on a breadboard, and includes the pinout of the module. Reading the wires against that pinout gives this assignment:

PartESP8266 pin
DHT22 (AM2302) data, OUTGPIO4
OLED SDAGPIO5
OLED SCLGPIO14
UP buttonGPIO12
DOWN buttonGPIO13
RESET buttonRST
Enable lineCH_PD, pulled up with a 10 kΩ resistor
Boot modeGPIO15 to GND
Serial to the FTDI adapterTXD and RXD

These pins are read from the diagram and are not listed in the repository text, so check them against the diagram before you build. Use an FTDI adapter set to 3.3 V, because a 5 V adapter can damage the module.

Automatic programming circuit

The two transistors and their 10 kΩ resistors form an automatic programming circuit. It drives the programming GPIOs of the module for you, so you do not have to press buttons to put the module in flash mode.

Flash and install

The installation is the same as for the other ESP8266 HomeKit accessories on this site. The firmware runs on ESP-Open-RTOS with Life Cycle Manager 2, which sets up the WiFi and installs updates over the air. The full steps, from installing esptool to flashing, joining the LCM- WiFi network and pairing, are in ESP8266 HomeKit Blinds.

In the portal, use these values:

FieldValue
OTA repositoryAchimPieters/ESP8266-HomeKit-Thermostat
OTA binary filemain.bin

When the installation is done, scan the QR code the device generates in the Home app to add it.

Firmware release

VersionDateNotes
0.0.13 November 2019Initial release

The firmware is published as a binary, main.bin, with a signature file, main.bin.sig.

Good to know

  • This is a test setup and not a finished product.
  • The HomeKit Accessory Protocol specification the firmware follows is the non-commercial version, for accessories you build yourself and do not distribute or sell.
  • The repository has the diagram and the MIT licence, but no source code.

Everything is in the ESP8266-HomeKit-Thermostat repository on GitHub.

Advertisement
All HomeKit

More HomeKit

Keep building.

Switches, sensors, plugs and blinds: more accessories that you build yourself and add to the Home app.

All HomeKit