-->
Page 1 of 1

DS1820 temperature sensor read/write with ESPBASIC

PostPosted: Fri Sep 16, 2016 7:49 am
by gilli
Hello , Fitst Congratulation to this super ESPBASIC.
I would like to know how to manage the temp sensor DS1820 in ESPBASIC.
thanks
Gilli

Re: DS1820 temperature sensor read/write with ESPBASIC

PostPosted: Fri Sep 16, 2016 4:34 pm
by Mmiscool
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

Re: DS1820 temperature sensor read/write with ESPBASIC

PostPosted: Fri Sep 16, 2016 5:34 pm
by livetv
See the thread below. About 6 posts in, I present a long and thorough dissertation on the DS18B20 and things you should know when using it with ESPbasic.

viewtopic.php?f=45&t=11522

Re: DS1820 temperature sensor read/write with ESPBASIC

PostPosted: Tue Sep 20, 2016 1:48 pm
by Luc Volders
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