Thursday, November 20, 2014

Connecting a Raspberry Pi to the Anova Precision Cooker

I backed a Kickstarter campaign to bring a new version of a cooker that allows a home cook to use the "sous vide" method of cooking just like fancy restaurants. The device is priced far below commercial units available, but performs exceptionally well. This new device is the Anova Precision Cooker and can be ordered here. This device sports a Bluetooth interface so that you could program and monitor the unit from a Bluetooth enabled device. Being a geek and software developer, I opted to support at the "Hacker" level which gave me early access to a prototype unit so I could work on developing an app or other software for the device.

I also recently purchased a Raspberry Pi B+ from Sparkfun.com and had been tinkering with all sorts of things on it. As a side note, I also purchased a cool Plexiglas enclosure from Adafruit industries, I highly recommend it, she makes them on site and it is a perfect fit and looks cool. The Pi is a great little platform and can do all kinds of things big computers can do at a fraction of the price. Currently I have it interfacing to my weather station and posting the weather data from my backyard up to the Weather Underground, I thought it might make a good platform to interface to the Anova as well; this brings me to the point of this post. 

Once I got the idea of interfacing to the Anova unit from my Raspberry Pi, I did a little research and found I needed to purchase a Bluetooth dongle that would be compatible with the Anova. Since the Anova uses Bluetooth LE, the dongle must also support that and I needed one that had already been successfully interfaced with the Raspberry Pi (no need to re-invent the wheel here). The one I chose is based on the Cambridge Silicon Radio and I got it from DX.com from their USA warehouse: ultra-mini-bluetooth-csr-4-0-usb-dongle-adapter.

So with the Pi, dongle and the Anova unit in place, it was time to see if I could interface them. My research found an awesome resource on eLinux.org on how to get Bluetooth LE working on a Raspberry Pi and I followed this almost exactly to get my Pi to talk to the Anova. Here is the blog post: http://www.elinux.org/RPi_Bluetooth_LE. The following pictures correspond to particular steps in the posting and I have tried to reference each of them for the pictures.

I followed all the steps up to the "First Test" header in the posting to get the proper software installed, configured and working on my Pi.Next I followed the instructions and the picture below are my results when following them.

Results of "lsusb" with the CSR BT Dongle plugged in
Doing a detailed "lsusb" on the CSR BT Dongle

Results of the detailed "lsusb"
Results of the "hciconfig"
Bringing the CSR BT Dongle "up"
Results of the "hcitool lescan" command
Results of the "hcitool lecc" command
Now the posting deals with accessing the Bluetooth device from using Python. I followed the instructions to build "bluepy" on my machine and then issued the command as described in the posting. My results follow and show that the software was able to connect to and identify the Service and Characteristic that is used to send commands to the Anova.

Results of running "btle.py"
That's it for now, the next step is to take the btle.py Python code and update it to send a command to the Anova. This is simply done by writing to the Characteristic with its value set to a recognized command (status, read temp nn, write temp nn, etc.).

 -Matt-