the following is actually two questions.
according to what i can find on the net, almost everybody is telling me that i need a 4.7k pull up resistor on the data line, when connecting the Dallas Semiconductor One Wire temperature sensor:
https://www.analog.com/media/en/technical-documentation/data-sheets/ds18b20.pdf
admit i am very rusty, been 40 years since i studied these things, but according to my reading of the spec, the sensor pulls 1.5 mA at most on the power pin, and 5 uA at most on the data pin.
am using raspberry picoW in this design, they embed the RP2040 chip:
https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
i am not using "parasitic power" in my application, and i will not be chaining devices on the data line, there is only one sensor per pico.
according to the RP2040 specs, "Output drive strength can be set to 2mA, 4mA, 8mA or 12mA"
i found one circuit where it appears someone has tested this sensor without an external pull up resistor:
https://robocraze.com/blogs/post/ds18b20-with-raspberry-pi-pico-using-micropython
and i have done the same - i can confirm this works, so far reliably over 48 hours, but i cannot work out if i risk damaging the pico, doing this.
so the first question - is the pico internal GPIO strong enough to handle the DS18B20 DQ line, without an external pull up?
the DS18B20 is currently being powered by a GPIO output pin, connected directly to VDD on the sensor.
it seems that even the minimum GPIO drive on the RP2040 is more than enough to power the DS18B20.
and so my second question is - am i right to believe that a single DS18B20 can safely be powered by one pico GPIO output?
according to what i can find on the net, almost everybody is telling me that i need a 4.7k pull up resistor on the data line, when connecting the Dallas Semiconductor One Wire temperature sensor:
https://www.analog.com/media/en/technical-documentation/data-sheets/ds18b20.pdf
admit i am very rusty, been 40 years since i studied these things, but according to my reading of the spec, the sensor pulls 1.5 mA at most on the power pin, and 5 uA at most on the data pin.
am using raspberry picoW in this design, they embed the RP2040 chip:
https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
i am not using "parasitic power" in my application, and i will not be chaining devices on the data line, there is only one sensor per pico.
according to the RP2040 specs, "Output drive strength can be set to 2mA, 4mA, 8mA or 12mA"
i found one circuit where it appears someone has tested this sensor without an external pull up resistor:
https://robocraze.com/blogs/post/ds18b20-with-raspberry-pi-pico-using-micropython
and i have done the same - i can confirm this works, so far reliably over 48 hours, but i cannot work out if i risk damaging the pico, doing this.
so the first question - is the pico internal GPIO strong enough to handle the DS18B20 DQ line, without an external pull up?
the DS18B20 is currently being powered by a GPIO output pin, connected directly to VDD on the sensor.
it seems that even the minimum GPIO drive on the RP2040 is more than enough to power the DS18B20.
and so my second question is - am i right to believe that a single DS18B20 can safely be powered by one pico GPIO output?
micropython for above:
class DSTemp:
def __init__ ( self, power_pin, sense_pin, power_ms = 500, sense_ms = 500 ):
self.power_pin = machine.Pin( power_pin, mode = machine.Pin.OUT, value = 0 )
self.sense_pin = machine.Pin( sense_pin )
self.power_ms = power_ms
self.sense_ms = sense_ms
self.lock = asyncio.Lock()
self.state = False
def active( self, state=True ):
await self.lock.acquire()
if self.state != state:
self.power_pin.value( state )
if( state ): await asyncio.sleep_ms( self.power_ms )
self.state = state
self.lock.release()
return self.state
def sensor( self ):
await self.lock.acquire()
if self.state:
ds = ds18x20.DS18X20( onewire.OneWire( self.sense_pin ) )
roms = ds.scan()
print( roms )
ds.convert_temp()
await asyncio.sleep_ms( self.sense_ms )
if len(roms):
pad = ""
for rom in roms:
print( hexlify(roms).decode(), ":", "%6.1f" % (ds.read_temp(s)))
pad = pad + "%.2fC " % ds.read_temp( rom )
else: pad = "no sensors"
else: pad = "power is off"
self.lock.release()
return pad
and is called as follows:
dsTemp1 = DSTemp( 0, 1 )
await dsTemp1.active()
result = await dsTemp1.sensor()
Last edited: