Introduction: *duino Keg Temp Monitor, or the Quest for the Perfect Pint
Despite conventional wisdom, the Guinness is usually NOT served warm on the Emerald Isle - there were few places I drank in that relied on "cellar" temp to cool their beer. According to the Guinness Storehouse, the Guinnness should be served at 8° C (46°F), which means it needs to be colder than that in the kegerator, as the laws of thermodynamics definitely apply to beer kegs. A guy in Donegal (where they serve the finest pints!) told me he keeps his kegs at 3°C (37.4°F), figuring by the time the pour ends it'll be close to factory specs.
Usually we keep fine homebrewed kegs of ales, pale ales, barley wines and stouts on tap at the Check 6, but lately the Guinness has become de rigeuer. The problem is, I never really paid that much attention to the temp of my kegerator. My beer always seemed cold enough and no one ever complained, but when I stuck an old school fridge themometer in there recently, I was shocked at how warm it was :-)
So why build this? Fridge thermometers work just fine but you have to open the kegerator every time you want to check the temp. And every time you open the door it screws up the controlled thermal environment. Using this little guy allows you to track inside temps which will help you find the proper setting for your kegerator thermostat.
Enter the Arduino + DS18B20...
Step 1: Find a Project Box
Any old project box could do, but not at the Check 6 Saloon - we need something a little more elegant. v1.0 was hacked out from a hunk of Eastern Cedar, which has some nice character but didn't match the dark woods in the Check 6 Saloon. A few days ago my partner (no, not that kinda partner) and I went over to his Grandad's house to pick up some walnut that had fallen and been roughly boarded. Absolutely beautiful stuff to work! After several runs through the table saw, planer, chop saw, router and mill, we came up with project box v2.0, which is roughly 4"x 3.5". This oughtta fit the guts nicely.
Step 2: Choose an Arduino and Collect Your Parts
You have several choices here, so choose your board according to your needs . In my case, I needed something I could program using the Arduino IDE -- I say "program" but I really mean borrow open source code and hack to my needs :-) I had a few Arduino Unos laying around but they have a rather large footptint and after all, we just need to run a couple of temp sensors and print out the readings on an LCD screen. IMHO, a full-up Arduino is a bit of overkill -- why use a $30 microcontroller when you can use something that does the same thing for a lot cheaper?
Originally I thought I'd use an ATTiny85 - I have a whole sleeve of them I ordered just to have for stuff like this - but I was too lazy to hook them up to my breadboard and mess with the code. So...I ordered a Digispark development board (which uses the ATTiny85), thinking that would do the trick. Wrong-o! While these boards are pretty cool, they are limited by the ATTiny memory of 8k (6k after the bootloader is jammed into the thing). Coding guys could probably find a way to make the Digispark work for this, but unfortunately I'm not one of them. And, I needed to get this thing up and running before I swapped out my Guinness keg with a new one! After a quick bit of googling I decided I'd use the Arduino Nano, which uses the same chip as the Uno (AT328 w/32k) and has a much smaller footprint.
Here's a list of all the parts I used for this build. A lot of this stuff I had in my parts rack that I bought a while ago, just waiting for projects like this:
Project Box (see Step 1)
16x2 LCD display
Adafruit i2c/SPI LCD backpack
DS18B20 temp sensor (x2)
3.5mm TRS female stereo connector jack (x2)
3.5mm TRS stereo connector cords (x2)
Mini rocker switches
9v DC wall wart
2.5mm DC power plugs (We'll need to solder one of these onto the wall wart)
2.5mm DCpower jack
Small PCB to hookup switch, PWR inputs and sensors
Hardware for case, as required
This build is very easy to make portable by using a battery pack (>5V) instead of the external DC power scheme I used.
Step 3: Sensors
This build is easily modifed to fit your needs. Once you have your Arduino, you need a couple of temperature sensors. I opted for the Dallas Semiconductor (now Maxim) DS18B20, a programable digital temp probe that's used a lot for these kind of projects. These babies are pretty accurate with a tolerance of +/- 0.0625°C, and there is an awesomely simple arduino library out there that makes things tolerable on the programming end. The bonus is you can string a bunch of them together and run them off of one input pin, which will come in handy when it comes to pouring the perfect pint.
Originally I ordered a few waterproof DC18B20's from a supplier on eBay, four to be exact. Unfortunately none of them worked - cheapo-Chicom copies of the real thing. I ended up ordering the real deals from Digispark and tested them using the Arduino 1-Wire Address Finder to confirm they were good. These things need a 4.7Ω pullup connected between pin 2 and 3 to get them to work (see diagram).
While you could hardwire the sensors into the arduino, I made mine modular - I can plug and unplug them at will and make the box portable. (This comes in very handy for checking the mash temp while brewing beer.) So I wired a male TRS (tip-ring-sleeve) 3.5mm stereo plug to each sensor. The tip we'll use for data, the sleeve for power and the ring is GND (see pic). I carefully encased the 3 pins from each sensor in epoxy - right where they go into the casing - making them waterproof.
For this build I'm using two sensors - one for the kegerator temp and one for the 'beer' temp, which I'll talk about in a minute. The "Box" probe is routed throught the top of the tower into and into the kegerator, where it just hangs in midair as close to the middle of the box and not touching anything. It reports the keg temp to the arduino. The "Beer" is wired in parallel and pigtailed off the box probe line. It sits in a glass of salt water and gives a rough approximation of the beer temp.
Short of stuffing a probe into the middle of the keg, there's really no way to get a dead-on reading of the beer temp itself. Another option -- if you use a cooling fan that draws cold air up into the tower (which I do) -- is taking a temp in the glass just after the pour, which will be somewhat accurate. Either way, you're not going to get true beer temperature.
Going forward, my plan is to log the temps from the sensor in the salt water and in the glass directly after the pour. Once I find the correlation between the two, I should be able to tweak the code to adjust for the difference. But for now, I'm content with the setup I have.
Step 4: Build the Board
We don't really need much on this build and the circuit couldn't be easier. We need:
- External power to the Nano and an on/off switch if desired)
- The sensor(s) into nano Digital Pin 2
- Power to the LCD and i2C output (SDA and SCL) into Nano Pins A4 and A5
I sketched up a poor rendition of the circuit in Photoshop. While I have Eagle, I really never learned how to use it. Same thing for Fritzing.
Step 5: Code It
You can download my sketch below. It uses the following libraries which are also attached:
Wire - Should already be installed on the Arduion IDE
OneWire - Allows access to OneWire devices like the DS18B20
LiquidTWI - Gets the Adafruit LCD i2C backpack running
Dallas Temperature - builds on the OneWire library and faciltates use of the DS18B20
My sketch was cobbed together from several bits of code I ran across making use of the DS18B20 and i2C LED backpack. It's heavily commented so hopefully you won't have any questions!
Step 6: Enjoy the Perfect Pint!
Hopefully with this simple device you'll be able to find the perfect setting for your kegerator and enjoy your beer the way it's supposed to be served! Yes, I know there are off-the-shelf fridge temp controllers that can control your keg temp better than doing it manually, but hey, what fun is that? Building stuff yourself rocks :-)
If you like this, please vote for it! Voting ends Nov 11th, and whatever I win goes to Wounded Warriors. Vote early, vote often! Pass this around, it's for a good cause!