4

I have a HAT which blocks GPIO4 so I cannot use the default pin for the temperature sensor, but I just cannot get it to work on another pin!

I just get lots of 00- instead of 28- in /sys/bus/w1/devices

Tried every available free pin using

dtoverlay=w1-gpio,gpiopin=16

in /boot/config.txt to no avail.

Is there something else I need to do?

  • Tried a fresh install of official Raspbian images of both Wheezy and Jessie and neither work unless the sensor is connected to the default pin (GPIO4) Is the w1-gpio overlay not compatible with Pi2? It works OK on my old Model B! – MillmoorRon Feb 26 '16 at 10:50
  • did you connect sensors to the correct pin? GPIO16 is pin 36. raspberrypi.stackexchange.com/questions/44027/… – edo1 Apr 3 '16 at 10:44
  • Yes! I gave up in the end and used the default pin with a wire trapped under the HAT. – MillmoorRon Apr 3 '16 at 17:44
1

I encountered the same problem. I could not get the DS18B20 w1-gpio to work on any pin other than pin 4 (the default). After many trials and errors I discovered that in the file /boot/overlays/README, it referenced default "4". I then tried quotation marks around the pin number, and it worked!

Answer: Add quotation marks: "21", to get the DS18B20 w1-gpio to work on a different pin than default, as follows:

dtoverlay=w1-gpio,gpiopin="21"

Here's the information that I found to be useful from file /boot/overlays/README:

Name:   w1-gpio
Info:   Configures the w1-gpio Onewire interface module.
        Use this overlay if you *don't* need a GPIO to drive an external pullup.
Load:   dtoverlay=w1-gpio,<param>=<val>
Params: gpiopin                 GPIO for I/O (default "4")
0

This is exactly what I have done!

Works fine on GPIO4, so I know the sensor works and the wiring is correct, just not working on any other pin.

I (currently) have the following in /boot/config.txt:

dtoverlay=w1-gpio,gpiopin=12

I get the following in my logs:

[    2.687623] Driver for 1-wire Dallas network protocol.
[    2.712091] w1-gpio onewire@0: gpio pin 12, external pullup pin -1, parasitic power 0
[    2.748447] w1_add_master_device: set_pullup requires write_byte or touch_bit, disabling
[    4.729959] w1_master_driver w1_bus_master1: w1_search: max_slave_count 64 reached, will continue next search.
[   52.148433] w1_master_driver w1_bus_master1: Family 0 for 00.800000000000.8c is not registered.
[  111.486264] w1_master_driver w1_bus_master1: Family 0 for 00.400000000000.46 is not registered.
[  158.887291] w1_master_driver w1_bus_master1: Family 0 for 00.c00000000000.ca is not registered.
[  230.148849] w1_master_driver w1_bus_master1: Family 0 for 00.200000000000.23 is not registered.
[  289.458052] w1_master_driver w1_bus_master1: Family 0 for 00.a00000000000.af is not registered.
[  324.908288] w1_master_driver w1_bus_master1: Family 0 for 00.600000000000.65 is not registered.
  • 1
    You should probably edit this additional information into your question as it does not appear to be an answer. – joan Feb 24 '16 at 11:36
0

If it works on GPIO 4 with dtoverlay=w1-gpio,gpiopin=4 then it should work just as well on any other.

It certainly used to work as I've done this in the past.

Choose the GPIO you want to use, wire it up, change /boot/config.txt and reboot. If it still doesn't work post a photo of your set-up.


I just wired a pair up to GPIO 21 (pin 40)

$ cat /boot/config.txt
sdtv_mode=2
dtparam=i2c_arm=on
dtparam=i2c_vc=on
dtparam=spi=on
dtoverlay=w1-gpio,gpiopin=21
#!/usr/bin/env python

# Public Domain

import glob import time

# Typical reading
# 73 01 4b 46 7f ff 0d 10 41 : crc=41 YES
# 73 01 4b 46 7f ff 0d 10 41 t=23187

while True:

   for sensor in glob.glob("/sys/bus/w1/devices/28-00*/w1_slave"):
      id = sensor.split("/")[5]

      try:
         f = open(sensor, "r")
         data = f.read()
         f.close()
         if "YES" in data:
            (discard, sep, reading) = data.partition(' t=')
            t = float(reading) / 1000.0
            print("{} {:.1f}".format(id, t))
         else:
            print("999.9")

      except:
         pass

   time.sleep(3.0)
$ ls /sys/bus/w1/devices/ 
28-000005d34cd2  28-001414abbeff  w1_bus_master1
$ /code/DS18B20.py  
28-001414abbeff 18.6
28-000005d34cd2 18.5
28-001414abbeff 18.6
28-000005d34cd2 18.5
28-001414abbeff 18.6
28-000005d34cd2 18.4
28-001414abbeff 18.6
28-000005d34cd2 18.5
0

I spent some time trying to avoid having an external pull-up resistor by using the internal pull-up feature of the Pi.

Whenever I did not have an external pull-up, I got those 00-xxxxxxx devices. Furthermore, the names of these 00- devices were often changing. I finally concluded that the internal pull-ups (60k vs recommended 4.7k) did not source enough current for my 1-wire device, and these 00- numbers were noise.

0

I tried Joans glob.glob piece of code in wheezy on a pi3, because it looked more interesting than the usual 2 step read_temp_raw followed by read_temp most folks use, but it needs a mod to work. viz: for sensor in glob.glob("/sys/bus/w1/devices/28-0*/w1_slave"): because my DS18B20 starts with 28-03

I also invoke the internal pullup with w1-gpio-intpullup.dtbo in /boot/dtoverlays which works OK for a single DS18B20 on the GPIOs I've tried (4 & 10).

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.