Brewing Log‎ > ‎

Untappd Kegerator

Untappd is all the rage with beer nerds these days. It's kinda like a foursquare for beer, where you "check-in" to beers, earn badges, and of course, see what (and where) your friends are drinking. The Untappd devs were kind enough to even put support in for homebrewed beers, allowing brewers to enter their own creations into the system. While Untappd has great Android and iOS apps, it always seemed silly to me while at home to have to find my phone every time I pulled a pint off the ole kegerator.

While surfing Seeed Studio one day, I noticed some nice hall-effect flow sensors. They were pressure safe, and made of nylon so they could handle carbonated beer with no problems. I also knew I had an extra Arduino Ethernet Shield languishing about and so the germ of an idea began to form... what if my kegerator could check-in my pours automatically? A little digging around the Untappd website yielded the last piece of the puzzle - an API!

How it works:
An interrupt routine on an Arduino calculates the RPM of flow sensors installed in the tap beer lines. Once it notices a tap flowing, it performs a beer "checkin" API call to api.untappd.com, lights the corresponding LED, and begins a 5 minute "lockout" timer to prevent multiple check-ins (from topping off a pint, etc). If the connection to api.untappd.com fails for some reason, the LEDs will flash alternately to signal the fault and the pour will be cleared. For kegerator maintenance (or pouring a pint for the neighbor), a button can be pressed to also suppress check-ins for 5 minutes. Both LEDs light in this case to signify the bypass. The Arduino also serves out a simple web server to the LAN for conveniently changing the Untappd beer IDs currently on each tap. Updates are saved to EEPROM.

Future enhancements:
There's lots of other cool Untappd API calls. I'd really like to have a small display (maybe Chumby sized?) on top of the kegerator, showing my Untappd friends beer check-ins in real-time. Also got an eye for Adafruit's PN532 RFID shield. It would be cool to hand out RFID tags to friends so the kegerator could recognize and check-in their pulls too! Some sound effects for Untappd badge awards would also be fun (and easy) to code.

Build your own:
Want to add Untappd to your kegerator? As long as you're comfortable with a soldering iron and some minor plumbing mods to your tap lines, this is a pretty easy project. In fact, it's an ideal intro to working with Arduino. Just about everything can be purchased from Adafruit (they started carrying the same flow sensors a couple days after I ordered mine from Seeed) and Radio Shack. Your local Radio Shack even carries Arduino if you're the impatient type.

Lastly, before we get started, a note about Arduinos. Because they are Open Source Hardware, there are many, many variants and clones. I'm particularly fond of Adafruit's breadboard friendly BoArduino. For this project however (and especially if you're an Arduino beginner), I recommend sticking with an official Uno. Interfacing the Ethernet Shield (daughter boards that plug into Arduinos are called shields) to a clone may be a bit non-obvious while it's plug-and-play with the Uno. There's also a version of Arduino that has Ethernet built-in that will work just fine. It's sometimes more expensive than an Uno and Ethernet Shield combined, however. Shop around.

Parts list:
Assembly:
  1. Tackle the plumbing bits first. It's a PITA if there's a leak after you've tied in all the wiring. Use plenty of teflon tape on the flow sensor threads and screw on the nylon FNPT to barb adapters good and tight. Either cut your tap lines, or better, take this opportunity to make them longer and buy some extra from your local homebrew store. Note the flow sensors do have a flow direction marked on the case.
  2. Once confirmed there's no leaks and you've pulled 2-3 pints to drink (just to make sure), feed in the 4 conductor wire to the flow sensors, however you chose. I ran mine down through the tap tower. Tie the power wires from each sensor together (red to red, black to black). The yellow from each is the signal back to the Arduino. That's why 4 conductors total are needed. It's unlikely you'll be able to keep wire colors consistent all the way back to the Arduino, so keep good notes along the way so you know what's what topside. Using Adafruit's waterproof connector makes for a nice clean in-fridge connection, but you can certainly get by with small wire nuts and electrical tape.
  3. Drill holes for 2 LEDs and the momentary switch in the project box as you see fit. Note there's not a lot of room above the Arduino / Ethernet Shield in the box I used, so you probably want to avoid that area. I used hot-melt glue to fix the LEDs in place, but superglue would work fine too.
  4. Cut up some of the female jumper wires. They'll be used in connecting stuff to the Arduino pins. You want them long enough so you've got room to work with the project box open, but not so long that you can't pack 'em all in when closed up. Go ahead and solder 4 female jumpers to the cable from the flow sensors. Use electric tape to insulate them from each other and again, remember to keep track of which colors lead to what sensor leads.
  5. Solder the short wires from both LEDs to one of the switch pins. Then solder a female jumper to the same pin. This is the ground for the LEDs and switch. Solder another female jumper to the opposite switch pin.
  6. Solder a resistor to each of the long LED wires. Trim things up to keep the space inside the project box manageable. Solder a female jumper to each of the resistors.
  7. Using pliers, carefully bend a row of the extra-long headers into a nice 90 degree angle. You need one header 3 pins wide and one 5 pins wide.
  8. Stack the Ethernet Shield on top of the Uno, carefully lining up all the pins. Now insert the 3 pin 90 deg header into the bottom female header of the Ethernet Shield, aligning to the 5V, GND, GND pins (yes there's two GND pins there). Insert the 5 pin header into the top female header aligning to pins 2-6. Note! Arduino pin numbering starts at 0 so there should be 2 open spots to the right of the installed 90 deg header.
  9. Connect the ground lead from the switch to one of the GND pins. Connect the lead that goes to the black wires of the flow sensors to the other GND pin. Finally, connect the lead that goes to the red sensor wires to the 5V pin. Power is done!
  10. Connect the lead that goes to tap #1's yellow sensor wire to pin 2, tap #2's yellow to pin 3. Now, the lead from tap #1's LED (you decide which is which) goes to pin 4 and #2's LED to pin 5. Last lead should be the switch - it goes to pin 6, of course.
Programming:
  1. If you've never done Arduino before, you probably want to play first with just the Uno and example programs that are included with the Arduino software. Once you've successfully compiled and loaded the "blink" example, you're ready to proceed with the build above.
  2. Start a new Arduino sketch and paste in this code. Edit the "Ethernet stuff" section as appropriate for your network.
  3. In the "untappd stuff" section, set your timezone and GMT offset as appropriate.
  4. The untappdaccesstoken constant is a little trickier. First, you need to register for API access from Untappd. This normally takes a day or two, but once accepted, you will be issued a Client ID for your kegerator app. As you'll also be the user of your own app you must generate an OAuth token that will allow the app access to your Untappd account. To do this, in a browser go to http://untappd.com/oauth/authenticate/?client_id=<YOURCLIENTID>&response_type=token&redirect_url=http://localhost and enter your Untappd login credentials. The redirect will fail but the OAuth registration is completed and the issued Access Token is displayed up in the browser address bar. Copy and paste it into the untappdaccesstoken constant.
  5. Plug the Uno into your computer, hit upload and STAND BACK! :-)
  6. If things go well, you're ready to plug the Ethernet Shield into your network. From a web browser, try connecting to the IP you assigned to the Arduino. If things are working correctly, you should see a page to set the Untappd beer IDs for your taps (showing gibberish, initially). Set them to the correct beer IDs and hit Submit. You're now ready to pull a pint and verify your Untappd check-in!
  7. If the LEDs blink alternately, that means the Arduino was unable to connect to api.untappd.com. Double-check your network settings.
  8. If the LED light stays on (a successful pour), but no check-in appears on your Untappd home page, it probably means the beer ID is invalid or your Access Token is wrong. You can uncomment the serial code bits in the checkIn() and setup() functions and use the Arduino UI's Serial Monitor to watch what's coming back from the Untappd server. That should give a good clue as to what's gone wrong.

Now that you're an Arduino master, consider all the brewing applications... What about a temperature controller and logger for your fermentation chamber? How about making your own PID (yeah, there's an Arduino library for that). Pretty cool, eh?



Comments