summaryrefslogtreecommitdiff
path: root/src/HW/thermostat/document.en.rest.txt
blob: 6a6c0a3976aed9a1bc65725c832d9596c35ae9ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
===========================
Building a smart thermostat
===========================
:CreationDate: 2018-03-25 12:47:54
:Id: HW/thermostat
:tags: - hardware
       - software
 
I'd like to have a computer-controller thermostat, that behaves the
way I want to, doesn't need to talk to external servers, can measure
temperature in multiple rooms.
 
I'll need:
 
* multiple cheap temperature sensors that can report their readings
  wirelessly
* a way to start / stop the boiler
* some clever software to decide when to turn the boiler on/off based
  on the temperature readings
* a computer to run that software
 
The sensors
===========
 
The current candidate is a ESP32_ running off (probably alkaline)
batteries, using a DHT11_ sensor.
 
.. figure:: thermometer-diagram.png
   :alt: diagram showing a ESP32 microcontroller wired up to a DHT11
         sensor
   :align: center
 
   Connections:
 
   =============== ======
   microcontroller sensor
   =============== ======
   +5V             VCC
   GND             GND
   pin 13          DATA
   =============== ======
 
`The code for the thermometer`_ uses the DHTesp_ library to read the
sensor, and the `esp8266-oled-ssd1306`_ library to drive the
display. The final sensor will most probably not have a display.
 
.. _ESP32: https://en.wikipedia.org/wiki/ESP32
.. _DHT11: https://www.adafruit.com/product/386
.. _`The code for the thermometer:
   https://www.thenautilus.net/cgit/thermostat/tree/sensor/thermostat.ino
.. _DHTesp: https://github.com/beegee-tokyo/DHTesp
.. _`esp8266-oled-ssd1306`:
   https://github.com/ThingPulse/esp8266-oled-ssd1306/
 
Talking to the boiler
=====================
 
Using the process described by `Steven Hale`_`Dave Hope`_`Ross
Harper`_ and probably others, I connected a 433MHz receiver to my
soundcard:
 
.. figure:: rf-receiver-diagram.png
   :alt: diagram showing a 433MHz receiver wired up to a stereo audio
         cable via resistors
   :align: center
 
   Connections:
 
   ============= =======
   From          To
   ============= =======
   Power +       receiver VCC
   Power -       receiver GND
   Power -       microphone cable shielding via 22kΩ resistor
   receiver data microphone cable channel via 47kΩ resistor
   ============= =======
 
By turning the knob the thermostat that was installed with the boiler,
I generated the on and off signals. I recorded them with Audacity_,
and spent a few hours puzzling them out. This is what the recorded
waveforms look like:
 
.. figure:: waveforms-small.png
   :alt: two similar but not identical saw-toothed waveforms, one
         above the other
   :target: waveforms-large.png
   :align: center
 
   The two signal trains (one for "on" and one for "off")
 
It took a while to realise that those saw-toothed waves were actually
square waves, mangled by all the filters that my soundcard has, and
that the heights were different only because of those same filters.
 
Measuring the number of samples between rising edge and falling edge
gave me the timing. Then I had to do the whole thing again when I
noticed that the "low" widths where not always equal to the preceding
"high" width: it's not a 50/50 duty cycle square wave.
 
Then I built a transmitter:
 
.. figure:: rf-trasmitter-diagram.png
   :alt: diagram showing an Arduino UNO wired up to a 433MHz
         transmitter
   :align: center
 
   Connections:
 
   =============== ===========
   microcontroller transmitter
   =============== ===========
   +3.3V           VCC
   GND             GND
   pin 7           DATA
   =============== ===========
 
and wrote `code to send the correct pulse train`_. The receiver wired
to the boiler recognises the signals and turns on and off.
 
.. _`Steven Hale`:
   http://www.stevenhale.co.uk/main/2013/08/home-automation-reverse-engineering-a-worcester-bosch-dt10rf-wireless-thermostat/
.. _`Dave Hope`:
   https://damn.technology/controlling-british-gas-wr1-receiver-arduino
.. _`Ross Harper`:
   https://rossharper.net/2015/11/decoding-a-siemens-rcr10433-thermostat-signal-to-control-a-boiler-from-a-raspberry-pi/
.. _Audacity: https://www.audacityteam.org/
.. _`code to send the correct pulse train`:
   https://www.thenautilus.net/cgit/thermostat/tree/trasmitter/sender.ino