Tell me what you want, What you really, really want.

Moderator: Mmiscool

User avatar
By Mmiscool
#55247 If you are using refer to the docs for the default pin umber used for the signal from the sensor.

the temp(0) function will return the sensors value. If you have more than one sensor connected to the same pin it will be temp(0), temp(1), ect. to read the values from each.

print temp(0)
print temp(1)

see
https://docs.google.com/document/d/1EiY ... a7768q34zs
User avatar
By Luc Volders
#55436 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