Elektor_Mag_-_January-February_2021

([email protected]) #1

46 January & February 2021 http://www.elektormagazine.com


rest, I now had to do automations inside ESPHome. This programming
and configuring is done in the YAML file of the thermostat’s ESPHome
project (see “Home Automation Made Easy” [3]).

Measure Room Temperature
First, declare the temperature sensor that measures the room tempera-
ture. As the sensor used is a DS18B20 (originally from Dallas, now Maxim
or even Analog Devices) connected to GPIO pin 5, and since ESPHome
has a special Dallas component, this translates to the following entries:

dallas:
  - pin: GPIO5

sensor:
  - platform: dallas
    address: 0x6D00000C24013928
    name: “Measured temperature”
    id: t_room
    filters:
      - offset: 0.0

The first line tells ESPHome to include its Dallas 1-wire communica-
tion module and connect GPIO5 to it. The sensor then is of the dallas
platform. The address is optional. However, if you specify it, it must
be correct; you can get it from the ESPHome log (don’t use mine, it is
unique). Specifying an id (t_room, pun not intended) is required here
because we will need to refer to the sensor from somewhere else inside

I added a potentiometer with a voltage limiting resistor because the Wi-Fi
module cannot handle voltages higher than 1.1 V. I kept the two pushbut-
tons and the three LEDs as they might come in handy at some point.


It was a lucky coincidence that the AC/DC module was just small
enough to fit under the plastic knob support of the potentiometer. The
potentiometer, power switch and mains terminal block were recovered
from the old thermostat (Figure 3). I had to replace the relay by a 5 V
type as the old thermostat’s relay was a 48-V type. I did not manage
to fit the desktop thermostat’s relay, but, lucky me once more, the old
thermostat’s relay was a type from an industry-standard family that
is still available and that exists in 5 V.


Putting it all on a PCB that fitted in the original enclosure required a
lot of measuring, but I succeeded in the end. All the SMT components
including the Wi-Fi module went on the bottom side of the board
(Figure 4), while all the through-hole parts found a place on the top
side. A little bit extra board surface was gained by obstructing a couple
of unused mounting holes of the enclosure. The fitting also implied
cutting away some plastic obstacles inside the enclosure. To route all
the tracks, a flexible approach of recommended isolation standards
was unfortunately unavoidable.


Software
The ESPHome firmware that I had compiled for my first setup also
required rethinking. Instead of simply exposing all the sensors and
actuators of the thermostat and letting Home Assistant take care of the


ESP-12E
GPIO16
GPIO14
GPIO12
GPIO13 GPIO15

GPIO10

MOD1
CH_ PD

GPIO2

GPIO0

GPIO4

GPIO5

GPIO9

REST

CS0MISO MOSISCLK

ADC

VCC GND

RX

TX^2221

16

17

18

19

20

10 11 12 13 14

15

9

1 2 3 4 5 6 7 8

K2
1
2
3
4
5

K1
1 2 3 4 5 6

R4
10k

+3V3

R11
120k

P1
47k

C3
100n

R3
10k

S2 S1 R2
220
LED3

YELLOW

LED1

RED

LED2

GREEN

R10
10k

R9
220

R8
10k

R7
10k

R1
220

R6
1k

DS18B 20

IC2

1

2

R5 3
10k C1
100n

T1

2N7002 S

D
G

RY211006Re1 D1
1N4148

N
L
NC
COM
NO

S3
LM1117-3.3
IC1
C4
1

+3V3

IRM-02-5

AC/DC1
L

N

+5V

200519-001

TXD
RXD
RST
GND
P0

C2
100n

C5

(^100) 6V3
Figure 2: Basically, the new discreetly
connected thermostat is the Elektor
Desktop Thermostat from 2018
with a new power supply. Also, a
potentiometer was added for setting
the target temperature.

Free download pdf