Wednesday, September 3, 2014

Three probe temperature monitor for BBQ/Smoker using Raspberry Pi

I started out looking for a remote thermometer for my smoker that had three probes: one for the smoker and two for meat.  I also wanted to be able to monitor the temperatures via Wifi whether I was inside the house or away from the house.  Raspberry PI seemed like a good way to do this on the cheap (compared to solutions on the market) while trying out a fun project.  The result of my project is documented here so that others can hopefully take advantage of the work I did.

Hardware Update (Custom PCB and RPI B+)

I ended up making a few more of these and decided to try and make my own custom PCB because the humble PI didn't fit on the Raspberry PI Model B+.  And the PCB makes it much easier because you don't have to deal with all of the wires.  If you get these parts, you don't have to worry about the complexities of the wiring diagram below.  You just have to solder the parts onto the board.   Updated hardware list is below:


The Hardware (Original)


Wiring with the original parts list

Skip this section if you get the PCB.

First, I had to put together the hardware.  I wired up the MCP 3008 to the RPI using the Humble PI board and the following MCP3008 wiring diagram:

From there it was just a matter of wiring my thermistor probes to channel 0, 1 and 2.  The only complexity there was the voltage divider using the 1k ohm probes to give me some more discreet measurements.  It still doesn't give me quite enough variance at the lower temperatures (below 100F) but it seems to get more accurate and consistent as you get above that so it is good enough for my purposes.  See below for a diagram of how I wired the probes:
















Then I wired pin 9-16 of the MCP3008 to the RPi GPIO as follows:

MCP3008 VDD -> 3.3V (red)
MCP3008 VREF -> 3.3V (red)
MCP3008 AGND -> GND (black)
MCP3008 CLK -> #18 (orange)
MCP3008 DOUT -> #23 (yellow)
MCP3008 DIN -> #24 (blue)
MCP3008 CS -> #25 (violet)
MCP3008 DGND -> GND (black)

Mounting

I ended up mounting the board in a small waterproof box and mounting the 2.5 mm jacks on the outside of the box.  This should allow me to leave it out in the rain as long as the jack and power cord are facing down.


After it was all buttoned up it looks like below.  I put the hole for the power cable on the line between the lid and the box, this way I wouldn't have had to drill a larger hole for the USB connector to fit through.  Also, I glued some magnetic strips to the back of the box so it can be attached to the side of the grill (where its not too hot of course).




The Software

Temperature Logging

Now I was ready to start reading the temperatures. The basics included a python script that I got from adafruit to read to values from the ADC and log them to a SQLite database.  It took some trial and error to determine which formula worked best to convert resistance to temperatures based on the Thermoworks thermistor probe that I was using.  A good source for these formula's can be found here.

Once I had the temperatures logging to the database every minute via cron I needed a web interface.  I already knew I wanted to use node.js and I found the good work that Tomas Holderness had done.  I used this as a start and built the web interface from there.  I modified quite a bit of stuff and on the highcharts library and how I was reading data into the Highcharts library.  I also added in Twitter bootstrap to make the web interface look clean and work across mobile and desktop platforms.

All my code is posted on github.


Configuration

I used Twitter bootstrap modals to create a nice popup and send form data to the node.js app.  The node.js app then takes the data and lays down the configuration on the filesystem.  For example, the ip information received is used to update the /etc/network/interfaces file.  The DNS information is used to update /etc/resolv.conf.


Wireless

The wireless setup is pretty straightforward and allows to WPA/WPA2 preshared key.  It want to use it in an area where there is no wireless AP to connect to, it also allows for adhoc networking.  This will allow you to connect your phone directly to the RPi and view the web interface.  Obviously, alerting will not be able to send email in this mode.

Alerting

The last thing I did was add some alerting capabilities.  The alerting allows you to set a high and low threshold for each sensor.  You can set any of the thresholds to 0 to disable them. There is also a hold down timer that basically defines how long a threshold must be broken before you send an email.  In my case, I just have it send an email to my SMS email address for my phone so I will get a text message.  I have ATT so I just send an email to 1234567890@txt.att.net and I get nice alerts on my phone.


Screenshots

Large Browser
Mobile Browser


The only other big thing I added was a configuration page to allow a user to change the IP and wireless network settings directly from the web interface without having to go the the shell on the RPi to change them.  The popups use the cool modal's that Twitter Bootstrap gives us and then it uses an HTML form to pass the vars to the node server app.  The node server app then goes to the filesystem and makes the appropriate changes to the filesystem of the RPi.  Specific files it modifies are /etc/wpa_supplicant/wpa_supplicant.conf and /etc/network/interfaces.  I was using "Raspbian GNU/Linux 7 (wheezy)" so hopefully this works for everybody.

IP Settings Configuration Page




Wireless Settings Configuration Page


Sensor Alerts Configuration Page


Email Configuration Page