ESP Heater Relay

by EduardG8 in Circuits > Electronics

540 Views, 3 Favorites, 0 Comments

ESP Heater Relay

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
wemos d1 mini.png
dht22.PNG
Single channel relay.PNG
Relay Box.PNG
  1. 220V to 5vdc transformer
  2. Wemos D1 mini ( / pro for better wireless range)
  3. DHT22
  4. 1 Channel relay
  5. 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

  1. relay (d1 mini pin D1 to the IN pin)
  2. 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: