- Tue Jun 07, 2016 2:10 pm
#48728
I am working on version 2 and trying to add a few buttons to allow me to manually turn on the output device.
I added the fan on/off buttons and when i click on them they work, but only stay on for about 5 secs.
The issue is the page refresh which occurs about every 5 sec to update the temperature comparison and current temp update.
This causes the output device to go off or on depending what the current temp is.
I am trying to add a Auto or manual mode.
I need to add a Mode button which puts the program in
[b] auto or manual[/b].
Auto would let the set temperature control the output device - normal
Manual would allow the ON / OFF buttons to take control and allow the buttons to turn on/off output device., but still all the current temperature to update.
Tried all kinds of logic but not good.
CODE:
'ESPBASIC V2
'DB1820S Temp Sensor Data PIN IS D4
'Pin D2 for led or relay output
memclear
'SERIALPRINTLN "restart page"
cls
let tf = 0
let curr = 0
let setp = 31
let stat = On
let mode = manual
wprint "<head>"
wprint "<meta http-equiv='refresh'content='5;URL=/input?'>"
wprint "</head>"
wprint "<body bgcolor='lightgrey'>"
wprint "<table align='center' width='320' bgcolor='lightblue' border='6' cellpadding='5'>"
wprint "<th><h2><b>WiFi Eco Thermostat</h2></b></th>"
wprint "<th</th></table><br>"
wprint "<table align='center' width='318' bgcolor='lightblue' border='4' cellpadding='5'>"
wprint "<td>"
Button " Manual Test Fan On" [on2]
Button " Manual Test Fan Off" [off2]
wprint "</td>"
wprint "<th</th></table><br>"
wprint "<table align='center' width='240' bgcolor='#99ff66' border='4' cellpadding='3'>"
wprint "<td>"
wprint "<b>--Heat/Cooling Fan is--<b/>"
wprint htmlvar(stat)
wprint "</td>"
wprint "<th</th></table><br>"
wprint "<br><br>"
wprint "<table align='center' width='340' bgcolor='yellow' border='5' cellpadding='5'>"
wprint "<td>"
Button "Set Temperature" [setpt]
textbox setp
wprint "<th</th></table><br>"
wprint "<br>"
wprint "<table align='center' width='330' bgcolor='lightgreen' border='5' cellpadding='15'>"
wprint "<td>"
wprint "<b>Current Temp- Celsius= <b/>"
wprint htmlvar(curr)
wprint "</td>"
wprint "<th</th></table><br>"
wprint "<table align='center' width='330' bgcolor='lightgreen' border='5' cellpadding='15'>"
wprint "<td>"
wprint "<b>Current Temp- Fahrenheit= <b/>"
wprint htmlvar(tf)
wprint "</td>"
wprint "<th</th></table><br>"
wprint "<br>"
Button "Exit" [quit]
timer 5000, [refresh]
wait
[on2]
po D2 1
let stat = "ON"
Wait
[off2]
po D2 0
let stat = "OFF"
Wait
[setpt]
wprint "<head>"
wprint "<meta http-equiv='refresh' content='5;URL=/input?'>"
wprint "</head>"
Wait
[refresh]
temp 0 curr ' read current temperature for device 0 db1820
tf = curr * 9
tf = tf / 5
tf = tf + 32
if curr > setp then goto [on2] else goto [off2] 'FAN ON IF CURRENT TEMP IS GREATER THEN SETP
wait
[quit]
timer 0
wprint "<a href='/'>Menu</a>"
end
You do not have the required permissions to view the files attached to this post.