Tyrone Smith 08/20/2024 06:54 AMI'm trying to use multiple DS18b20 temperature sensors:
import gpio // Sensors
import ds18b20 show Ds18b20 // Temperatursensor
GPIO-PIN-NUM1 ::= 2 // Outside Temperature GPIO
GPIO-PIN-NUM2 ::= 5 // Inside top Temperature GPIO
main:
temp1 := gpio.Pin GPIO-PIN-NUM1 --input --pull-up=true //Temperature-sensor Outside
ds1 := Ds18b20 temp1
temp2 := gpio.Pin GPIO-PIN-NUM2 --input --pull-up=true //Temperature-sensor Outside
ds2 := Ds18b20 temp2
temperatur1 := ds1.read-temperature // Outside
temperatur2 := ds2.read-temperature // Inside top
print "Temperatur 1: $temperatur1"
print "Temperatur 2: $temperatur2"
I found this comment in the ds18b20.toit lib but i honestly don't know how to make use of it.
Assumes there is only one sensor connected to the given $pin.
If there are multiple sensors, then the driver misbehaves. In that
case use $(Ds18b20.constructor --id --bus) instead.
(edited)