How fun would it to be able to actually read temperatures at 500º F and beyond with a microcontroller? This is a job for the thermocouple sensor.
The thermocouple, thermocouple amplifier and other parts arrived this past Monday. Within short order, I discovered that the 52-year old oven in my kitchen was off by a mile. My wife always said it was 25º F on the high side.
Today, we’ll start looking into using these sensors to capture real-time PancakeBot temperatures on our PancakeBot, covered in last week’s edition of Off-the-Shelf Hacker. I thought analyzing temperature data, as the PancakeBot prints out a pancake, might lead to interesting patterns of operational behavior. Consistent pancake production requires an understanding of the physical characteristics of the machine. Microcontrollers, sensors, software and data capture fit this kind of work, very well.
What’s Inside a Thermocouple?
A thermocouple is composed of two dissimilar metal wires, fused together at the business end. The fused wires produce an exceedingly small voltage that’s amplified, then processed into a digital signal, that’s then sent to your computing stack. I used an Arduino Duemilanove controller to read the digital signal, from the amplifier, then forwarded the data to my Linux notebook over the USB cable.
There are about a half dozen different kinds of thermocouples, with the K-type being the most common. I used a standard glass braid insulated K-type thermocouple from Adafruit. It registers temperatures up to 900º F.
Thermocouples generate such small voltages that an amplifier is needed to get a reading. I used a MAX31856 universal thermocouple amplifier breakout board for this project. This particular amplifier board can take readings from all the different thermocouple types and outputs data over the SPI bus. The SPI bus requires 4 data lines, plus power and a ground connection.
Complete coverage of how to hook up the thermocouple and amplifier are found in this Adafruit tutorial.
The amplifier board and thermocouple worked on the first try, although the data numbers dropped as the temperature of the probe increased. This is a dead give-away that the thermocouple leads were reversed. Unbolting the two leads and switching them around, then screwing them back into the terminal block made the numbers go the right direction.
My thought is to use a thermocouple to capture the temperature of the griddle during PancakeBot operation. The griddle uses household current through a heating element built into the cooking surface. It should be a simple matter of attaching the thermocouple probe to the bottom of the griddle to directly measure the heating element temperature and variation, as a pancake is cooked.
As it turns out, properly mounting a thermocouple is tricky. This “Understanding the Challenges of Surface Temperature Measurement Using Thermocouples” white paper explains things in great detail. Basically, it says that permanently mounted thermocouples, as opposed to temporarily mounted ones (say with electrical tape), should be fairly accurate and reliable. We certainly want a reliable, accurate and fast response to our PancakeBot temperatures.
My plan is to mechanically attach the thermocouple end to the bottom of the griddle with some kind of bracket. With the sensor working, I’ll figure out the mounting details as the project progresses.
Oven Testing: “It’s Always Overcooked”
Using the oven in the kitchen provided an easily accessible test setup for the thermocouple.
Data flows from the amplifier to the Arduino, then to the Linux notebook. I compiled and uploaded the MAX31856 example code, that was included in the MAX31856 library. A breadboard was used to connect the amp to the Arduino.
I placed the notebook, breadboard, Arduino and thermocouple/amplifier board rig on the kitchen counter, next to the oven.
To take the readings I simply unrolled the thermocouple wire and placed the tip inside the oven, while closing the door held it in position. The flexible braided fiberglass seal around the inside of the door provided a gentle passage for the wires, so there was little risk of damage.
Once the Arduino was plugged in, it was easy to capture the data using the quick and dirty “cat on the Linux command-line method”:
rob% cat /dev/ttyUSB0 > temp.txt
Check out the data in a terminal window, after a short capture period, with the oven dial temperature set at 300º F.
I also took readings at 50º intervals, from 200 to 500. After removing the text at the beginning of each line and summarizing, I plugged the data into a LibreOffice Calc spreadsheet and produced the following plot. The blue line is the dial setting and the red one is the temperature measured by the thermocouple. Wow, the temperature is way high at the low end and slightly low at the high end.
The graph definitely explains some of my kitchen disasters over the past 20 years.
Now you know about thermocouples and their associated amplifiers. We also looked at real-life data coming from the sensor.
In an upcoming column, I’ll introduce the MLX90614 Melexis contactless infrared sensor. You thought the thermocouple and amp were interesting? This thing reads temperature through a little window on the front of the device, without any physical contact with a surface.
We’ll integrate all these sensors into our PancakeBot telemetry and R&D efforts.
Stay tuned and Merry Christmas.