8

I had two of these running fine, but now they've stopped. From reading I've done I think this has something to do with kernel updates and device tree. There seems to be about half a dozen options now with numerous permutations of config, but I haven't got it working at all.

I have a Pi B+ and I've wired:

  • 4.7kΩ Resistor between pin 1 (3.3V) and pin 7 (GPIO 4)
  • pin 1 (3.3V) to the +ve of the DS18B20
  • pin 6 (GND) to the ground of the DS18B20
  • pin 7 (GPIO 4) to the data of the DS18B20

I am running updated Raspian Linux raspberrypi 4.1.7+ #817 PREEMPT

From what I've read the options are:

  • modules, and possibly parameters, in /etc/modules
  • blacklist statements in /etc/modprobe.d/raspi.blacklist.conf
  • device_tree= or not in /boot/config.txt, and if not, then dtoverlay statement that includes
    • w1-gpio-pullup or w1-gpio
    • gpiopin=X where X is usually 4
    • extpullup=Y or ommitted where Y is a pin number?

The device(s) is(are) never listed under /sys/bus/w1/devices/ where they used to be. I mostly just have w1_bus_master/ in there.

Things I've tried:

1. Without Device Tree (attempting to go to original config)

device_tree= in /boot/config.txt.

/etc/modules including:

w1-gpio
w1-therm

This was an attempt to revert to the settings that worked before.

2. Without Device Tree but with more module params

device_tree= in /boot/config.txt.

/etc/modules including:

w1-gpio pullup=0 gpiopin=4 extpullup=1
w1-therm strong_pullup=1

3. With Device Tree (hay, it's obviously the cool thing to do)

/boot/config.txt contains: dtoverlay=w1-gpio,gpiopin=4

I've also tried various combinations of blacklisting and listing in /etc/modules the wp-gpio and wp-therm modules.

Things I've read that have only muddied my understanding(!)

Not least because I have a Pi B+ whereas many are working with Pi2 which I don't have.

[EDIT] As suggested in comment:

  • /etc/modules empty.
  • /boot/config.txt does not have device_tree=, thus enabling device tree. It does not contain any w1-* lines at all.

Result: lsmod shows that neither w1-gpio nor w1-therm are there (nor wire which is usually there when the other two are).

After sudo modprobe w1-gpio; sudo modprobe w1-therm there is still nothing in /sys/bus/w1/devices/, not even the w1_bus_master one.

...

And with dtoverlay=w1-gpio-pullup,gpiopin=4 in /boot/config.txt...reboot...

Now lsmod shows wire and w1_gpio and w1_therm. ls /sys/bus/w1/devices/ has the devices! Thanks @Joan!

artfulrobot
  • 353
  • 1
  • 3
  • 13
  • Use device tree. I'm not sure if it is compulsory yet, it will be one day. /etc/modules should not have 1-wire modules mentioned. From memory device tree should load w1-gpio and w1-therm (use lsmod to check). Could you ensure you are using device tree and an empty /etc/modules and reboot. – joan Oct 10 '15 at 18:48
  • Thanks @joan I've edited question with the result of that. – artfulrobot Oct 10 '15 at 18:56
  • The same with dtoverlay=w1-gpio-pullup,gpiopin=4 in /boot/config.txt. – joan Oct 10 '15 at 19:02
  • @joan yes! The winning combination! Thanks so much. – artfulrobot Oct 10 '15 at 19:54
  • https://github.com/raspberrypi/firmware/issues/348 also has some lengthy explanations on parasite mode. Its all confusing, indeed – x29a Apr 03 '16 at 15:34

2 Answers2

4

I'm posting this as it's the answer I got to but all credit is due to the commenter @Joan!

/etc/modules empty.
/boot/config.txt does not have device_tree=, thus enabling device tree. It does not contain any w1-* lines at all.

Result: lsmod shows that neither w1-gpio nor w1-therm are there (nor wire which is usually there when the other two are).

After sudo modprobe w1-gpio; sudo modprobe w1-therm there is still nothing in /sys/bus/w1/devices/, not even the w1_bus_master one.

...

And with dtoverlay=w1-gpio-pullup,gpiopin=4 in /boot/config.txt...reboot...

Now lsmod shows wire and w1_gpio and w1_therm. ls /sys/bus/w1/devices/ has the devices! Thanks @Joan!

artfulrobot
  • 353
  • 1
  • 3
  • 13
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo May 06 '20 at 20:40
2

To enable 1-wire run

raspi-config

and go to Interfacing Options -> 1-Wire

(This will add dtoverlay=w1–gpio at the end of /boot/config.txt. Default pin is GPIO 4. If you would like to use a custom pin you have to manually change this line to dtoverlay=w1-gpio,gpiopin=x where x is other GPIO pin number)

Reboot the Pi

To list all devices that Raspberry Pi has discovered via 1-Wire busses which will be in the format "28-XXXXXXXXXXXX" run

ls /sys/bus/w1/devices/

To get temperature run

cat /sys/bus/w1/devices/w1_bus_master1/<your_device_id>/w1_slave
OdkoPP
  • 121
  • 1