This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DS18B20 with MOSFET - reading temperature from multiple sensors on Raspberry Pi

I am attempting to read temperature data from 10 DS18B20 sensors, not connected in parasite mode.

Here is the datesheet of ds18b20 [removed - broken link]

It happens quite often that I don't get a reading from a sensor. I read online a bit about MOSFET's and they are supposed to boost the signal as far as I understood?

Is this possible? How would I connect it and are there any recommendations on the type?

  • Hi, 

    I have moved this question to the 'Processors' community as I think they may be best placed to answer this. 

    Kind Regards,

    Ryan

  • The purpose of using a MOSFET on the OneWire bus is to supply more current to the DS18B20 during conversion, and it is recommended when the DS18B20 is exposed to temperatures higher than ~60ºC because the leakage current increases significantly. This doesn't mean "boosting the signal". But using a 5V parasitic power source instead of 3.3V can improve the signal response of the remote sensors. Also lowering the pull-up resistor value will help to reduce the slew rate an increase the current available but watch out for the Input Logic-Low level which should be kept under 0.8V, the DS18B20 RdsON os 100 ohm, it is better to keep the current under 5mA. In my tests with long cables I also found that the different cables will give you different results especially because of capacitance between the lines and shielding. I got better results with a FTP cat6 cable but using lines in different pairs, because the capacitance between the lines was significantly lower that when using wires in the same pair. connecting the shield to ground helped too because I was using the setup in a noisy environment, but I was able to use a longer cable without shielding UTP cat5. in a less noisy environment.

    If you want to use a high side MOSFET to increase the current available during conversion you have to use an extra GPIO  to control the gate, the MOSFET should be a P-Chanel type, you should use a pull-up resistor to keep the MOSFET off when the GPIO is not yet configured as an output, the MOSFET Source should be connected to the positive power supply,  and connect the drain to the OneWire bus. The MOSFET should be turned on by outputting a logic Low on the GPIO less than 10us after the CONVERT T [44h] command and should remain on for a time longer that Tconv which is 750ms for 12bit resolution and down to 93.75ms for 9bit. This will probably mean changing your libraries, I haven't seen this feature implemented in any public domain libraries so far.

    When using a MOSFET in this way the OneWire bus power should be the same as the GPIO block because if you use 5V to power the bus and the GPIO is using 3.3V the MOSFET will never turn off because Vgs will only change between 5V and 1.7V, so use the same voltage as for the GPIO block, 3.3V for the Raspberry Pi.

    In summary: To improve the signal, experiment with the pull-up resistor and bus voltage; use a less capacitive cable; try shielding; Use a MOSFET to increase the current available during conversion.

    A suitable part would be the FDV304P digital MOSFET or something similar ith is important to have low Rdson with the GPIO drive voltage, the FDV304P has less than 1.5Ω at 2.7V.

    Hope this helps.