About This Project
If you have never heard of the Anova, you are missing a wonderful, wonderful gadget in your life. Imagine coming home after a long day, and waiting for you is the perfect medium rare steak, perfectly cooked fish, or the most tender but still crisp asparagus. If you are any type of foodie at all, you NEED this machine!
Check it out here: Anova Precision Cooker
As a somewhat early adopter, I picked up an 800W version with Bluetooth only. For the most part, I don’t even use the Bluetooth or the phone App, but it would sure be nice to be able to monitor a 50 hour cook of a pork shoulder roast - succulently tender, yet still medium rare. For that you need the WiFi model!
I was too cheap to upgrade, so I just plugged along, using my Anova without being able to spark it up from the cloud. That was until the Raspberry Pi Zero W came around.
The W, pronounced Dubya - because I said so, is a single core SOC board, but with built in WiFi and Bluetooth. A plan was hatched.
Let’s see if we can integrate the Pi with the Anova and get it on Cayenne!!
What’s Connected
This is a great project for folks that don’t solder, are afraid to wire stuff, but still want to play with IoT.
You need an Anova Precision Cooker, A 5V USB power supply, a Raspberry Pi Zero W, and 8GB micro SD card (might get away with smaller but they’re cheap like Borscht, don’t hurt yourself). You will also need the Mini HDMI connector and a micro USB to USB A female cable to connect a keyboard to configure the Pi.
How To
Note, pay particular attention to steps 1,9, 11, and 15. Very important.
-
First of all, acquire yourself a tasty beverage.
-
Next, install Raspbian onto your microSD card. Get Jessie Lite, you don’t need Pixel.
Raspberry Pi OS – Raspberry Pi
Raspberry Pi Documentation - Getting Started
I used Win32DiskImager myself, but looks like RPi recommends Etcher in the above guide. -
Plug in your microSD, your keyboard, monitor, and power for the Pi.
-
Login with pi/raspberry and change your password. Don’t be a newb. https://www.raspberrypi.org/documentation/linux/usage/users.md
-
Run sudo raspi-config and expand file system, set keyboard to the US, and turn on the ssh server.
Raspberry Pi Documentation - Configuration -
Configure your wifi. Raspberry Pi Documentation - Configuration
Make sure you use wpa_passphrase and don’t forget to delete your human readable passphrase from wpa_supplicant. Keep the interwebs safe! -
Reboot, login, and make sure you have Wifi with ping mydevices.com for instance.
-
Now type ifconfig to find your ip address, and if desired use putty on your pc to connect to your pi. I like this better, because I can now just disconnect the keyboard and hdmi - no longer needed.
-
Have a drink.
-
Now you are going to want to do the following commands to get all the stuff. I am using a library I found for talking to the Anova here: GitHub - erikcw/pycirculate: A Python wrapper library for interacting with the Anova 2 over Bluetooth LE on Linux. and the Cayenne MQTT lib here: GitHub - myDevicesIoT/Cayenne-MQTT-Python: Python Library for Cayenne MQTT API
sudo apt-get update
sudo apt-get install python-pip
sudo apt-get install libglib2.0-dev
sudo pip install bluepy
sudo pip install pycirculate --pre
sudo pip install cayenne-mqtt -
Ok, have another drink.
-
Now, make sure your Anova is plugged in, and run sudo hcitool lescan. Record the MAC address of your cooker.
Connect to the Cayenne dashboard, and create a new Bring Your Own Thing Device. Record the MQTT and Client ID credentials. -
Create a file on your Pi, and call it something like Cayenne.py, and drop in the following code. If you aren’t comfortable with Linux command line, you could create this file in something like Notepad++ and transfer it over with something like WinSCP. WinSCP :: Official Site :: Download
-
Change the credentials to what you recorded above, and run with python Cayenne.py. It should connect and you will see your dashboard auto populate.
-
Have another, you’ve earned it.
-
Next, you will want to create a Setpoint slider on Channel 4 and set it’s min and max to 5 and 99. This is what the Anova can do. If you don’t like Celcius, deal with it. You can configure it to F all you like later. You will also want to create a pushbutton on Channel 5.
-
Bob should now be your uncle, you’ll be high fiving yourself, and your wife will say, “Are you drunk?”.
-
If you is the happy, you can then do a sudo crontab -e, and add the following to the end of your cron file:
@reboot /home/pi/Cayenne.py &
This will make sure the script is always called on reboot, and you don’t need to touch the pi again. Of course you will. I know you. You can’t help yourself.
The Code
#
#Connect your Anova to MyDevices Cayenne.
#
#import time and date stuff
import datetime
import time
#import Anova lib
from pycirculate.anova import AnovaController
#get Cayenne
import cayenne.client
#MQTT Credentials
MQTT_USERNAME = "..."
MQTT_PASSWORD ="..."
MQTT_CLIENT_ID = "..."
# Your Anova Address goes here, run `sudo hcitool lescan` and record
ANOVA_MAC_ADDRESS = "..."
#Cayenne message callback
def on_message(message):
print("message received: " + str(message))
#set the temperature setpoint if we get a slider message
if message.channel == 4:
ctrl.set_temp(message.value)
print("Setpoint set to " + message.value + " degrees")
if message.channel == 5:
if (message.value == '1'):
ctrl.start_anova()
print("Anova Started")
else:
ctrl.stop_anova()
print("Anova Stopped")
#Initialize Cayenne
client = cayenne.client.CayenneMQTTClient()
#Set the Cayenne message callback
client.on_message = on_message
#begin a Cayenne session
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)
#grab your Anova
ctrl = AnovaController(ANOVA_MAC_ADDRESS)
def main():
print datetime.datetime.now()
#Canadians do Celcius
print ctrl.set_unit('c')
i=0
timestamp = 0
while True:
#Cayenne kick
client.loop()
#Call every 10 seconds
if(time.time() > timestamp + 10):
#send the current temperature
client.celsiusWrite(1,ctrl.read_temp())
#send the set temperature
client.celsiusWrite(3,ctrl.send_command_async("read set temp"))
#send the run status
if (ctrl.anova_status() == 'stopped'): a_stat = 0
else: a_stat = 1
client.virtualWrite(2,a_stat)
#save last timestamp
timestamp = time.time()
# print ctrl.read_temp(), ctrl.read_unit()
# print ctrl.set_temp(TEMP)
# print ctrl.start_anova()
# print ctrl.anova_status()
if __name__ == "__main__":
main()
Triggers & Alerts
Again, yep. Imagine dropping some frozen steaks in in the morning, and start cooking when they are thawed, then hold a lower safe temperature until you’re on your way home.
Sound crazy? We do it because we can!!
Scheduling
Yep. Baby wakes up at 2am. Warm milk is ready at precisely the right temperature.
Dashboard Screenshots
Photos of the Project
Video
https://drive.google.com/file/d/0B2qZsCCACkEvRTc4VUNtRk5iZGc/view?usp=sharing
This hacking session brought to you by Glenlivet 15.
Cheers,
Craig