THERMOSTAT :ESPBASIC V2 -MULITPLE SENSORS AND HTML FORMATS
Posted: Wed Jun 15, 2016 8:43 pm
Thanks to Rotohammer for initial development of this project.
I have been plugging away at this program , adding new features and lots of html formats etc.
I am posting the results so others can have a working program with actual examples of various formats for hardware and html codes to enhance the appearance. It has taken several weeks to experiment and trial and error.
There are so few working program examples that it makes it difficult for the new learner like me, so hopefully,
this will provide a kickstart and maybe someone else can add new features etc..
Hardware:
I flashed this code on a D1 mini and also on a esp12e. - both work fine
I also took an "Eco Plug module" - Home depot sold them. cheap wall outlet controller
and took it apart to find it had an esp8266 - but could not program it.
So I removed it and mounted the D1 mini. The existing unit already had the correct voltages.
I just clipped the old esp module and used the 3 wires from the eco.
Vcc -3.4
gnd
data
I feed them to my d1 mini, and now with the new code It turns on and off the A/C outlet
I mounted 2 temp sensors DS18B20 - Working great - inside and outside temperatures
and can control of the builtin A/C plug to tun on/off a fan etc.....
CODE:
Have fun , hope someone finds it useful
Joe
I have been plugging away at this program , adding new features and lots of html formats etc.
I am posting the results so others can have a working program with actual examples of various formats for hardware and html codes to enhance the appearance. It has taken several weeks to experiment and trial and error.
There are so few working program examples that it makes it difficult for the new learner like me, so hopefully,
this will provide a kickstart and maybe someone else can add new features etc..
Hardware:
I flashed this code on a D1 mini and also on a esp12e. - both work fine
I also took an "Eco Plug module" - Home depot sold them. cheap wall outlet controller
and took it apart to find it had an esp8266 - but could not program it.
So I removed it and mounted the D1 mini. The existing unit already had the correct voltages.
I just clipped the old esp module and used the 3 wires from the eco.
Vcc -3.4
gnd
data
I feed them to my d1 mini, and now with the new code It turns on and off the A/C outlet
I mounted 2 temp sensors DS18B20 - Working great - inside and outside temperatures
and can control of the builtin A/C plug to tun on/off a fan etc.....
CODE:
Code: Select all
'ESPBASIC V2 A24
' DS18B20 Temp Sensor Data PIN IS D4
'Pin D2 for led or relay output inside
'Pin D5 for led or relay output outside
memclear
cls
let tf = 0
let tfout = 0
let curr = 0
let setp = 31
let stat = On
let outc = 0 'for second temp sensor
let statout = On
let setpout = 31
wprint "<head>"
wprint "<meta http-equiv='refresh'content='5;URL=/input?'>"
wprint "</head>"
wprint "<body bgcolor=' #000033'>"
wprint "<table align='center' width='340' bgcolor='#ffb31a' border='6' cellpadding='5'>" '#ffb31a
wprint "<th><h1><span style='color:blue'>WiFi Eco</span>Thermostat </h1></th"
'wprint "<th><h1><b>WiFi Eco Thermostat</h1></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" [fon2]
'Button " Manual Test Fan Off" [off2]
'wprint "</td>"
'wprint "<th</th></table><br>"
wprint "<table align='center' width='240' bgcolor='#33cc33' border='4' cellpadding='3'>"
wprint "<td>"
'wprint "<mark><b>-----INSIDE -- FAN--<b/></mark>"
wprint "<b>-----INSIDE -- FAN--<b/>"
wprint "<mark>"
wprint htmlvar(stat)
wprint "</mark>"
wprint "<br>"
wprint "</td>"
wprint "<th</th></table>"
wprint "<br>"
wprint "<table align='center' width='330' bgcolor='#33cc33' border='5' cellpadding='6'>"
wprint "<td>"
wprint "<b>Inside Temp- Celsius= <b/>"
wprint htmlvar(curr)
wprint "</td>"
wprint "<th</th></table><br>"
wprint "<table align='center' width='330' bgcolor='#33cc33' border='5' cellpadding='6'>"
wprint "<td>"
wprint "<b>Inside Temp- Fahrenheit= <b/>"
wprint htmlvar(tf)
wprint "</td>"
wprint "<th</th></table><br>"
wprint "<table align='center' width='350' bgcolor='#33cc33' border='5' cellpadding='5'>"
wprint "<td>"
Button "Set INSIDE Temp" [setpt]
textbox setp
wprint "<th</th></table><br>"
wprint "<br>"
wprint "<table align='center' width='240' bgcolor='#00cc99' border='4' cellpadding='3'>"
wprint "<td>"
wprint "<b>-----OUTSIDE FAN--<b/>"
wprint "<mark>"
wprint htmlvar(statout)
wprint "</mark>"
wprint "</td>"
wprint "<th</th></table><br>"
'wprint "<br><br>"
wprint "<table align='center' width='355' bgcolor='#00cc99' border='5' cellpadding='5'>"
wprint "<td>"
Button "Set OUTSIDE Temp" [setpt]
textbox setpout
wprint "<th</th></table><br>"
wprint "<table align='center' width='330' bgcolor='#00cc99' border='5' cellpadding='6'>"
wprint "<td>"
wprint "<b>Outside Temp -Celsius= <b/>"
wprint htmlvar(outc)
wprint "</td>"
wprint "<th</th></table><br>"
wprint "<table align='center' width='330' bgcolor='#00cc99' border='5' cellpadding='6'>"
wprint "<td>"
wprint "<b>Outside Temp- Fahrenheit= <b/>"
wprint htmlvar(tfout)
wprint "</td>"
wprint "<th</th></table><br>"
'wprint "<table align='center' bgcolor='#00e6ac' border='5' cellpadding='5'>"
'wprint "<td>"
'wprint "<a href='http://urlxxxxxxxxxx/'>ESP CONTROL66</a>"
'wprint "</td>"
'wprint "</table><br>"
'wprint "<br>"
Button "Exit" [quit]
timer 5000, [refresh]
wait
[on2]
po D2 1
let stat = "ON"
'if outc > 30 then goto [outcon] else goto [outcoff]
if outc > setpout then goto [outcon] else goto [outcoff]
Wait
[off2]
po D2 0
let stat = "OFF"
'if outc < 30 then goto [outcoff] else goto [outcon] ' for a set value instead of set temp
if outc < setpout then goto [outcoff] else goto [outcon]
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
temp 1 outc ' read current temperature for device 1 db1820
tf = curr * 9
tf = tf / 5
tf = tf + 32
tfout = outc * 9
tfout = tfout / 5
tfout = tfout + 32
if curr > setp then goto [on2] else goto [off2] 'FAN ON IF CURRENT TEMP IS GREATER THEN SETP
wait
[outcon] ' OUTSIDE ON
po D5 1 'outside on
let statout = "ON"
wait
[outcoff] '
po D5 0 'outside on
let statout = "OFF"
wait
[quit]
timer 0
wprint "<a href='/'>Menu</a>"
end
Have fun , hope someone finds it useful
Joe