-->
Page 1 of 1

Temperature / Humidity DHT11,22 for beginners like me...

PostPosted: Sun Mar 11, 2018 6:47 pm
by Zim
I tried to achieve a "smart phone friendly page". (Thanks to heckler for the CSS example)
I am new to coding, but ESPbasic has made it fun.
Thanks MMISCOOL.


pic.jpg




Code: Select all' ESPbasic V3  is awsome
memclear
cls
tbox = "background-color:white;text-align:center;display:block;width:54px;height:32px;font-size:20;font-weight:bold;box-shadow:3px 3px black"
cell1 = "<table align='center' width='320' bgcolor='lightgreen' border='6' cellpadding='10'height='80'>"
cell2 = "<table align='center' width='320' bgcolor='red' border='6' cellpadding='5'height='80'>"
cell3 = "<table align='center' width='320' bgcolor='lightblue' border='6' cellpadding='5'height='80'>"
cell4 = "<table align='center' width='320' bgcolor='transparent' border='0' cellpadding='0'height='80'>"
butt = "background-color:white;text-align:center;display:block;width:130px;height:80px;font-size:18;font-weight:bold;border-radius:15px;box-shadow: 5px 5px darkgrey;border: 2px solid black"

wprint "<style>"
wprint "p {font-size:24px;}"
wprint "h1 {text-shadow: 2px 2px white;}"
wprint "</style>"

wprint "<body bgcolor='black'>"  'sets background color for webpage
io(pi,D1,)
DHT.SETUP(22, D1)                 'specifies DHT22 sensor connected to D1
let curr = "CAL"                  'just shows CAL until current temperature is read
let hum = "CAL"
io(po,D2,1)                       'diode indicator on D2

wprint cell1
wprint "<th><h1><b><big>Our Room Temperature</big></h1></b></th>"
wprint "<th</th></table>"
cssid htmlid(),"text-shadow: 2px 2px white;"

wprint cell2
wprint "<center><th>"
wprint "<p>Temperature</p>"
wprint "</th></center>"
wprint "<th>"
wprint "<center>"
textbox curr
wprint "</th>"
wprint "</center>"
cssid htmlid(), tbox

wprint cell3
wprint "<center><th>"
wprint "<p>Humidity</p>"
wprint "</th></center>"
wprint "<th>"
wprint "<center>"
textbox hum
wprint "</th>"
wprint "</center>"
cssid htmlid(), tbox
wprint "</table>"
wprint "<br>"
wprint cell4
wprint "<th>"
wprint "<center>"
button "Tap me to <mark>Refresh</mark>", [purge]
cssid htmlid(), butt
wprint "</th>"
wprint "</center>"
wprint "<th>"
wprint "<center>"
button "Tap me to <mark>Exit</mark>", [exit]
cssid htmlid(), butt
wprint "</th>"
wprint "</center>"
wprint "</table>"

timer 2000, [refresh]
wait

[refresh]
io(pi,D1,)
curr = int(dht.temp())  'int removes decimal
hum = int(dht.hum())
if (curr > 50) then let curr = CAL
if (hum > 100) then let hum = CAL
io(po,D2,1)
delay D2,1000
io(po,D2,0)
endif
wait

[purge]
returngui
wait

[exit]
cls
wprint "<window.close();>"
end