1-wire under Ubuntu on BB Black

I need some advice on getting a 1-wire device (ds18b20) working under ubuntu 13.04 on my BB Black. I’ve installed the owfs package from the ubuntu repo, and I believe that I’ve gotten everything wired up correctly. In my case my 1wire device is hooked up to GPIO-7. I cannot figure out how to tell tell the system to treat GPIO-7 as a 1-wire io device. During my digging I came across [1] which talks about updating a file to register an GPIO pin as a one wire device with the system, but my ubuntu installation doesn’t seem to have that file.

Any help greatly appreciated.

[1] http://squidge.sourceforge.net/w1/

Thanks for the response. This is definitely the piece I was missing. I don’t suppose you still have the device tree overlay. I’ve never done any work with device tree overlays, and none of the examples that I’ve found cover setting up overlays for 1-wire. I’ve found some decent examples of device tree overlays for pwm, but no luck on 1-wire yet…

Thanks! That was great help. A couple of notes for anyone reading this later. The patched version of dtc can be obtained/built using Robert’s script at https://raw.github.com/RobertCNelson/tools/master/pkgs/dtc.sh. In my case I’m using a 4.7K ohm resistor (thats what I’ve seen used in other places, and Adafruit included in in the ‘kit’ when I ordered the sensor). I didn’t have any of the spi stuff. I’m assuming that was from some other cape, and/or some other part of the project that you were working on… The only problem that I’m having at the moment, is that ever time I read, I get:

ff 07 4b 46 7f ff 01 10 2f : crc=2f YES
ff 07 4b 46 7f ff 01 10 2f t=127937

I did mis-wire the sensor, so its possible that I damaged it, but I’ll keep poking around. I remember seeing other comments about the temperature always being constant and I just need to track those down.

Thanks again for the help.

127937 is a very unpleasant number - not as bad as 42 would be,
of course, but not nice. The power-on value for the DS18B20 is
85 deg C, and the operating temperature range is -55 to +125 deg C,
so something’s definitely off.

Looking deeper, the DS18B20’s ADC output is generally 12 bits, though
you can set it lower for faster conversions. (I don’t know if the Linux
driver allows that.) That gives 1/16 of a degree per bit, and we can
see that:

cwr@farthing ~ $ echo 0.937 / 0.0625 | bc
14.992000

so 127.937 becomes 127 and 15/16 (ish).

cwr@farthing ~ $ echo obase=2 ; 128 * 16 - 1 | bc >fff

The actual 12 bit result is masked with 0x7FF, since the high bit
is used as the sign (2’s complement notation).

cwr@farthing ~ $ echo ibase=16 ; obase=2 ; 7FF | bc >>fff
cwr@farthing ~ $ cat fff
11111111111
11111111111

Oooh-err. It looks as if the device isn’t really reading anything, just
returning all-ones, though for some reason the high bit isn’t set. The
processor reading the temperature and generating the crc is working
correctly, but the sensor has gone out to (a well-cooked) lunch.

Hmmm; time to try another DS18B20.

Good luck - Will

(BTW, if you have an Arduino around, it’s pretty easy to check the DS18B20
directly and unambiguously, with no pesky device drivers in the way.)

Just wanted to say a huge thanks for this thread, it got me working with my one wire network!

Is there a way to get the setup done on startup?

Was hoping this would work for me too but wasn’t as lucky. I initially set up the sensor on my Arduino Uno, in parasite power mode. But as I understand, I’ll need to wire it up like this picture to work with the BBB:
http://3.bp.blogspot.com/-budGL8I6W4Y/URGx8PYvvbI/AAAAAAAAAwU/_-TTpUrWRZs/s640/Simple+Temp+Sensor_bb.jpg

(using 3.3v instead of 5v, using BBB P8, pin 11 instead of the arduino)

So I’ve done this and wired my data wire to the P8 header and pin 11 (relating to GPIO 1_13 as I understand). I loaded the DTS successfully and was able to echo to /sys/devices/bone_capemgr.8/slots (not 9 like the example). I’ve rebooted and all but the device doesn’t show up in the /sys/devices/w1_bus_master1 folder. I even echoed the ID of the sensor to the w1_master_add (and got a folder for my sensor /etc.) but no response from the sensor.

When I look at dmesg, it says that my device doesn’t provide a temperature to the cat /sys/devices/w1_bus_master1/xx-xxxxxxxxxxxx/w1_slave

Am I using the right PIN on P8? Is my wiring correct or should I try the 8K pullup resistor instead of 4.7K? To help me know what to look for, what does your dmesg look like when adding the nocape, also when responding with a temperature?

Are you sure you’ve got the right pins plugged in? What do you see in dmesg?

run:

cat /sys/kernel/debug/gpio

And post the output

Hi All
I’ve got a fair way down this path,

but when I attempt to load cwrse’s blob file I get these errors on dmesg:

[ 141.405600] of_get_named_gpio_flags exited with status 45 [ 141.405623] of_get_named_gpio_flags: can't parse gpios property [ 141.411224] bone-capemgr bone_capemgr.9: slot #6: Applied #2 overlays.

…And I dont have a slave device, and it does not appear to work.

I’m using ubuntu, so the command I use to load is:

sudo sh -c "echo w1 > /sys/devices/bone_capemgr.9/slots"

Any ideas what is going on?

Thanks for your help

Matt