ESP8266 Thermostat

Moderators: Voyager, BertB, rtenklooster, Stuntteam, grovkillen, TD-er

Post Reply
Message
Author
User avatar
enesbcs
Normal user
Posts: 368
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

ESP8266 Thermostat

#1 Post by enesbcs » 09 Jan 2019, 20:32

ESP8266 Thermostat
Image
Parts required:
  • 107x87x59mm Plastic Electronics Project DIN Rail PLC Box
  • NodeMCU ESP8266 Development Board (ESP12)
  • HLK-PM01 5VDC 3W power supply (HLK)
  • Fuse N400mA 250VAC 5x20mm + fuse socket (Bizt/400mA)
  • Varistor for 275V (VDR/275V)
  • 5x7 cm Prototype Paper
  • 5x7cm Double-Side Protoboard Prototype PCB Board
  • 1x3 Matrix Array Key Membrane Switch Keypad 36x55mm (BTN-L,BTN-R,BTN-M)
  • 5V 1-Channel Relay Module with Optocoupler Level (RELÉ)
  • AC 250V 3A 2 Pin ON/OFF I/O SPST Snap in Mini Rocker Switch (Kapcsoló)
  • 2 Poles/2 Pin 2.54mm/0.1" PCB Universal Screw Terminal Block
  • AM2320 Digital Temperature and Humidity Sensor (AM2320)
  • OLED 1.3" White LCD 4PIN Display Module I2C Interface 128x64 (OLED)
(*)Text between parenthesis is drawing symbols below!

Wiring:
Image
230V AC arrives from left (Line,Neutral) and "Kazán kontaktus" is 2wire that controls the boiler. (either Normally Open start/stop signal, or if boiler is old, it can control 230VAC)

ESP12 pinout:
  • RX (GPIO3/D9) = BTN-M (Menu button)
  • D1 (GPIO5/SCL) = OLED SDA + AM2320 SDA (it is only reversed for easy soldering)
  • D2 (GPIO4/SDA) = OLED SCL + AM2320 SCL (it is only reversed for easy soldering)
  • D5 (GPIO14) = Relay IN
  • D6 (GPIO12) = BTN-M (Left button)
  • D7 (GPIO13) = BTN-R (Right button)

    Inside:
    Image
    Image

    I developed P168 ThermoLED ESPEasy plugin for easy usage:
    https://github.com/enesbcs/ESPEasyPlugi ... rmOLED.ino
    Complete ESPEasy firmware can be downloaded from here:
    https://drive.google.com/file/d/1SVa6bv ... sp=sharing

    P168 features :
    - Displays and use current temperature from specified Device/Value (can be a Dummy for example)
    - Displays and maintains setpoint value
    - on power down/up this plugin maintains and reloads RELAY and SETPOINT values from SPIFFS
    - Supports 3 buttons, LEFT, RIGHT and MODE selection (MODE button cycles modes below,
    LEFT/RIGHT increases-decreases setpoint OR timeout (Mode sensitive)
    - one output relay need to be specified, currently only HIGH level active supported
    - 3 mode is available:
    - 0 or X: set relay permanently off no matter what
    - 1 or A: set relay ON if current temperature below setpoint, and set OFF when
    temperature+hysteresis reached - comparison made at setted Plugin interval (AUTO MODE)
    - 2 or M: set relay ON for specified time in minutes (MANUAL ON MODE), after timeout, mode switch to "A"

    List of commands :
    - oledframedcmd,[OLED_STATUS] Inherited command from P036 status can be:
    [off/on/low/med/high]
    - thermo,setpoint,[target_temperature] Target setpoint, only used in Mode "A"
    - thermo,heating,[RELAY_STATUS] Manually forcing relay status [off/on]
    - thermo,mode,[MODE],[TIMEOUT] Set to either mode X/A/M, if M selected,
    then TIMEOUT can be specified in minutes

    Command Examples :
    - /control?cmd=thermo,setpoint,23 Set target setpoint to 23 Celsius
    - /control?cmd=thermo,mode,1 Set mode to AUTOMATIC so it starts to maintain setpoint temperature
    - /control?cmd=thermo,mode,2,5 Starts pre-heat for 5 minute, does not care about TEMP, then go to AUTO mode after timeout
    - /control?cmd=thermo,mode,0 Switch heating off, absolutely do nothing until further notice


    ESPEasy device settings:
    Image

    P168 control plugin settings:
    Image

    Sample rules:

    Code: Select all

    on System#Boot do
     event,loctemp
    endon
    
    on loctemp do
     TaskValueSet,3,1,[homero#Temperature]
     TaskValueSet,3,2,0
    endon
    
    on exttemp do
     TaskValueSet,3,1,%eventvalue%
     TaskValueSet,3,2,1
     timerSet 1,180
    endon
    
    on Rules#Timer=1 do
     event,loctemp
    endon
    
    on homero#Temperature do
     if [glob#external]=0
      TaskValueSet,3,1,[homero#Temperature]
     endif
    endon
    
    The code above makes it possible to use it's own AM2320 settings as default or if nothing sends to it a remote update.
    Remote temperature can be sent by the following URL:
    http://THERMOSTAT_IPADDRESS/control?cmd=event,exttemp=21.5
Attachments
thermostat_controls.jpg
Thermostat controls
thermostat_controls.jpg (107.13 KiB) Viewed 2930 times

User avatar
grovkillen
Normal user
Posts: 3043
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: ESP8266 Thermostat

#2 Post by grovkillen » 09 Jan 2019, 21:28

Love it! Good job! :o
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
enesbcs
Normal user
Posts: 368
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: ESP8266 Thermostat

#3 Post by enesbcs » 09 Jan 2019, 22:31

grovkillen wrote:
09 Jan 2019, 21:28
Love it! Good job! :o
Thanks! It could not have been created without ESPEasy! :) And of course without Plugin_036, which is the base of this one.
Believe it or not, the hardest thing in coding was to create and display a flame icon on the display... :) It took a while until i understood why the flame was mirrored and splitted half after conversion...

asuz
Normal user
Posts: 53
Joined: 31 Oct 2018, 18:22

Re: ESP8266 Thermostat

#4 Post by asuz » 09 Jan 2019, 22:35

Thanks for that project, i will built your project soon :)

User avatar
grovkillen
Normal user
Posts: 3043
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: ESP8266 Thermostat

#5 Post by grovkillen » 09 Jan 2019, 22:45

enesbcs wrote:
09 Jan 2019, 22:31
grovkillen wrote:
09 Jan 2019, 21:28
Love it! Good job! :o
Thanks! It could not have been created without ESPEasy! :) And of course without Plugin_036, which is the base of this one.
Believe it or not, the hardest thing in coding was to create and display a flame icon on the display... :) It took a while until i understood why the flame was mirrored and splitted half after conversion...
Yeah it's always those silly things that takes time :)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: ESP8266 Thermostat

#6 Post by papperone » 10 Jan 2019, 07:13

great project, well done!!!

I may give a small advice... make the display not always "ON" else you will need to replace the OLED module every 3/4 months due to the fast worn out :(
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

User avatar
enesbcs
Normal user
Posts: 368
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: ESP8266 Thermostat

#7 Post by enesbcs » 10 Jan 2019, 08:34

papperone wrote:
10 Jan 2019, 07:13
great project, well done!!!

I may give a small advice... make the display not always "ON" else you will need to replace the OLED module every 3/4 months due to the fast worn out :(
Thank you. I have motion sensors nearby and Domoticz switches the OLED display off when no motion for 15 minutes, than switches to ON if motion occurs.

riker1
Normal user
Posts: 301
Joined: 26 Dec 2017, 18:02

Re: ESP8266 Thermostat

#8 Post by riker1 » 17 Jan 2019, 12:03

Hi

looks great.

Having a question:

I just want to use the 1x3 Matrix Array Key Membrane Switch Keypad 36x55mm (BTN-L,BTN-R,BTN-M)

How to I need to connect it and get readings for that?

I did

1 vcc
2 gnd
3. D2
4. D1

but do not get readings for it.
Thanks for Hints.

t

User avatar
enesbcs
Normal user
Posts: 368
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: ESP8266 Thermostat

#9 Post by enesbcs » 17 Jan 2019, 18:18

riker1 wrote:
17 Jan 2019, 12:03
I just want to use the 1x3 Matrix Array Key Membrane Switch Keypad 36x55mm (BTN-L,BTN-R,BTN-M)

How to I need to connect it and get readings for that?

I did

1 vcc
2 gnd
3. D2
4. D1
but do not get readings for it.
Thanks for Hints.
Sorry for the missing information, but as you see it has only four connection to three button... so VCC is not needed. It is a simple switching device, you can check with a multimeter, if you connect GND to the 1st pin, than the other 3 pin will go to GND when you press a button. This is the reason why Input-pullup is also necessary, with this setting the GPIO's will go back to HIGH if not pressed, and go to LOW if pressed. (if you left out pullup, than you will surely not see any changes - P168 plugin automatically use input_pullup for button pins)
And D1/D2 is the default I2C pins as you surely know.

riker1
Normal user
Posts: 301
Joined: 26 Dec 2017, 18:02

Re: ESP8266 Thermostat

#10 Post by riker1 » 24 Jan 2019, 18:34

ok, thanks will check that

Sounds great

riker1
Normal user
Posts: 301
Joined: 26 Dec 2017, 18:02

Re: ESP8266 Thermostat

#11 Post by riker1 » 29 Jan 2019, 17:43

Hi
nice, it is working.
Thanks

Patou
Normal user
Posts: 26
Joined: 21 May 2018, 10:33

Re: ESP8266 Thermostat

#12 Post by Patou » 02 Feb 2019, 20:42

Hello enesbcs,
Very nice project and clear explanations
I will start to build your project for my house
Can I ask 2 questions ? :
- Can we use as temperature sensing device also a BME 280 ?
- Can we integrate in your project a clock task to change the temp setpoint for high to low following day/night
Or is it easier to do this with Domoticz ?
Thanks in advance
Patou

kimot
Normal user
Posts: 151
Joined: 12 Oct 2017, 20:46

Re: ESP8266 Thermostat

#13 Post by kimot » 03 Feb 2019, 11:35

It is very easy schedule temperature setting from Domoticz.
When I was planning my heating regulator, I imagined a similar sophisticated device with a display and buttons.
But the circumstances forced me to make the quick fix, that I have achieved with ESPeasy and Domoticz.
And now almost after two years of operation, I see that it is fully enough to control the heating in my house.
The regulation is performed by ESPEases itself by means of rules and setting of parameters and passing of results (display of temperatures, consumption report, planning, etc.) is ensured by Domoticz.
The display and buttons on the regulators do not miss me, even though I'm thinking about displaying some information - like outside temperatures on some of the visible regulators.

My old version with Wemos D1 and ESPeasy _dev13 ( very very slow responses ) you can see here:

https://www.youtube.com/watch?v=1ef6tRinOQ4

Now I have regulators built on Sonoff Basic with ESPEasy v2.0 and everything is much much faster.

Some sreenshots:
regulator.jpg
regulator.jpg (843.46 KiB) Viewed 2140 times
Screenshot_3.png
Screenshot_3.png (135.58 KiB) Viewed 2140 times
Screenshot_2.png
Screenshot_2.png (204.1 KiB) Viewed 2140 times
2018-12-28-183359_1920x1080_scrot.png
2018-12-28-183359_1920x1080_scrot.png (161.48 KiB) Viewed 2140 times

User avatar
enesbcs
Normal user
Posts: 368
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: ESP8266 Thermostat

#14 Post by enesbcs » 03 Feb 2019, 16:25

Patou wrote:
02 Feb 2019, 20:42
- Can we use as temperature sensing device also a BME 280 ?
You can use any temperature sensing device, that ESPEasy supports.
Local temperature sensing is a last resort for me, as i have temperature sensors in EVERY room, and Domoticz sends the actual temperature data to the thermostat. (motion sensors helps Domoticz to decide which room needs to be monitored) - This is why i am implemented "Temperature source" setting in my plugin, which can be even a Dummy, for remote management.
Patou wrote:
02 Feb 2019, 20:42
- Can we integrate in your project a clock task to change the temp setpoint for high to low following day/night
Or is it easier to do this with Domoticz ?
I am using LUA in Domoticz to change setpoint on the device based on the Number of people present, based on the specific room temperatures, where motion detected, and of course based on time. (easy if you knew LUA)
Storing the setpoints locally in the device SPIFFS can be done with some programming in Arduino. (not so easy)
Otherwise if you have to do some local setpoint, can be done by ESPEasy rules. (not so hard)

Patou
Normal user
Posts: 26
Joined: 21 May 2018, 10:33

Re: ESP8266 Thermostat

#15 Post by Patou » 04 Feb 2019, 12:35

To enesbcs,
Thanks for your explanations. I made a test units and everything works
Also different setpoints related to time with Esp rules
To Kimot,
Thanks also for your informations, as I am only a beginner with Lua script can you send me some of yours so i can adapt them on my situation It will be easier for me than starting from scrach
Patou

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests