0

I have added 2 DS18B20 sensors to my Raspberry pi 1, both sensors shows up in /sys/bus/w1/devices and I can only read data from one of them, the other simply has a empty w1_slave file.

They are not both connected to the same pins, the working one is connected to GPIO14 and the one not working but listed is connected to GPIO17.

I have this in my /boot/config.txt file:

dtoverlay=w1-gpio,gpiopin=14
dtoverlay=w1-gpio,gpiopin=17

and I use this script to pull up the resistor:

import RPi.GPIO as GPIO

GPIO_PIN_NUMBER=17
GPIO.setmode(GPIO.BCM)
GPIO.setup(GPIO_PIN_NUMBER, GPIO.IN, pull_up_down=GPIO.PUD_UP)

There is 2 of those files where the other one has GPIO_PIN_NUMBER=14

In /sys/bus/w1/devices I see this:

28-00000003ae63  28-00000003c175  w1_bus_master1  w1_bus_master2

And the 28-00000003c175 is the working one which reports the temperature but the 28-00000003ae63 has the empty w1_slave file.

7
  • I have tried swithing the non working to GPIO4 with same result, I have also tried switching the sensor to a new one, same result.
    – HDIK
    Commented Apr 7, 2022 at 14:32
  • Have you tried connecting both to GPIO 14 (1-wire is a bus) to check that both work?
    – joan
    Commented Apr 7, 2022 at 16:33
  • @joan, hello. Yes, I have tried that and if I use GPIO14 for both, they both works (not when both are connected tho) but one by one they both works. And I believe that, if the system can see the device, then it "should" work, but there most be sth I do wrong since the w1_slave file is empty.
    – HDIK
    Commented Apr 7, 2022 at 16:38
  • 1-wire is a bus. You can have multiple 1-wire devices connected to the same GPIO at the same time.
    – joan
    Commented Apr 7, 2022 at 16:40
  • Yes, I know that, but no matter how I do it or which raspberry version I use, then it doesn't work. and I only need these 2 sensors, so using 2 channels doesn't hurt I guess, since using same fails everytime.
    – HDIK
    Commented Apr 7, 2022 at 16:42

2 Answers 2

1

I've found out that the cause of this is the cat6 cable I was using to extend the cable of the sensor, putting the sensor directly to the pin makes it works as should, so I just need to figure out what cable to use instead.

1

Use a 3K to 4K resistor or something close, the added cable increases the capacitance slowing it down.

1
  • Plus, Raspberry has inbuilt pull up which is more than enough.
    – HDIK
    Commented Apr 8, 2022 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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