# The Data Science Behind BBQ

Smoking ribs or a pork shoulder requires lots of patience and practice. When everything works, you get to enjoy an amazing dinner. When things go wrong, you end up with dry, overcooked meat that only your dog may enjoy. Here’s what great BBQ looks like from @AndreasHarsch.

My process of smoking meat, cheese, or even ice cream is to monitor only the meat temperature and the internal temperature of the smoker. When I finish a cook, I go back and try to learn from the data. I do not attempt to control the smoker using the Internet of Things, I use IoT to collect the data with ThingSpeak, analyze the data with MATLAB, and apply the insights to the next cook. The best advice that I have been given is to not change too many variables. Stick with simple rubs, the same charcoal, the same wood, the same cuts of meat, etc. Only change one variable for one cook. It takes years of trial and error before you get great at BBQ.

With the help of ThingSpeak and MATLAB, I can help you understand one of the more frustrating parts of smoking meats… the stall! The stall is a period of time where what you are cooking does not seem to be increasing in internal temperature. I used to panic during the stall and mess with the temperature by adding more charcoal or turning the vents. Overtime, I realized this is normal. No reason to panic.

Cooking is taking something cold and getting its internal temperature up to a safe level. Everything that you cook has a different target internal temperature, but generally the sweet spot is 190-205F. Smoking is about low and slow cooking. This means that you are trying to raise that internal temperature slowly with a low temperature. I use a cook temperature of 230-250F. This means that smoking takes a lot of time to properly cook. In some cases, this is two hours per pound. Things don’t change much minute to minute in a BBQ pit, so you can collect data every few minutes and still have an accurate picture of what’s happening.

## Collecting Data

First, I set up a ThingSpeak channel to store my temperature data. One field is for the smoker’s temperature and field two is for the internal temperature of what I am cooking. To get the data, you have many options. I did a quick search around the internet and discovered hundreds of Arduino and ThingSpeak projects to get data from a smoker. In general you need two temperature probes that can take the heat of the smoker, connectors, an Arduino with Wi-Fi like the MKR1000.

## Analyzing the Temperature Data

The first step is to read in the temperature data using MATLAB that was collected by ThingSpeak. Data on ThingSpeak is stored in a channel and identified by a channelID. If you have a private channel, you will need to supply a Read API Key to get access to the data.

smokerTT = thingSpeakRead(279400,'ReadKey','9AYZQDT1XFDM98FW','OutputFormat','timetable','NumPoints',115);

Sometimes the data from your temperature probe is noisey. This means the value that the temperature probe reports is sometimes higher or lower than the actual temperature. If you take a few samples and take a median, you get a consistent result. In MATLAB, I use smoothdata to take a moving median of my time-series sensor data.

smoothSmoker = smoothdata(smokerTT);

After I clean up the data, I want to visualize it and to see what happened. This is a good time to learn how long things actually take, so on your next cook you budget the right amount of time and don’t rush any phases.

plot(smoothSmoker.Timestamps, smoothSmoker.Variables);

I can use this data to determine how long the total cook will last and even set alerts using ThingSpeak. I tend to watch the smoker and tend the fire.

## Results

After a lot of research, I discovered what the stall is doing and why it is important to keep your patience and push forward. This is starting to sound like a metaphor for life. According to Prof. Greg Blonder, “The stall is evaporative cooling”. Prof. Greg is a physicist, entrepreneur, former Chief Technical Advisor at AT&T’s legendary Bell Labs, and regularly contributes to AmazingRibs.com. He likes to bust myths about barbequing and help us understand the thermodynamics of cooking. You are heating the meat slowly, but the moisuture in the meat is evapotaring at the same rate. This effect causes a stall in the temperature rise. The temperature of the meat will go up when the moisture is depleted. The stall is important to the cooking process and leads to something called the bark. This is an outer layer of the meat that is slightly thicker and less tender than the rest of the meat, but traps in lots of flavor and adds to its complexity. So, don’t rush during the stall. Keep the smoker temperature constant – avoid the temptation to turn the heat up to get through faster. And in the end, enjoy some well made BBQ with friends and family over the summer weekends and holidays.

|