Skip to content

Latest commit

 

History

History
104 lines (71 loc) · 6.75 KB

README.md

File metadata and controls

104 lines (71 loc) · 6.75 KB

ESPHome Based Line Voltage (Baseboard Heating) Thermostat From Wall Switch

I recently wanted to add smart thermostats to my apartment. However, I was surprised by the lack of inexpensive, line voltage (or baseboard) smart thermostats. Especially since there's so many cheap smart wall switches, and a line voltage thermostat is just a wall switch with a temperature sensor and some type of UI. So I decided to make some. I also set myself a goal of making the entire thing reversible back to a wall switch if I ever moved to a place where I no longer needed line voltage thermostats and I mostly succeeded. I had to de-solder the microswitch, but otherwise everything is reversible and it'd be easy enough to re-solder if I want to switch back.

Update August 21, 2021:

The 2021.08 ESPHome update had some breaking changes to how it handels thermostats. The YAML config file has been updated to work with the new version of ESPHome.

⚠️Warning⚠️

This project involves line voltage, which can be extremely dangerous and deadly. I am not an electrician or electrical engineer so proceed at your own risk. Always turn off the power at the breaker and double triple check the power is disconnected before touching any wires.

Parts List

  1. A ESP based smart wall switch, with accessible GPIO pins. I used a Laghten smart switch (Amazon Link), but others will probably work as well.
  2. A USB-UART (USB to TTL converter) for flashing
  3. DHT22/AM2302 (Amazon Link)
  4. Rotary encoder with push button (Amazon Link)
  5. 128X64 (0.96") SSD1306 OLED display (Amazon Link)
  6. JST battery connectors (optional)
  7. A 4.7K resistor
  8. 4x wire nuts (I reused the ones already in the wall)
  9. 2X #6 screws for the switch
  10. 3D printed case
  11. Hot glue gun
  12. 2X #6 x 1" decorative wall plate screws (colored to match your 3D printed case)

Flashing

I recommend flashing the ESP before you start soldering parts onto it. Unfortunately Tuya Convert no longer seems to work due to the new Tuya firmware, so you'll have to use a USB-UART converter and solder connections. My smart switch was based on a TYWE3S and I used the Tasmota instructions available here for flashing.

⚠️ Power the ESP from 3.3V on the USB-UART during flashing. Do not connect line power during flashing! ⚠️

I found it easiest to remove the entire board with the ESP from the switch to flash and solder on components.

Flashing

In addition to the thermostat.yaml file, you will also need a font file (I used Open Sans) and 4 image files from Material Design Icons:

The MDI icons and font file will need to be in the same directory as the .yaml file.

Soldering Components

Here is the pinout I used. Other configurations would likely work but I know this one worked for me.

pinout

I also used pre-wired JST connectors to make removing the cover easier once all the components were soldered together and I used sharpie to color code the different connections.

JST Connectors

You also need to de-solder the microswitch or the encoder won't fit. Save it along with the front plates if you ever want to change it back to a wall switch.

microswitch

OLED Display

In order to get the OLED display to fit into the case, I de-soldered the header pins from the board and just soldered the wires directly onto the back.

OLED

Temperature Sensor

The AM2302 requires a pull-up resistor on the data line, so that was soldered on first along with the data wire. Then the power wires were added.

Rotary Encoder

The encoder has 2 separate connections. The encoder and the push button. For the push button, one connection should be GND and the other connected to an GPIO pin. For the encoder portion, the center pin should be GND and the other two connected to GPIO pins. I connected the two GND connections at the encoder and only ran one wire back to the ESP's GND.

encoder

Case

The case was designed in Alibre Atom 3D. I've included the original file as well as the .stl and STEP files if anyone wants to modify them. I printed mine on my Monoprice Select Mini Pro in black PETG. You can print it either face up or face down. Face up requires a lot more filament for supports but gives you a better front surface. Face down, you still need supports for where the rotary encoder goes.

case

Putting It All Together

Before gluing or closing anything up, it's always good to do a quick test to make sure all your connections are secure.

⚠️ When testing using line voltage, always put wire nuts over any unconnected wires (switched wire) and never touch any exposed connections! ⚠️

testing

(This image was taken before I realized the microswitch didn't fit.)

I like to try and make things as re-usable as possible so I prefer to use hot glue to hold everything together.

Installing It On The Wall

As I am not an electrician, I don't want to give detailed instructions on how to install the high voltage aspects. The basics of installing the thermostat are:

  1. ⚠️ Make sure the power is turned off at the breaker ⚠️

  2. ⚠️ Check again that the power is turned off ⚠️

  3. ⚠️ Use a non-contact voltage tester to make sure theres no power! (Seriously this is important!) ⚠️

  4. Connect the wires appropriately.

  5. Screw in the switch

  6. Connect the 3.3V and data cables to the components in the 3D printed case.

  7. Screw on the 3D printed case

  8. Cross your fingers & turn back on the power

Thermostat Operation

The thermostat will work even when disconnected from Home Assistant/ ESPHome. To change the temperature, you short press the rotary encoder and you can adjust the temperature set-point in 0.1o increments. Another short press sets the new set-point. To toggle the thermostat on or off, simply long press the rotary encoder.