5.24.2014

BeagleBone and DS18B20 Temp Sensor

After deciding to switch over the the BeagleBone Black, we have been reconsidering using an Arduino to measure environmental variables. Using the numerous I/O pins on the BBB is not only easier, but more efficient in size and speed. We've also decided that we will not be purchasing pH, DO, and Salinity sensors for the prototype...they will be add-ons for those who want them.

Before starting, read this quick explanation on device tree overlays on the BeagleBone. After understanding the basics of pin-muxing.

Also refer to this post by HipsterCircuits (much of the following taken from the post). That post is the basis for the explanation below.

Then download the device tree overlay package (can't use apt-get as that package does not have the -@ compiler) use Robert C Nelson's source install:



After installing the software, make the file executable, and then run the bash file to install device-tree-overlay (dtc) from the source:




Then copy and paste the code found in this post to BB-W1-00A0.dts (by creating this file).

Compile the .dtbo file:



Copy the .dtbo file to /lib/firmware:




Mux the pins (this must be done on every reboot -- we added it to the init section of our script):



Attach the DS18B20 one-wire temperature sensor. Use a 4.7k resistor to attach the sensor (for more information read this post). Then attach the white wire to "P9_22", the black wire to "P9_46", and the red to "P9_3".

After muxing the pins and attaching the sensor you should see a new device appear in /sys/bus/w1/devices. Use this unique id (ours was 28-0000049acf0) to replace the ID in the code below.

Create a python file similar to the image below (download can be found here):





And this is the output on the BeagleBone:





As you can see, this is not entirely accurate, but a .5 accuracy will work fine for our project. The pressure is also calculated using 14.7 psi, which should atmospheric pressure at sea-level.

This surprisingly easy setup will be useful for our project. By embedding this sensor code as part of a python module in our project, we will be able to easily read the temperature both above and below the surface of the water.

No comments:

Post a Comment