Here's How to Hack a Hotel Room Thermostat

Hot Wiring a Heater

If you replace your standard home thermostat you f

If you replace your standard home thermostat you find the most common setup has either 4 or 5 wires running to your HVAC equipment. These include a 24 volt AC power wire, leads to switch the heater, air conditioner, and fan, and finally an optional “common” wire, which is often used to power a smart thermostat. In order to remain backwards compatible, virtually all residential HVAC units in my part of the world use a version of this layout. A common troubleshooting technique is to “hot wire” an HVAC system — directly connecting the 24 volt wire to either the heater line or the the AC line.

For the hacker, the takeaway is that a simple relay is perfect to drive the system. For my setup shown above, I bridge the red 24 volt line to the yellow heater line, and the system roars to life. I’m using the 4 channel relay module from SainSmart. Anything that has GPIO and can talk to a temperature sensor is enough to build a thermostat. As you all know, however, I have committed to a building a Raspberry Pi into every room in my house, and I’m using all that extra power to run the official 7 inch touchscreen as a display and interface for the HVAC. I’m also using some Adafruit MCP9808 temperature sensors, which talk to our Pis using the I2C bus.



You need the WiFi Version! (W in product name suffix, like -GALW). There are also a versions without WLAN (Offline-Version and ZigBee-Version (-GALZBW)). See Diagnose Can we add WiFi to Non-WiFi Thermostat bac-002.pdf

The BHT Version is for heating only. The BAC-Version has modes Cooling, Heating and Ventilation. The BHT-002-GA/GB/GC versions only differs in relays-wiring.

Difference between GA, GB and GC

  • GA – Water-Heating
    • Two Relays for opening and closing valve
    • Only one Relay will be closed at the same time
    • Closing Relay PIN 1 – PIN 3 (N or L)
    • Opening Relay PIN 2 – PIN 3 (N or L)
    • Product Spec says Max Power: 3 A
  • GB – Electric-Heating
    • Connect Heating between PIN 1 and PIN 2
    • Product Spec says Max Power: 16 A
  • GC – Water/Gas Boiler
    • One Relay – potential free (dry contact)
    • Relay on PIN 1 – PIN 2 (dry contacts)
    • Product Spec says Max Power: 3 A

Hardware Installation

Here a description of how to install the hardware – indepentdent from Open Source WThermostat. No special Hardware installation necessary for Upgrading to this firmware!

Round-Robin Databases and Pretty Graphs

You may not be familiar with the name, but you’ve probably seen graphs produced by RRDTool, most notably in the Cacti monitoring suite. RRDTool is a simple round-robin database built on creating pretty graphs, and the idea that older data needs less resolution than fresh data. It might be useful to track temperature minute-by-minute, but usually only the last couple hours of that data. Last week’s data doesn’t need to be as granular: an average temperature for each hour might be enough. Last month, you might just care about the daily averages, etc. RRDTool lets you specify multiple round robin archives for each data source, with different time spans and granularity.

One more trick I’ve made use of is specifyin

One more trick I’ve made use of is specifying a data source to track when the heater or air conditioner is running. This allows comparing temperatures to the HVAC duty cycle, which is useful for tracking down insulation and efficiency issues. Also, this data will be important for tuning the thermostat to avoid “short cycles”, when the system doesn’t run long enough to reach full efficiency, but turns on and off several times in short succession.

Build this firmware from source

For building from sources and coding i suggest VS Code and PlatformIO. You can also use Gitpod.

Visual Studio Code: Install and Prepare to build

  • Install Visual Studio Code and PlatformIO.
  • Type:
  • Open the folder ‘WThermostatBeca’ in VS Code
  • Go to PlatformIO Icon
  • Click Build
    • Binary Firmware can be found in build_output\firmware\wthermostat-1.xx-fas.bin (or -debug or -minimal)

All dependant arduino-libraries (DNSServer, EEPROM (for esp8266), ESP8266HTTPClient, ESP8266mDNS, AsyncWebServer, ESP8266WiFi, Hash, NTPClient, Time.) will be downloaded automatically (defined in platform.ini) and the necessary WAdapter library from (git submodule).

Cloud Development using Gitpod

You can open and compile this Project on Gitpod. You need a GitHub account, 50 hours are free per month – don’t forget to stop the workspace.

Just click

The fist build starts automatically. You can download the firmware by right-clicking in the Project-Explorer the file located at build_output/firmware/wthermostat-1.xx-fas.bin and then choose Download.

Some commands

  • Build normal firmware: platformio run -e wthermostat
  • Build all firmwares: platformio run
  • Get latest version and dependant libraries. git pull ; git pull --recurse-submodules
  • Upgrade PlatformIO: platformio upgrade --dev ; platformio update

Special Build Versions

  • -Minimal environment: minimal version without thermostat, MQTT or WebThings support. Use only for intermediate Updating
  • -Debug environment: DO NOT FLASH TO THERMOSTAT. There is debugging output to serial interface which will confuse MCU
    • Upload to USB-Connected development ESP8266 board (Node MCU or Wemos D1 Mini pro)