1

I have a DS18B20 temperature sensor which I am trying to use in parasite power mode with only two wires (data line and ground) with my Raspberry Pi Zero W. I've connected it to the RPi in the following way:

enter image description here

 (i.e. GND DS18B20 -> GND   RPi
       DQ  DS18B20 -> GPIO4 RPi
       Vdd DS18B20 -> GND   RPi)

As per pg. 4 of the temp sensor datasheet the Vdd pin must be tied to ground in parasite power mode.

I'm using Timo Furrer's Python package and CLI tool, w1thermsensor, to interface with the temp sensor. The command line interface provides a way to list all OneWire temperature sensors connected to the bus with: w1thermsensor ls

In /boot/config.txt, I've added the line dtoverlay=w1-gpio,pullup=1 but when I run w1thermsensor ls at the command line, it returns Found 0 sensors:

I've read on more than one forum that you must use an external 4.7K pullup resistor between 3V3 and the GPIO pin, but I struggle to see why this is the case. Doesn't the above addition to config.txt connect the internal pullup resistor between 3V3 and GPIO4 (GPIO4 is default for w1-gpio overlay), and hence I wouldn't need to use an external pullup?

I did find on this Github comment that the pullup in a RPi can be 50-60KOhms, so may not supply enough current? In the same Github comment a "use-at-your-own-risk overlay" called w1-gpio-intpullup-overlay.dtb is provided for download. But how would that differ from adding dtoverlay=w1-gpio,pullup=1 to /boot/config.txt?

TL;DR - I'm trying to use the DS18B20 temperature sensor in parasite power mode using only the data line and ground connections, and activating the internal pullup resistor on the data line instead of using an external pullup. However, the command line interface I'm using isn't registering the sensor in this configuration.

  • 1
    Why are you trying to just use 2 wires? – CoderMike Feb 22 at 9:51
  • It's more convenient and cleaner than having to solder an external pullup in. – Adrian Feb 22 at 9:55
1

Without the resistor you need to supply the DS18B20 with an external power source.

A 4,7K resistor is the commonly used for parasitic power.

The data sheet notes (https://datasheets.maximintegrated.com/en/ds/DS18B20-PAR.pdf):

Another feature of the DS18B20 is the ability to operate without an external power supply. Power is instead supplied through the 1-Wire pullup resistor through the DQ pin when the bus is high. The high bus signal also charges an internal capacitor (CPP), which then supplies power to the device when the bus is low. This method of deriving power from the 1-Wire bus is referred to as “parasite power.” As an alternative, the DS18B20 may also be powered by an external supply on VDD.

The internal resistor is 10x higher so its not suitable.

  • Ah ok, I thought that might be the case. Although when I measured the voltage between GND and GPIO4 in the w1-gpio,pullup=1 state, the voltage was around 0.2-0.3V, whereas if I omit that from the config file and instead run the following in python: – Adrian Feb 22 at 18:27
  • GPIO.setmode(GPIO.BCM) GPIO.setup(4,GPIO.IN,pull_up_down=GPIO.PUD_UP) the voltage I measure is around 3.3V I would have thought that both would read the same voltage because in both cases the internal pullup is activated, no? – Adrian Feb 22 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.