Page 1 of 3


PostPosted: Wed Jun 15, 2016 8:43 pm
by joeman2116
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..

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
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.....
Screen Shot 06-15-16 at 10.39 PM.PNG


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

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]

po D2 1
let stat = "ON"
'if outc > 30 then goto [outcon] else goto [outcoff]
if outc > setpout then goto [outcon] else goto [outcoff] 

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]

wprint "<head>"
wprint "<meta http-equiv='refresh' content='5;URL=/input?'>"
wprint "</head>"


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

[outcon] ' OUTSIDE ON
po D5 1 'outside on
let statout = "ON"

[outcoff] '
po D5 0 'outside on
let statout = "OFF"

timer 0
wprint "<a href='/'>Menu</a>"

Have fun , hope someone finds it useful
Joe :D


PostPosted: Sun Jun 19, 2016 12:19 am
by forlotto
Wow look at you go! you came a long way from the first iterations I recall trying to help you with for now if you are going to do tables, background colors, css etc its best to stick with the 2.0 branch 3.0 branch has some ghost html bugs that are not easily understood currently.

Hopefully this will change some time down the road but for now it is summer and even the devs must have a little time to enjoy that ;)

But thumbs up I find it useful when I figure out a few other more difficult things I may just have to use parts of your code the table looks kind of neat with the contrasting colors etc and everything seems to be functioning very well from the looks of it I am however curious on the fan part of things what exactly is the fan you refer to being used for?

Do you have any pics of how you got everything wired in etc? Details on hardware and such like wiring might be important for a novice starting off and pics of the hardware how to run it keep it out of the elements etc may be all important things. I myself am curious because once and a while a user may have a much easier way of doing something then I tend to think along the lines of it is kind of like those lifehack videos you see on youtube once in a while you will find one that speaks to you saying why did I not do that all along?

Anyhow thank you for sharing joeman!



PostPosted: Fri Jul 08, 2016 9:58 pm
by joeman2116

Sorry for not getting back sooner. I have been away but will be back into playing with this project.
The exercise was to use html code examples for future projects and something practical at the same time.
There a so few full working projects with html coding, it took a while to figure the formats....
Hopefully someone will continue to add features....

The fan temperature allows you to control when a relays turns on / off the a/c outlet.

I have used several enclosures and will post pictures etc.
My latest version now has 2 db1820 temperature sensors, one controls the outlet , depending on temperature setting. The other sensor just turns a relay on or off.
I keep one sensor in the room, close to the unit and the other inside the A/C vent - provides a live view how cool the central air vent is compared to actual room.
I would like to some more features, email notification etc



PostPosted: Sat Jul 09, 2016 4:09 am
by forlotto
Yes I believe html is still currently facing bug status in version 3.x this one must be a fairly impossible thing to track down the odd thing is you can build a webpage with msgbranch and it works if done correctly the tags work but as far as html another way it is still a no go but if done correctly you can do some fairly radical stuff with msgbranch I've toyed with it quite a bit but a lot has changed in this as well from 2.x to 3.x and some of the changes have crippled its ability to some degree.

Anyhow maybe someday these thing will be addressed it is hard saying for sure as the bug for one is difficult to pin down when your html page displays things as correct even though it does not show however it does insert a meta tag at the beginning of all code inserting websockets.js as well... Personally I do not know the fix for this either. But 2.x branch does work. For all I know one of the last two uploads fixed things a bit I have missed this if it was done so far but... Anyhow still good work thanks for responding.