Building bbPool

The needs

As for poolDuino, I want to measure :

  • water pH, ORP and temperature
  • air temperature

and report that on my emoncms web site.

The hardware

Connecting temperature sensors to the BBB…

and reading the values…

Information for those two temp sensors can be found here for DS18B20 and here for AtlasScientific ones.

Connecting pH and ORP sensor

AtlasScientific pH and ORP stamps are using simple asynchronous serial communication protocol. For communicating with them, we will use 2 of the 4 UARTS available on the Beaglebone, UART1 & 4.

P1040843

Enabling UARTS

First, you need to enable UARTs 1 & 4. That’s easy :

Yeah… I know, but that’s easier like that : don’t need to type sudo before each command. But keep in mind you are root and you can destroy your Ubuntu. So think before you type !

Here, we can see UARTs are not enabled. So let’s enable them.

Reading from UART

I am a perl fan… so I’ll show a perl example, no python as I don’t know python and there is a handfull of examples using python…

I used Device::SerialPort library which is quite handy.

Code is here on GitHub. This code sets pH stamp in continuous reading and reads output every second.

Conclusion

I now have a Beaglebone connected to 2 temperature sensors, an ORP and a pH stamp, and I can read all those sensors value 🙂

I am working on a web GUI to display the information, send the info to my emoncms website and be able to configure the gizmo. So stay tune !

 

Loading a custom device tree overlay on Ubuntu

Ok… After getting my 1-Wire temperature sensor to work (see this post), I spent hours trying to get my custom 1-wire virtual cape at boot time using uEnv.txt :

But I always get this error :

Working great from command line after booting :

Seems to be a bug in the kernel : http://hipstercircuits.com/enable-device-tree-overlay-on-startup-on-beaglebone-black/

So, quick and dirty solution (I don’t wan’t / know how to build a custom kernel…) : so I added the command into /etc/rc.local

Now it is loaded at boot time !
~

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 :

poolDuino hardware & software details

pH and ORP stamp are using standard serial communication to send data they read from the probe. So I used the SoftwareSerial library to get data processed by the arduino and I connected :

  • pH RX & TX pin respectively to pin 2 & 3 on the arduino
  • ORP TX & TX pin respectively to pin 5 & 6 on the arduino

Temperature sensor is an analog sensor which I connected to pin A0.

PoolDuino 640x480

Also, I connected power (3.3V) and ground to respective power lines of sensors.

Test code (which is way more complicated than it should be because I was first planning to use an arduino as the final solution… but then decided to go for a BeagleBone) can be found here : https://github.com/jsiobj/poolDuino