DS18B20 temperature sensor on a Beaglebone Black running ubuntu

It was quite of a challenge to make my DS18B20 to work with my BeagleBone Black on Ubuntu…

There are quite a few blogs and web sites (see below) which talks about 1-wire on BeagleBone and about Ubuntu on BeagleBone but not everything was in one place. So I thought I write this little procedure.

As you need to be root for most of those commands, you may want to open a root connection which will avoid having to type in “sudo” in front of each command :

BUT DON’T FORGET THAT YOU ARE ROOT AND YOU CAN BREAK YOUR UBUNTU !

Install Ubuntu and required package

Install Ubuntu : see this post for more details.

Install the devide tree compiler (dtc) :

Update dtc package (required on Ubuntu else you would get “dtc: invalid option — ‘@'” error) using instructions here :

Be aware that it installs a all bunch of package for building new dtc package. Also, actually, you may not need to install the dtc package as it seems Robert C. Nelson’s script is doing it for you.

Connecting the probe to the BBB

That’s simple :

  • VCC on VDD_3.3 i.e. P9.4 for instance
  • Ground on… ground i.e. P9.1 for instance
  • Data on P9.22 (that’s how we’ll configure the BeagleBone, don’t use another pin unless you know what to change in the DTS file we’ll see a bit later.)

BBB_DS18B20

Activating 1-wire

What’s interresting is that 1-wire driver is already installed in Ubuntu’s distro. To make sure it is, just try this :

But it is not associated to any pin. So first, create a device tree overlay definition for 1-wire activation (found here actually) on port P9.22 :

Then compile it and copy the compiled file to /lib/firmware :

(not sure why I had to specify the full path of dtc even though which dtc gives the correct path. May be a cache somewhere ?) Check which overlays are loaded :

Load the overlay

Check it is properly loaded :

Now you should see the device in /sys/bus/w1/devices

Almost there…

And the temperature is : 18,312°C !!!

References

I also used the following web sites / blogs to get all this to work :

4 thoughts on “DS18B20 temperature sensor on a Beaglebone Black running ubuntu

    • Hello Mark,

      A bit of your comment was lost due to <> I guess.

      Anyway, I found a quite usefull ressource here. Derek lists all pins and match pin no with address, offset, gpio no…

      So, let say you want to use P9.20, the line would be
      gpios = < gpio0 12 0 >

      I don’t have time to test it right now, but tell me if it works !

      Hope this helps.
      JS

  1. Pingback: UART4 with Pandaboard and Arch Linux - BlogoSfera

  2. If you are not geting 1wire device not loaded after
    >echo BB-1WIRE-P9-22 > /sys/devices/bone_capemgr.9/slots
    You may required to modify /boot/config.txt or /boot/uEnv.txt
    add following line
    optargs=capemgr.enable_partno=BB-1WIRE-P9-22
    Save file, reboot BBB, and check load again with
    echo BB-1WIRE-P9-22 > /sys/devices/bone_capemgr.9/slots

Leave a Reply

Your email address will not be published.