Thermostat
Posted: Fri Nov 06, 2015 12:00 pm
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.
Some action shots, since its a modified interp:
My development boards:
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:
Update 2015-11-07: the new temp command is now in the interpreter, the code is changed to reflect that.
Code: Select all
memclear
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:
My development boards:
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