Use a Raspberry Pi to Help You Bake a Turkey

on November 24 | by

Since everything is getting connected to the “Internet of Things”, it is time for your turkey to get in on the IoT action. In this simple tutorial, I will show you how capture the temperature of your bird as it cooks in the oven and stream it to a data visualization in your web browser. Hi-tech turkey!

Pi+Turkey=Yummy

Here are the supplies you will need:

  • An internet connected Raspberry Pi or your single-board computer of choice
  • Vernier Go!Temp USB temperature probe (Product Link)
  • Thermal shield tape (Amazon Link)

Go!Temp Temperature Probe

The Vernier Go!Temp probe has a temperature range of -20°C – 115°C (-4°F – 239°F), convenient since we want our turkey to reach an internal temperature of 71°C (160°F). However, you do not want to expose the plastic base or cord of the Go!Temp probe to the oven’s high temperatures. This is where the thermal shield tape comes in. Thoroughly wrap all of the probe’s exposed plastic that will be inside of the oven in the thermal shield tape to keep it safe. The wrapped, shielded cord and Go!Temp probe are the only things that will go in the oven with your turkey (please do not put your Raspberry Pi in the oven).

TurkeyTemp2
Plug your Go!Temp probe into your USB port and start your Pi. At a command prompt, type “lsusb” to verify that your Pi sees the probe:

pi@raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 08f7:0002 Vernier EasyTemp/Go!Temp
Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 001 Device 005: ID 046d:c534 Logitech, Inc.

One of the devices connected should say “Vernier EasyTemp/Go!Temp”. Once connected, your Go!Temp probe is going to write data to a file, /dev/ldusb0. Verify that file is present (type “ls -l /dev/ldusb0” at the command prompt).

That completes the hardware setup. For the software setup, first install the Initial State streamer to give your captured temperature readings a destination to go to (go here for instructions on setting up the Initial State streamer; it is super easy and takes less than two minutes). Create a new file on your Raspberry Pi (e.g. “turkey_temp.py”) and copy+paste the code below into it. You will need to copy+paste the access key associated with your Initial State account in between the quotes on line 6 where it says “PUT YOUR ACCESS KEY HERE”. You can find your access key under your account settings or on the landing page once you log into your account. The code below is all of the code that you will need.

from ISStreamer.Streamer import Streamer
import time
import struct

# Streamer constructor, this will create a bucket called Turkey Temperature
streamer = Streamer(bucket_name="Turkey Temperature", access_key="PUT YOUR ACCESS KEY HERE")

# Stream message
streamer.log("Turkey Says", "Gobble Gobble")

targetTemp = 160
targetReached = False

while True:
    # Set sample interval to 5 seconds
    time.sleep(5.0)

    # Read 8 bytes from ldusb0 and unpack them
    # little endian format
    # data 0: 1-Byte Sample Count
    # data 1: 1-Byte Sequence Number
    # data 2, 3, 4: 2-Byte Temperature Samples 
    ldusb = open("/dev/ldusb0")
    raw = ldusb.read(8)
    ldusb.close()
    data = list(struct.unpack("<BBHHH", raw))

    # Average together the three temperature samples and apply transform: C = Average/126.74 - 5.4
    cel = (data[2] + data[3] + data[4]) / 3 / 126.74 - 5.4
    fahr = (9.0/5.0 * cel) + 32.0
    # Adjusted temperature factor determined empirically 
    fahrAdj = fahr * 1.16
 
    # Stream it
    streamer.log("Temperature(F)", fahrAdj)
    if fahrAdj > targetTemp and not targetReached:
        streamer.log("Turkey Says", "I am cooked!!")
        targetReached = True

Line 6 sets up the destination “bucket” for our data stream. We will name the bucket “Turkey Temperature”. Every time you run this script, a new bucket named “Turkey Temperature” will be created under your Initial State account (identified by your access key), and all data generated from that script run will be contained there. Line 9 streams the first message to the newly constructed stream.

Reading the temperature from the Go!Temp probe (lines 16-32) follows the guide given at http://finninday.net/wiki/index.php/Vernier_Go_Temp_USB_device_in_Linux. Every five seconds, eight bytes are read from /dev/ldusb0.  Within these eight bytes are three 2-byte temperature readings from the probe.  However, these readings need to be converted to Celsius/Fahrenheit. After testing the conversion equation given in the finninday.net tutorial, I realized that my Go!Temp required a bit more calibration tuning to be accurate. I tested the reading on a few different temperatures and empirically determined the readings were off by a factor of 1.16 (hence the adjustment on line 32). I recommend doing similar tests on your Go!Temp probe and adjusting the conversion accordingly.

Streaming the calculated temperature happens on line 35. If you want to change how often the temperature is captured and streamed, change the sleep time on line 16.

We are ready for a test run. A good test to run is to capture the temperature change inside your oven when you preheat it. This will ensure that everything is working before you mess with your turkey. Set your preheat to something less than 115°C (239°F). Do not preheat more than 150°C (302°F) or you will damage your Go!Temp probe. Be careful to only put the thermally wrapped and shielded portion of the probe in the oven and start the preheat cycle. Run the python script at the command prompt (type “sudo python turkey_temp.py”).

TurkeyTemp6

Log into your Initial State account and a new log will pop up in your log shelf called “Turkey Temperature”. View this in Waves or Lines to see your temperature changes. My test run is shown above when I used my oven’s “fast preheat” option. It took my oven 6.58 minutes to reach 256°F where it then settled back to the target 240°F. I found it Interesting that this option overshoots the target then settles back down. I decided to do a second test run using my oven’s normal preheat option for comparison. This was a much more surprising result.

TurkeyTemp5

I learned that my oven is a liar. After 11 minutes, my oven beeped to tell me that it was preheated to 240°F. The temperature reading was only 184°F. For the next 10 minutes, it continued to preheat until it stabilized at 230°F. Huh? I have a hard enough time cooking as it is. I do not need any additional help from my oven to sabotage dinner.

Once everything is working, you are ready to cook. You will want to place the Go!Temp probe in the thigh of the turkey but do not touch the bone (b/c the bone heats up faster than the meat). A nice guide on exactly where to place a meat thermometer in a turkey can be found at http://karyosmond.com/where-do-you-stick-thermometer-turkey/.  Use a small knife or something sharp as a guide for your probe. Did I mention that the only thing that should be in the oven besides your turkey is the thermally wrapped portion of your Go!Temp probe and not your Raspberry Pi? Please don’t kill a perfectly good Pi. You are ready to cook and stream. Once you see that your turkey has reached its target temperature (160°F to 175°F depending on whose advice you take), your bird is cooked. Bon Appétit

**Note This tutorial pushes the Go!Temp probe to its temperature limits. If you cook your turkey at an oven temperature higher than 150°C (302°F), your Go!Temp probe may die. Follow all directions and restrictions listed in your Go!Temp probe’s instruction manual.

.

3 Responses

  1. bruce says:

    did you calibrate the temp sensor with ice water and boiling water? if not, how did you get “exact” measurements — 15% error is pretty shabby compared to the temp sensor specs.

    • Jamie Bailey says:

      I struggled with calibration due to lack of available documentation on how to get to and use the probe’s internal calibration values. I did boiling water, room temperature, and refrigerator temperature as measured by a traditional thermometer (and a few other temperatures around the house like in the garage and outside). The curve wasn’t a straight line like I hoped, especially at lower temperatures. At the high-end, it seemed pretty close making my calibration just a really rough one that was tweaked for high temperatures. Perhaps I got a lemon of a probe. I really want to find other temperature probes that work on extreme temperatures and have a digital output. There do not seem to be many options.

  2. Ben says:

    Hey there. I got the Pi to recognize the GoTemp and confirmed it using ‘lsusb’. However the /dev/ldusb0 file is not present and doesn’t seem to be getting written to. Any idea what’s going wrong?

Leave a Reply

Your email address will not be published. Required fields are marked *

« »

Initial State Technologies, Inc.
Scroll to top
Initial State