ESP8266 / ESPEasy Thermostat for Domoticz

Everything about esp8266 and more.
Post Reply
davidlightsa
Posts: 5
Joined: Tuesday 20 December 2016 11:25
Target OS: Raspberry Pi
Domoticz version:
Contact:

ESP8266 / ESPEasy Thermostat for Domoticz

Post by davidlightsa » Tuesday 20 December 2016 11:45

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 11:25
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by davidlightsa » Wednesday 04 January 2017 13:59

Any ideas? Please... :?:

maluko
Posts: 223
Joined: Monday 03 February 2014 0:57
Target OS: Raspberry Pi
Domoticz version:
Location: Portugal
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by maluko » Wednesday 04 January 2017 14:37

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 11:25
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by davidlightsa » Monday 09 January 2017 15:05

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 12:24
Target OS: -
Domoticz version:
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by therascal » Saturday 11 March 2017 12:32

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: 548
Joined: Tuesday 09 December 2014 18:04
Target OS: Raspberry Pi
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by Westcott » Saturday 11 March 2017 19:37

Hi TheRascal,
Your code is neat!
You've done the bit I was trying to do.
Zwave - Sigma Z+ stick, Fibaro 2x FGSD002, FGMS001
Horstmann - 2x HRT4, 2x C-stat-11, 4x ASR-ZW, TKB 2x TZ56, 2x TZ68E
Max-EQ Cube, Valve, Neo 2x door
RFXtrx433E, RFlink - 1byone driveway, doorbell, Oregon and BangGood temp
Wifi - YeeLight RGB, 3x ESP8266

Remicade
Posts: 12
Joined: Friday 15 September 2017 21:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by Remicade » Friday 29 September 2017 17:40

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: 54
Joined: Saturday 25 November 2017 18:18
Target OS: Raspberry Pi
Domoticz version: v3.8153
Location: Czech Rep.
Contact:

Re: ESP8266 / ESPEasy Thermostat for Domoticz

Post by kimot » Wednesday 29 November 2017 23:34


Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests