-->
Page 11 of 19

Re: Thermostat

PostPosted: Tue Jun 07, 2016 4:26 pm
by Electroguard
If you want to switch to manual control, just disable your timer to stop it keeping on re-reading the sensor and doing any more logic comparisons...

To Disable timer:

timer 0

Re: Thermostat - Timer

PostPosted: Wed Jun 08, 2016 1:37 pm
by joeman2116
Electroguard,

The timer is a good point.

If I point the button to the sub routine which turns on the output device, and add the timer 0, the output does stay on or off by the buttons.
But now it wont allow me to return to normal auto operations where it uses the set temperature to control off or on.
I tried adding timer 4000 in several locations but never solved the problem.

joe

Re: Thermostat

PostPosted: Wed Jun 08, 2016 7:28 pm
by joeygbsn
This is an updated version of the original program for 3.0. This uses the returngui command to refresh the page.

Joeman, if I was you I would set some sort of flag for manual control. let flag = 1 when you press the manual on button, and then test for the flag in the on and off routine. Because now if you turn it on, but the temp is still above the setpoint, it will try to turn off during the next refresh. So you test whether or not flag = 1 before you turn the pin off again. If flag = 1 keep pin on. I hope that makes sense.

Code: Select allmemclear
SERIALPRINTLN "restart page"
cls

let curr = 0
let setp = 30
let stat = On

Print "ESP8266 WiFi Thermostat "
print
Button "Setpoint", [setpt]
textbox setp
wprint "<br>"
wprint "CurrTemp="
wprint htmlvar(curr)
wprint "<br>"
wprint "Heater="
wprint htmlvar(stat)
wprint "<br>"
button "Exit", [quit]
timer 4000, [refresh]
wait

[on2]
io(po,16,1)
SERIALPRINTLN "PIN 2 ON"
let stat = "On"
returngui
Wait

[off2]
io(po,16,0)
SERIALPRINTLN "PIN 2 OFF"
let stat = "Off"
returngui
Wait

[setpt]
returngui
Wait

[refresh]
curr = temp(0)
SERIALPRINTLN curr
if curr < setp then goto [on2] else goto [off2]
Wait

[quit]
timer 0
wprint "<a href='/'>Menu</a>"
end

Re: Thermostat

PostPosted: Wed Jun 08, 2016 7:44 pm
by joeygbsn
Or you could just stick with the timer idea and create another button to set the timer back to whatever.