ESP8266 / ESPEasy Thermostat for Domoticz

Everything about esp8266 and more.

Moderator: leecollings

Post Reply
davidlightsa
Posts: 5
Joined: Tuesday 20 December 2016 10:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

ESP8266 / ESPEasy Thermostat for Domoticz

Post by davidlightsa »

Hi Folks, first post here. Been playing with ESPEasy on both NodeMCU and Sonoff ESP8266 WiFi switches for a while. I'm running Domoticz on a RPi3 and have also installed Homebridge and MQTT for HomeKit support (although I can't seem to get MQTT to start up correctly BEFORE Homebridge on boot).

Anyway, to the point of this post: In South Africa (where I'm from) we mostly use electric water heaters with a 100 - 200-litre cylinder. Inside the cylinder is a heating element and a thermostat. The thermostats are set once and then the element will turn ons and off as the thermostat desires. Problem is, the water heater is in the roof, and so turning the system on and off or adjusting the temperature (say downwards in summer is a PITA).

For my next home automation project I'd like to use Domoticz and HomeKit to set the temperature of, and also to turn the water heater on only when we're home. I've decided to use a NodeMCU (ESP12) running ESPEasy with a 100A Solid State Relay (SSR) and a DS18B20 on a 1m cable (which I plan to attach to the outlet pipe with thermal paste at the outlet of the water heater (it's a copper pipe so closely representative of the temperate inside the cylinder). As the SSR will be inline to the AC supply to the water heater, it will effectively 'override' the water heater (turning it off as programmed) and only up to the temperature set on the water heater's built in thermostat. I want to use it this way for two reasons: 1.) I can set a 'safe' temperature on the water heater so as to prevent it from boiling if there is a problem with my design; and 2.) if the home automation is not functional the water heater will work on the built-in thermostat as it is now. For the latter arrangement I am building my circuit so that the SSR is normally closed (so to speak).

Where I'm at now: I've configured the DS18B20 and switch on both the NodeMCU and in Domoticz, and I can read and write both respectively. I've created a virtual thermostat, but cannot figure out how to interface the input temperature from the water heater and then using the thermostat to perform the switching. I'm hoping someone here can help me write the logic in Domoticz please?
davidlightsa
Posts: 5
Joined: Tuesday 20 December 2016 10:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by davidlightsa »

Any ideas? Please... :?:
maluko
Posts: 105
Joined: Sunday 02 February 2014 23:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Portugal
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by maluko »

i think that you want use rules on espeasy.
see the forum and wiki.
http://www.letscontrolit.com/
davidlightsa
Posts: 5
Joined: Tuesday 20 December 2016 10:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by davidlightsa »

Thanks for the reply. I've done some further reading on using rules, and while I can see how rules could work, I'm not clear how the SetPoint virtual device in Domoticz would be used to set/update the switching value on the node.

How are domestic water heating systems which are incorporated into home automation controlled?
therascal
Posts: 1
Joined: Saturday 11 March 2017 11:24
Target OS: -
Domoticz version:
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by therascal »

I use this to set a set point in domoticz and use the sonoff to check the temp again the setpoint evey 120 secs. Use the one at the bottom and the setpoint code in domoticz. the Sonoff th is on 192.168.1.200


At the moment I have a Domoticz server running on a Raspberry which i Can send a set point using the code below.

This works well, as long as i resend the data from Domoticz ever few minutes as it only checks that once and makes a decision to turn on or off GPIO 12.
After the temperature has dropped to below the set point it will not turn off until i send the setpoint again from Domoticz.

The question is
Can i make the esp8266 compare the set point to the room temperature every 60 secs, just encase the Domoticz goes down or a lose Wifi.

Domoticz

Code: Select all

commandArray = {}
        if devicechanged['Tent Temp Fan Control Setpoint'] then
   DomDevice = 'Tent Temp Fan Control Setpoint'
         DomValue = otherdevices_svalues[DomDevice]
         CalcValue = (DomValue*1)
         print(CalcValue)
         url= 'http://192.168.1.200/control?cmd=event,FanSetpoint='..(CalcValue)..''
         commandArray['OpenURL']= url
end
return commandArray 
In the esp8266 i have this running as a rule

Code: Select all

on FanSetpoint do
 TaskValueSet 3,1,%eventvalue%
  if [Room#Temperature]>[RoomTemp#Temp] do
   GPIO,12,1
   else
   GPIO,12,0
   endif
endon
Room#Temperature Is the Actual temp
RoomTemp#Temp is the setpoint sent via FanSetpoint.

In The ESP i have a Dummy device setup in Location 3 and

1 Temperature & Humidity - DHT Room 23 GPIO-14 Temperature: ¬¬¬¬¬¬¬
2 Switch input FanRelay 28 GPIO-12 State:¬¬¬¬¬¬¬ I use this to tell Domoticz The relay is on or off
3 Dummy Device RoomTemp Temp: THE SETPOINT SENT FROM DOMOTICZ


Thanks so much for Looking and at least thinking about it.
Last edited by The_Rascal on 09 Mar 2017, 21:54, edited 1 time in total.
Top
The_Rascal
Normal user
Posts: 3
Joined: 09 Mar 2017, 01:56
Re: Checking a Temperature against a setpoint
Quote
#2 Post by The_Rascal » 09 Mar 2017, 21:47

If been thinking overnight,

Please keep in mind this is the first code i have ever written.

After trail and error this seems to work

Code: Select all

on System#Boot do
  TaskValueSet 3,1,24                                                   // 24 is a setpoint to return to if power is turned off.
  TimerSet,2,60                                                           // 60 seconds to then start Temp-Watchdog.
endon

on FanSetpoint do
  TaskValueSet 3,1,%eventvalue%                  
  TimerSet,1,10                                                           // 10 seconds after a setpoint has been received restart Temp-Watchdog 
endon

on Rules#Timer=1 do
    event,Temp-Watchdog 
endon

on Temp-Watchdog do
  if [Room#Temperature]>[RoomTemp#Temp] do
   GPIO,12,1
   else
   GPIO,12,0
   endif
   TimerSet,2,120                                                         // 120 second THEN restart whole check of setpoint to actual temp.
endon

on Rules#Timer=2 do
    event,Temp-Watchdog
endon
I was hoping someone might be able to check the code over and see if it can be compressed or improved. I know it looks crap, but im over the moon it works.

Thanks The_Rascal...
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by Westcott »

Hi TheRascal,
Your code is neat!
You've done the bit I was trying to do.
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
Remicade
Posts: 26
Joined: Friday 15 September 2017 21:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Netherlands
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by Remicade »

Hi there,
Do you think this will work for my floorheating?
Can you tell some more about the buttons used in domoticz?
I will try your setup anyway, thanks for sharing!
Cheers Paul
kimot
Posts: 104
Joined: Saturday 25 November 2017 17:18
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Czech Rep.
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by kimot »

RPi2 Domoticz v 4.10717
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
Kruu
Posts: 49
Joined: Tuesday 17 January 2017 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by Kruu »

Old topic, but did'nt want to open another one.

I would like to make something like this:
https://diyprojects.io/esp-easy-rules-s ... -node-red/

Esp8266 thermostat with OLED display and + - buttons. Do you guys have any other idea than the one on the link.


So would like to have, SET temperature, Curent temperature. and + - controlls with buttons.
kimot
Posts: 104
Joined: Saturday 25 November 2017 17:18
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Czech Rep.
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by kimot »

RPi2 Domoticz v 4.10717
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests