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








38 comments:

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Check out the updates I just made today. I had put this PCB together sometime back but never updated the blog post. Hope this helps.

      Delete
    2. Tim,
      I love this idea but don't know how to code. Would you be willing to build one for me? I love the use case.

      Thanks,
      Jeff Antone

      Delete
  2. Very neat project! You did a very good job at laying out what is needed and documenting your code. I may have to try this out!

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Can't get the web server to work for some reason. Have tried everything.
    I get following:
    insserv: warning: script 'K01thermserv' missing LSB tags and overrides
    insserv: warning: script 'thermserv' missing LSB tags and overrides

    ReplyDelete
    Replies
    1. Also, what version of node and npm are you running please?

      Delete
    2. I have the same problem. Is there a known issue?

      Delete
  5. I solved it.

    Download node here 'wget http://node-arm.herokuapp.com/node_0.10.36_armhf.deb'

    Then 'sudo dpkg -i node_0.10.36_armhf.deb'

    Should give you node -v of '0.10.36' and a npm -v of '1.4.28'

    Then sqlite3 and node-sqlite3 will install. :)

    ReplyDelete
  6. Hi, have you tried with a thermocople and thermocouple amp as this one:
    https://www.adafruit.com/products/269

    python code:
    https://learn.adafruit.com/max31855-thermocouple-python-library

    It should give you the same functionality but without having to do any of the soldering/wiring. Also, putting this in a box should be much easier.

    I have all the parts so I will try your code at some point.

    Thanks!
    Carlos

    ReplyDelete
    Replies
    1. Finding a food grade K-type thermocouple is super expensive. The analog type food probes that come with the off-the-shelf wireless devices are much more affordable.

      Delete
  7. I'm curious as to what min max settings and ohms at 25C you put into https://www.thermistor.com/calculators

    the only calc that lets you go above 250C is Z/D (-4.4%/C @ 25C) Mil Ratio B as far as I've found and I'm not seeing any min temp ranges on your thermistor link

    I have tried with various settings (not knowing the exact specs of the thermistor I was given), but everything it's given me for a,b,c results have been extremely incorrect.

    obviously I know the ohms at 25 C, but I've tried many min max ratings to get nothing but garbage (ie. 180C at a room temp of 30C)

    the only known factors are ohms at 25C and max rating of at least 250C

    ReplyDelete
    Replies
    1. I really don't remember. See link below for the formula I used with the abc values I used. This should work if you use all the same parts I did.

      https://github.com/tilimil/PIBBQMonitor/blob/master/logger.py

      Delete
  8. Ok, so ive bought the PCB built it and have tried several times to do the setup. I have the same issue as some have stated above."insserv: warning: script 'thermserv' missing LSB tags and overrides"
    I did notice when installing the npm install -g node-gyp i got the following warning:

    npm WARN engine boom@2.10.1: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.36","npm":"1.4.28"})
    npm WARN engine cryptiles@2.0.5: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.36","npm":"1.4.28"})
    npm WARN engine hoek@2.16.3: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.36","npm":"1.4.28"})

    Is this where the problem lies? I have to admit I am very green with programming. I'm not sure I have the files located in the correct places. I haven't been able to find an install of node 0.10.40

    ReplyDelete
    Replies
    1. Sorry, I did also try getting the latest node version v4.2.1 & npm 2.14.7 and it didn't work.

      Delete
    2. Are you sure you followed the directions in the readme? You should not have ended up with 0.10.36 if you did.

      https://github.com/tilimil/PIBBQMonitor/blob/master/README.md

      Delete
  9. Brilliant! So glad I found this. I've been thinking about starting a PI-based smoker temp probe project for a while, but never got around to it. Stumbling across your page was all the motivation I needed to finally get started. Thanks!

    ReplyDelete
  10. Replies
    1. UPDATE: working great with a Pi Zero on Jessie
      http://tinypic.com/r/16k3qqb/9

      This is my first Pi project & didn't have too many issues with the instructions. Little stumble with node-sqlite3 & sqlite3.

      I had to remove gpy to get none-sqlite3 to install:
      sudo apt-get remove gpy

      Also had to install sqlite3 through npm (unsafe perm tag important!)
      sudo install sqlite3@latest --unsafe-perm

      Things seemed to be working fine after that, although to get it writing to the DB I had to make all python scrips executable:
      chmod +x logger.py
      chmod +x alert.py

      Still working on getting the email alert functioning. Thanks to Tim for posting the how-to & PCB board!

      Delete
    2. Hi,

      I'm having problem on my B+ with Jessie as well and I think it might be the same problem, but I can't come around it like you said you did. Is it possible that you can specify what you did different?

      /L

      Delete
    3. Lars,

      Happy to help, but I posted the exact lines I ran to fix it. I tried to keep a running log of every command I entered but instead of posting all that, if you posted the errors & what commands you're running we can isolate the issue.

      Delete
    4. This comment has been removed by the author.

      Delete
    5. I got it working after a few tries - thanks a lot for your post, it helped me a lot!

      I think you don't need to do everything below but this is what I did.
      sudo apt-get remove gyp
      sudo npm install -g node-gyp
      sudo apt-get remove sqlite3
      sudo install sqlite3@latest --unsafe-perm
      sudo apt-get install sqlite3

      Then I edited logger-py and web/index.html to show temperatures in C instead. And in web/index.html you can change timezone offset if the time is wrong,

      Delete
  11. What was your cost not including the Pi?

    ReplyDelete
  12. All prices shipped
    $36.99 2 probes (meat & air)
    $13.75 (for 3) boards
    $21.63 digikey
    $5.97 case
    $19.98 IC & usb WIFI

    $98.32

    .99 pi zero
    .99 4gb microsd
    If you wanna count those, I had the SD laying around. You could definitely do it a tad cheaper if you split a pcb board order or just ditched all the fanciness and soldered directly to the PI. Either way it's an awesome little tool. I love exporting the cook into CSV and archiving a graph of each one

    ReplyDelete
  13. Very awesome. Glad you guys were able to use this! I still use mine all the time. I love being able to check a brisket while away from the house.

    ReplyDelete
  14. do you have a picture with your pcb? I'm afraid I have something turned the wrong direction when I was soldering

    ReplyDelete
    Replies
    1. Take a look at the tinypic url I posted. The only thing that's directional is the IC (little dimple in one side) & GPIO header (pin one should be marked)

      Delete
  15. It was a great post written on Three probe temperature monitor for BBQ/Smoker using Raspberry Pi.
    Best Wishes from
    Disposable Temperature Monitoring Probe

    ReplyDelete
  16. This is really very informative article about monitoring of temperature.very awesome that,you have best try to understand all about temperature using very effective images.i like this very much.although i have searching about grill temperature solution of cooking chicken grill.anyways i have huge learned your content about monitoring temperature.

    ReplyDelete
  17. I want to thank you for this article. I've made a slightly different version to tie into some of my existing home components. Using a Pi zero, and your python code (revised) I'm sending my temperature readings every 15 seconds via REST API to my InfluxDB and Grafana stack running on a virtual machine for realtime monitoring and historical graphing. Now, along with all my other HA data points, I can view how my smoker is running and analyze temperature trends over time.

    ReplyDelete
  18. I'm trying to install the pibbqmonitor on a raspberry Pi Zero W running Raspbian Stretch Lite Kernel version 4.14.

    I'm having trouble with sqlite3. i originally tried the instructions on the tilimil/PIBBQMonitor github, which failed. I've also tried the steps used by Lars Fredriksson above, but with the same result.

    The Putty sysout is pasted below.

    Any suggestions?

    Thank you

    pi@raspberrypi:~ $ sudo npm install sqlite3@latest --unsafe-perm
    /
    > sqlite3@4.0.0 install /home/pi/node_modules/sqlite3
    > node-pre-gyp install --fallback-to-build

    node-pre-gyp ERR! UNCAUGHT EXCEPTION
    node-pre-gyp ERR! stack TypeError: Buffer.alloc is not a function
    node-pre-gyp ERR! stack at Object. (/home/pi/node_modules/sqlite3 /node_modules/tar/lib/pack.js:32:20)
    node-pre-gyp ERR! stack at Module._compile (module.js:435:26)
    node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:442:10)
    node-pre-gyp ERR! stack at Module.load (module.js:356:32)
    node-pre-gyp ERR! stack at Function.Module._load (module.js:311:12)
    node-pre-gyp ERR! stack at Module.require (module.js:366:17)
    node-pre-gyp ERR! stack at require (module.js:385:17)
    node-pre-gyp ERR! stack at Object. (/home/pi/node_modules/sqlite3 /node_modules/tar/lib/create.js:6:14)
    node-pre-gyp ERR! stack at Module._compile (module.js:435:26)
    node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:442:10)
    node-pre-gyp ERR! System Linux 4.14.34+
    node-pre-gyp ERR! command "/usr/local/bin/node" "/home/pi/node_modules/sqlite3/n ode_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
    node-pre-gyp ERR! cwd /home/pi/node_modules/sqlite3
    node-pre-gyp ERR! node -v v4.2.1
    node-pre-gyp ERR! node-pre-gyp -v v0.9.0
    node-pre-gyp ERR! This is a bug in `node-pre-gyp`.
    node-pre-gyp ERR! Try to update node-pre-gyp and file an issue if it does not he lp:
    node-pre-gyp ERR!
    npm ERR! Linux 4.14.34+
    npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "sqlite3@late st" "--unsafe-perm"
    npm ERR! node v4.2.1
    npm ERR! npm v2.14.7
    npm ERR! code ELIFECYCLE

    npm ERR! sqlite3@4.0.0 install: `node-pre-gyp install --fallback-to-build`
    npm ERR! Exit status 7
    npm ERR!
    npm ERR! Failed at the sqlite3@4.0.0 install script 'node-pre-gyp install --fall back-to-build'.
    npm ERR! This is most likely a problem with the sqlite3 package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR! node-pre-gyp install --fallback-to-build
    npm ERR! You can get their info via:
    npm ERR! npm owner ls sqlite3
    npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
    npm ERR! /home/pi/npm-debug.log

    ReplyDelete
  19. BTW, if I try sudo install sqlite3@latest --unsafe-perm as listed in Lars' comment above it falis (see below), so I assume the npm argument is needed.

    pi@raspberrypi:~ $ sudo install sqlite3@latest --unsafe-perm
    install: unrecognized option '--unsafe-perm'
    Try 'install --help' for more information.

    ReplyDelete

  20. If you would like to obtain a good deal from this piece of writing then you have to apply these methods magnum 4d live to your won webpage. The Gaming Club bears a license from the admin of Gibraltar, and claims to be one of a prefer few casinos that have a license from the Gibraltar government. A enthusiast of the Interactive Gaming Council (IGC), The Gaming Club follows all the guidelines laid all along by the organization, something that has later a long pretension in it visceral ascribed as a great area to gamble online.

    Everything nearly The Gaming Club feels good; be it the promotions, the big number of games, the multiple banking options on offer, the radical security measures, or the fair and blamed gaming practices the casino adopts.

    The Gaming Club motors along on software developed by one of the giants of online gaming software fee Microgaming. The software it uses is highly developed and has a range of features expected to complement your online gambling experience and make you desire to arrive assist after all circular of gambling you realize here.

    Another hallmark of a fine casino is the atmosphere of its customer preserve team, and The Gaming Club does not disappoint on this front.

    ReplyDelete
  21. Finally got it working on Buster on a pi zero w using Lars' instructions along with a newer version of Node. Instructions for the new version of Node: https://www.thepolyglotdeveloper.com/2018/03/install-nodejs-raspberry-pi-zero-w-nodesource/

    Latest version of Node: https://nodejs.org/dist/latest-v11.x/node-v11.15.0-linux-armv6l.tar.gz

    ReplyDelete