Post about your Basic project here

Moderator: Mmiscool

User avatar
By Rotohammer
#33275 Based on the mods i made to the interpreter at viewtopic.php?f=43&t=6229#p33254, as well as bits pulled from the examples, here is the code for a simple heater thermostat based on a DS18B20 temperature sensor:

Update 2015-11-07: the new temp command is now in the interpreter, the code is changed to reflect that.

Code: Select allmemclear
SERIALPRINTLN "restart page"
cls

let curr = 0
let setp = 30
let stat = On
wprint "<head>"
wprint "<meta http-equiv='refresh' content='5;URL=/input?'>"
wprint "</head>"

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

[on2]
po 2 0
SERIALPRINTLN "PIN 2 ON"
let stat = On
Wait

[off2]
po 2 1
SERIALPRINTLN "PIN 2 OFF"
let stat = Off
Wait

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

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

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


Some action shots, since its a modified interp:
tstat-off.jpg

tstat-on.jpg


My development boards:
dev-setup.jpg


Version 1.23 with DS18B20 mod working on GPIO5 compiled for 512k so it should run on any board.
*removed* - use the official binary now.

I use the following command in Linux to flash an image:
Code: Select all./esptool.py --port /dev/ttyUSB0 write_flash 0x00000 ESP8266Basic.cpp.bin --flash_size 4m
You do not have the required permissions to view the files attached to this post.
Last edited by Rotohammer on Sat Nov 07, 2015 7:47 am, edited 2 times in total.
User avatar
By Mmiscool
#33307 I integrated the source from your other post tonight in to the main branch. Made a change to the command. Device id is first before the variable for result to be placed in like other input commands. Updated your demo to reflect these changes. Modified code below.

Do you mind if I use this demo on the http://ESP8266Basic.com web site in the examples section?


Code: Select allmemclear
SERIALPRINTLN "restart page"
cls

let curr = 0
let setp = 30
let stat = On
wprint "<head>"
wprint "<meta http-equiv='refresh' content='5;URL=/input?'>"
wprint "</head>"

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

[on2]
po 2 0
SERIALPRINTLN "PIN 2 ON"
let stat = On
Wait

[off2]
po 2 1
SERIALPRINTLN "PIN 2 OFF"
let stat = Off
Wait

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

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

[quit]
timer 0
wprint "<a href='/'>Menu</a>"
end
User avatar
By Rotohammer
#33324
Mmiscool wrote:I integrated the source from your other post tonight in to the main branch. Made a change to the command. Device id is first before the variable for result to be placed in like other input commands. Updated your demo to reflect these changes. Modified code below.

Do you mind if I use this demo on the http://ESP8266Basic.com web site in the examples section?


That would be super! Anything I post here is for everyones benefit, so use it in any way you see fit.

I'll update my post after I test the new build so theres no out of date info there to confuse anyone.