Post about your Basic project here

Moderator: Mmiscool

User avatar
By joeman2116
#48798 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
User avatar
By joeygbsn
#48818 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
User avatar
By joeygbsn
#48819 Or you could just stick with the timer idea and create another button to set the timer back to whatever.