Here is a very simple thermometer using a DS1820.
I am using the nodeMCU board and have attached the DS1820 to digital i/o D4.
VCC goes to VCC, GND goes to GND and the data line is attached to D4.
A pull up resistor of 4k7 is attached between the VCC and D4 line.
Software is very simple but gives a nice webpage with the temperature and a simple meter that constant displays wether the temperature is rising or falling.
Code: Select allmemclear
cls
temnow = temp(0)
temnow = int(temnow * 10)
temnow = temnow / 10
wprint "<!DOCTYPE html>"
wprint "<html> <body>"
wprint |<body style="background-color:powderblue;">|
wprint |<H1><span style="color: red;">|
wprint "Thermometer"
wprint "</H1>"
wprint "</span>"
wprint |<H2><span style="color: blue;">|
wprint "Temperature = "
wprint temnow
wprint "</span>"
wprint "</H2>"
meter temnow, 0, 40
wprint "<br>"
wprint "<br>"
button "Again", [again]
wprint "............"
button "Stop", [quit]
timer 1000, [refresh]
wait
[refresh]
temnow = temp(0)
Wait
[again]
timer 0
run
wait
[quit]
end
As a matter of fact this was my first real self-edited basic program and now I realise how easy and well-done this programming language is.
Thanks MMISCOOL.
Luc