ddevejian
Posts: 14
Joined: Tue Mar 31, 2015 11:18 pm

Trouble with 1wire

Wed Apr 01, 2015 12:14 am

I am having difficulty with the 1wire driver in raspberian. I am trying to set up a thermal sensor with a DS18B20, but I am unable to see anything.

When I try to list the devices in the fs, this is what I see.

Code: Select all

pi@raspberrypi /sys/bus/w1/devices $ ls
00-400000000000  00-800000000000  w1_bus_master1
pi@raspberrypi /sys/bus/w1/devices $
The 00-400000000000 and 00-800000000000 will change from time to time, (always a 00-) but their contents do not appear similar to what I am expecting:

Code: Select all

pi@raspberrypi /sys/bus/w1/devices $ ls
00-200000000000  w1_bus_master1
pi@raspberrypi /sys/bus/w1/devices $ cd 00-200000000000
pi@raspberrypi /sys/bus/w1/devices/00-200000000000 $ ls
driver  id  name  rw  subsystem  uevent
pi@raspberrypi /sys/bus/w1/devices/00-200000000000 $
This is what I am seeing in messages related to the one wire driver:

Code: Select all

Apr  1 00:02:25 raspberrypi kernel: [    4.112221] w1-gpio onewire@0: gpio pin 4    , external pullup pin -1, parasitic power 0
Apr  1 00:02:25 raspberrypi kernel: [    6.083494] w1_master_driver w1_bus_maste    r1: w1_search: max_slave_count 64 reached, will continue next search.
Apr  1 00:03:18 raspberrypi kernel: [   53.479054] w1_master_driver w1_bus_maste    r1: Family 0 for 00.800000000000.8c is not registered.
Apr  1 00:04:18 raspberrypi kernel: [  112.790023] w1_master_driver w1_bus_maste    r1: Family 0 for 00.400000000000.46 is not registered.
Apr  1 00:05:05 raspberrypi kernel: [  160.150673] w1_master_driver w1_bus_maste    r1: Family 0 for 00.c00000000000.ca is not registered.
Apr  1 00:06:16 raspberrypi kernel: [  231.411904] w1_master_driver w1_bus_maste    r1: Family 0 for 00.200000000000.23 is not registered.
Apr  1 00:07:16 raspberrypi kernel: [  290.722895] w1_master_driver w1_bus_maste    r1: Family 0 for 00.a00000000000.af is not registered.
Apr  1 00:07:51 raspberrypi kernel: [  326.136136] w1_master_driver w1_bus_maste    r1: Family 0 for 00.600000000000.65 is not registered.
Apr  1 00:08:28 raspberrypi kernel: [  363.464118] w1_master_driver w1_bus_maste    r1: Family 0 for 00.e00000000000.e9 is not registered.
This behavior does not change even if I disconnect everything from the GPIO.

I am loading w1-gpio and w1-therm at boot via /etc/modules

The following line is in my config.txt:

Code: Select all

# Enable 1wire
dtoverlay=w1-gpio,gpiopin=4
I am running 3.18.10:

Code: Select all

pi@raspberrypi / $ uname -a
Linux raspberrypi 3.18.10-v7+ #774 SMP PREEMPT Wed Mar 25 14:10:30 GMT 2015 armv7l GNU/Linux
pi@raspberrypi / $
Any suggestions or further troubleshooting would be greatly welcome.

ddevejian
Posts: 14
Joined: Tue Mar 31, 2015 11:18 pm

Re: Trouble with 1wire

Wed Apr 01, 2015 1:08 pm

I forgot to mention, its a PI 2.

User avatar
joan
Posts: 12894
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Trouble with 1wire

Wed Apr 01, 2015 1:12 pm

Should you be loading the modules in /etc/modules if you are using device tree?

That said, if you get varying results that suggests a loose or incorrect connection.

How have you connected the sensor? I.e. what connections have you made between the sensor and the Pi.

ddevejian
Posts: 14
Joined: Tue Mar 31, 2015 11:18 pm

Re: Trouble with 1wire

Wed Apr 01, 2015 1:30 pm

There was no difference in behavior when I loaded the modules via modprobe. I stuck them in /etc/modules to save myself from typing that manually each time I booted.

I do not think this is a loose connection, because, as I mentioned above, this behavior happens even with nothing connected to the GPIO. (At which point there is only the power supply and an ethernet connection.)

Im using a ribbon cable from the GPIO to a breadboard, from which I connect 3V3 to the positive power rail, GND to the negative, the sensor GND directly to the GND rail, sensor Vdd to the positive power rail and sensor DQ to a 4k7 ohm resistor that connects to the positive rail and a second connection from sensor DQ to pin 4. Pretty much exactly the layout seen here: http://www.reuk.co.uk/DS18B20-Temperatu ... rry-Pi.htm

Ive tried changing the data pin, I used 18 with the same behavior.

My guess it the issue is here:

Code: Select all

 r1: w1_search: max_slave_count 64 reached, will continue next search.
I have either one or no devices connected, I cannot understand why it thinks the max_slave_count of 64 is reached.

User avatar
joan
Posts: 12894
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Trouble with 1wire

Wed Apr 01, 2015 2:00 pm

You should not be loading the modules in /etc/modules (or manually) if you are using device tree. I don't know what effect trying to load the modules multiple times will have.

ddevejian
Posts: 14
Joined: Tue Mar 31, 2015 11:18 pm

Re: Trouble with 1wire

Wed Apr 01, 2015 11:43 pm

I had seen a number of websites that described doing both, setting the dtoverlay in config.txt and issuing the modprobe commands. Nevertheless, having now readup on what device tree is and does, I would agree that issuing modprobe (or including it in /etc/modules) is redundant for w1-gpio if you are using the dtoverlay in config.txt.

There does not appear to be an overlay that includes w1-therm, so that may still need to be loaded manually, however, Ill worry about that later, right now the problem seems to be with w1-gpio.

Removing both w1-gpio and w1-therm from /etc/modules does not solve the problem. I still see the errors in /var/log/messages about maximum_slave_count reached as well as the Family 0 for 00-XX000000000 not registered. And the spurious device ids in /sys/bus/w1/devices.

Since these errors occur without my circuits attached to the pi, Im fairly certain my wiring has nothing to do with this.

Where can I go from here?

ddevejian
Posts: 14
Joined: Tue Mar 31, 2015 11:18 pm

Re: Trouble with 1wire

Thu Apr 02, 2015 2:11 am

All right, its working.

I found a couple of comments in other forums that suggested that the "Family 0 for 00-XX00000000000.YY is not registered" message is not an error, but typical behavior for the 1wire driver when nothing is attached.

Based off of that, I reattached my circuit and started to double check everything. Looking at the datasheet for the DS18B20, the input voltage is 3.0 to 5.5. Thinking that perhaps the 3v3 pin wasnt delivering sufficient voltage for whatever reason, I tried the 5v0 on pin 2. Still no love. However, when I changed the ground pin from pin 9 to pin 6, low and behold it started working. (Ive since moved back to the 3v3 on pin 1 for power and it continued to work.) For the moment Im going to assume there is a break in my ribbon cable or the T-Connector I used to connect the GPIO to the breadboard. Digging into exactly whats happening there will be a labor for another day.

I appreciate your help, Joan.

User avatar
DMike92
Posts: 21
Joined: Mon Dec 29, 2014 12:52 am
Location: France
Contact: Website

Re: Trouble with 1wire

Sat May 09, 2015 11:08 am

Thank a lot for your auto-reply ddevejian. I'm having exactly the same trouble wich drives me crazy because it was working nicely on my Pi B+ until a software change (apt-get xxx + apt-get upgrade).
I will try what you said and come back.
Le savoir ne vaut que quand il est partagé (c'est pas de moi mais j'adhère).

User avatar
pluggy
Posts: 3636
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Trouble with 1wire

Sat May 09, 2015 12:12 pm

Its a problem with the 3.18 kernels and device tree not working with the old way of doing things. Unfortunately the old way of doing things stick around a long time on the internet. I've avoided upgrading my Pis doing one wire stuff because of the changes that need to be made. It can be done, but I forget where I've seen the solution.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

aewdummy
Posts: 3
Joined: Sun Feb 22, 2015 11:11 am

Re: Trouble with 1wire

Wed May 20, 2015 2:41 pm

Hi

Can I add my two pennyworth to this discussion

I have an add on board attached to a Pi 1 model b. NEARLY ALL the gpios are in use. It has worked just fine to 12 months.

If I attach the board to a Pi 2, the I get the following ( as others get too ) from dmesg, the 1 wire stops working and I don't get the expected subdirectories in /sys/bus/w1/devices

w1-gpio onewire@0: gpio pin 4, external pullup pin 5, parasitic power 0
w1_add_master_device: set_pullup requires write_byte or touch_bit, disabling

w1_master_driver w1_bus_master1: w1_search: max_slave_count 64 reached, will continue next search.

I have nothing on pin 5

Note the "w1_search: max_slave_count 64 reached" which seems to be my problem

If I just jumper gpio4, power and earth between the Pi 2 and the board THE 1WIRE WORKS PROPERLY and the "w1_search: max_slave_count 64 reached" message is not present

I have tried to selectively jumper other gpio pins, but I can't locate the problem.

Is there a gpio pin ( other than 4 ) that is involved in 1 wire?

Thanks for any insight you can give me

A

forzalaquila
Posts: 2
Joined: Tue Feb 17, 2015 3:17 pm

Re: Trouble with 1wire

Mon Nov 16, 2015 2:30 pm

I my friend
For anybody think that GPIO4 can be damaged and want to try to change to another GPIO pin.
After a lots of try i have made this and it has worked:
1) use a pretty old kernel version without device tree .I'm using 3.12.36 and you can download from sudo rpi-update f74b92120e0d469fc5c2dc85b2b5718d877e1cbb
2) edit, from root, /boot/cmdline.txt end put at the ending of line this bcm2708.w1_gpio_pin=18 (18 is the GPIO number that you want use.The file must be only 1 line)
3) reboot and enjoi

ciao
cesare

User avatar
DougieLawson
Posts: 30935
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Trouble with 1wire

Mon Nov 16, 2015 7:06 pm

Why not use the support in the device tree kernels?

Code: Select all

dtoverlay=w1-gpio,gpiopin=nn

Code: Select all

dtoverlay=w1-gpio,pullup=on,gpiopin=nn

Code: Select all

dtoverlay=w1-gpio-pullup,gpiopin=nn,extpullup=nn

Code: Select all

dtoverlay=w1-gpio-pullup,pullup=on,gpiopin=nn,extpullup=nn
Docs are in /boot/overlays/README.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

on4ami
Posts: 1
Joined: Wed Nov 15, 2017 9:55 am

Re: Trouble with 1wire

Wed Nov 15, 2017 10:43 am

I'm also having.

After a couple of day my 4 DS18B20 report a different ID starting 00-.

My pullup resistor is 4k7 all connected to GPIO pin 4.

do i still need :

command:

sudo modprobe w1-gpio pullup=1

Or don't use an external resistor.

KR

Pat

pcmanbob
Posts: 2468
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Trouble with 1wire

Wed Nov 15, 2017 1:33 pm

You don't need to use any modprobe commands now if you are using raspbian stretch.

you just need to enable 1-wire either via raspi-config or by adding dtoverlay=w1-gpio to /boot/config.txt. then reboot.

With your sensors connected to the default pin 7 or gpio 4 if you prefer, with an external 4.7k resistor.

Image

if you do

Code: Select all

cd /sys/bus/w1/devices

ls
you should see your sensor ID's listed.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help

braveness23
Posts: 1
Joined: Tue Apr 12, 2016 3:26 am

Re: Trouble with 1wire

Mon Dec 11, 2017 1:22 am

pcmanbob, this is great and a big help! I've changed my config as you described and I now see my devices in /sys/bus/w1/devices/

Code: Select all

pi@hometemp:~ $ ls /sys/bus/w1/devices/
3b-000000183532  3b-000000186e31  3b-000000186e4a  w1_bus_master1
But I do not have w1_slave as a sub-directory for these devices any more. How do I actually read the temperature from my devices now?

I am running raspbian stretch on a Pi 2 Here is my hardware configuration:

https://github.com/braveness23/Hometemp ... ers_bb.png
pcmanbob wrote:
Wed Nov 15, 2017 1:33 pm
You don't need to use any modprobe commands now if you are using raspbian stretch.

you just need to enable 1-wire either via raspi-config or by adding dtoverlay=w1-gpio to /boot/config.txt. then reboot.

With your sensors connected to the default pin 7 or gpio 4 if you prefer, with an external 4.7k resistor.

Image

if you do

Code: Select all

cd /sys/bus/w1/devices

ls
you should see your sensor ID's listed.

pcmanbob
Posts: 2468
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Trouble with 1wire

Mon Dec 11, 2017 4:02 pm

Code: Select all

pi@hometemp:~ $ ls /sys/bus/w1/devices/
3b-000000183532  3b-000000186e31  3b-000000186e4a  w1_bus_master1
So now you have your devices showing up, you need to cd in to the device directory

Code: Select all

cd /sys/bus/w1/devices/3b-000000183532

then as a test do

Code: Select all


cat w1_slave
which will show the raw temperature reading output by the sensor the t=xxxxx being the temperature.

this python code will read one temp sensor for you and return the temp in C

Code: Select all

#!/usr/bin/python

import time

def read_temp_raw():
    device_file = "/sys/bus/w1/devices/enter sensor ID here/w1_slave"
    print device_file
    f = open(device_file, "r")
    lines = f.readlines()
    f.close()
    return lines
 
def read_temp():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != "YES":
        time.sleep(0.2)
        lines = read_temp_raw()
    equals_pos = lines[1].find("t=")
    if equals_pos != -1:
        temp_string = lines[1][equals_pos+2:]
        temp_c = float(temp_string) / 1000.0
        
        return temp_c
	

print "Start "

temperature = (read_temp())
print temperature

Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help

User avatar
DMike92
Posts: 21
Joined: Mon Dec 29, 2014 12:52 am
Location: France
Contact: Website

Re: Trouble with 1wire

Tue Jan 02, 2018 11:28 pm

For those still having trouble, make sure that /etc/modules contains both
w1-gpio
w1_therm
Note that the last one has an underscore (I tried with w1-therm and had the "64..." message in dmesg)

lsmod should read 3 important lines if correct :

Code: Select all

Module         Size  Used by
w1_gpio        4534  0
w1_therm       4475  0
wire          31801  2 w1_gpio,w1_therm
(size values may differ)
Check that the last one uses the 2 others

This configuration works for me for non parasitic probes (3 wires and a 4.7K between VCC and Data on pin 4)
So my /boot/config.txt contains at the end :

Code: Select all

dtoverlay=w1-gpio
# NOTE : After playing with those and putting all back in place, it does not work anymore! dmesg is showing:
w1_search: max_slave_count 64 reached, will continue next search.

After having done more testing, it appears that the probes disappears without doing anything. I suspect a hardware issue.
Le savoir ne vaut que quand il est partagé (c'est pas de moi mais j'adhère).

Return to “Troubleshooting”

Who is online

Users browsing this forum: No registered users and 26 guests