ESP Heater Relay
![ESP ThermicStation Relay.jpeg](/proxy/?url=https://content.instructables.com/FI2/5CR9/KYIP83LU/FI25CR9KYIP83LU.jpg&filename=ESP ThermicStation Relay.jpeg)
Control your Heater with an ESP relay via Home Assistant.
The temperature is read from another Home Assistant sensor, if the remote sensor / HA is not available the internal sensor is used.
Needed Components
![5vdc transformer.PNG](/proxy/?url=https://content.instructables.com/FBO/HL2E/KYIP83QP/FBOHL2EKYIP83QP.png&filename=5vdc transformer.PNG)
![wemos d1 mini.png](/proxy/?url=https://content.instructables.com/FFF/ZOUN/KYIP83QR/FFFZOUNKYIP83QR.png&filename=wemos d1 mini.png)
![dht22.PNG](/proxy/?url=https://content.instructables.com/FYQ/9E8A/KYIP83QQ/FYQ9E8AKYIP83QQ.png&filename=dht22.PNG)
![Single channel relay.PNG](/proxy/?url=https://content.instructables.com/FRX/LDCU/KYIP84D1/FRXLDCUKYIP84D1.png&filename=Single channel relay.PNG)
![Relay Box.PNG](/proxy/?url=https://content.instructables.com/FZ8/E4DK/KYIP83R3/FZ8E4DKKYIP83R3.png&filename=Relay Box.PNG)
- 220V to 5vdc transformer
- Wemos D1 mini ( / pro for better wireless range)
- DHT22
- 1 Channel relay
- Relay box
Coonecting the Pieces
From the power source 5v output 3 wires will go to:
- wemos d1 mini (5v and ground)
- the relay (5v and ground)
- dht22 (5v to pin1, gnd to pin 4)
Data pins
- relay (d1 mini pin D1 to the IN pin)
- dht22 (d1 mini pin D2 to pin 2)
The ESPHome Code
esphome:
name: thermicstation-relay
on_boot:
priority: 500
then:
- climate.control:
id: ${location}_thermostat
mode: "HEAT"
esp8266:
board: d1_mini
# Enable logging
logger:
substitutions:
default_temp_low: "15.0"
room: Kitchen
location: "moon"
remote_sensor: "sensor.bme680_temperature"
climate:
- platform: thermostat
min_heating_off_time: 60s
min_heating_run_time: 60s
min_idle_time: 0s
visual:
min_temperature: 15 °C
name: "${location} ${room} Thermostat"
id: ${location}_thermostat
sensor: active_temp
default_mode: heat
default_target_temperature_low: ${default_temp_low}
heat_deadband: 0.3
heat_overrun: 0.3
heat_action:
- switch.turn_on: ${location}_thermicstation_relay
idle_action:
- switch.turn_off: ${location}_thermicstation_relay
switch:
- platform: gpio
name: "${location}-thermicstation-relay"
id: "${location}_thermicstation_relay"
pin:
number: D1
sensor:
- platform: dht
id: "${location}_internal_dht22"
pin: D2
model: DHT22
temperature:
name: "${location} Thermicstation Temperature"
id: "${location}_internal_dht22_temp"
humidity:
name: "${location} Thermicstation Humidity"
id: "internal_dht22_humidity"
update_interval: 60s
- platform: homeassistant
name: "Input Temp From Home Assistant"
id: remote_temp
entity_id: ${remote_sensor}
- platform: template
name: "Active Thermicstation Input Temp"
id: active_temp
lambda: |-
if (isnan(id(remote_temp).state)){
return id(${location}_internal_dht22_temp).state;
} else {
return id(remote_temp).state;
}
update_interval: 60s
# Enable Home Assistant API
api:
ota:
password: "<secret>"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Thermicstation-Relay"
password: "<secret>"
captive_portal: