CODE: xxxx.bas
onHtmlReload create_page
onhtmlchange update
D1 = 5 ' temp/hum sensor DTH22
DHT.SETUP 5, 22
tmp = DHT.TEMP
hm = DHT.HUM
wtr$ = "NO"
txtbtmp$ = "background-color:white;text-align:center;display:block;width:54px;height:42px;font-size:30;font-weight:bold"
txtbwtr$ = "background-color:white;text-align:center;display:block;width:60px;height:42px;font-size:30;font-weight:bold"
txtbhm$ = "background-color:red;text-align:center;display:block;width:54px;height:42px;font-size:30;font-weight:bold"
gosub create_page
timer0 2000, update
wait
create_page:
cls
A$ = ""
A$ = A$ + |<!DOCTYPE html><html><body><style>|
A$ = A$ + |body {background-color: black;}|
A$ = A$ + |p {font-size:24px;}|
A$ = A$ + |</style>|
A$ = A$ + |<table align='center' width='300' height='100' bgcolor='lightgreen' border='1' cellpadding='8'>|
A$ = A$ + |<th>|
A$ = A$ + |<p>Basement<br>Temp.</p></th></center>|
A$ = A$ + |<th><center>|
A$ = A$ + textbox$(tmp, "txt1")
A$ = A$ + |</th></center>|
A$ = A$ + cssid$("txt1", txtbtmp$)
A$ = A$ + |</table>|
A$ = A$ + |<table align='center' width='300' height='100' bgcolor='lightgreen' border='1' cellpadding='8'>"|
A$ = A$ + |<center><th>|
A$ = A$ + |<p>Basement<br>Humidity</p>|
A$ = A$ + |</th></center>|
A$ = A$ + |<th><center>|
A$ = A$ + textbox$(hm, "txt2")
A$ = A$ + |</th></center>|
A$ = A$ + cssid$("txt2", txtbhm$)
A$ = A$ + |</table>|
A$ = A$ + |<table align='center' width='300' height='100' bgcolor='lightgreen' border='1' cellpadding='8'>"|
A$ = A$ + |<center><th>|
A$ = A$ + |<p>Water<br>Detection</p>|
A$ = A$ + |</th></center>|
A$ = A$ + |<th><center>|
A$ = A$ + textbox$(wtr$, "txt3")
A$ = A$ + |</th></center>|
A$ = A$ + cssid$("txt3", txtbwtr$)
A$ = A$ + |</table>|
HTML A$
A$ = ""
autorefresh 1000
return
update:
tmp = DHT.TEMP
hm = DHT.HUM
pause 200
if hm > 30 then txtbhm$ = "background-color:red;text-align:center;display:block;width:54px;height:42px;font-size:30;font-weight:bold" else txtbhm$ = "background-color:white;text-align:center;display:block;width:54px;height:42px;font-size:30;font-weight:bold"
refresh
return