top of page

Arduino Kegerator Tracking


Please note: The version of the tap handle being shown here is also the a prototype print (thus the rough finish), although the functions shown are the same as the final product.


Background: In the past, I had messed around with Raspberry Pi's, but I always wanted to learn Arduino. After doing some research, I jumped in and purchased a cheap starter kit on Amazon and started watching Paul McWhorter's amazing (and free!) video series on YouTube. For anyone wanting to get started with Arduino, I can't recommend this channel enough. After the first few courses and bringing circuits to life, I decided I needed a project to do on my own. And the Kegerator Tracker was born.


The Project: My father has a kegerator but never knows when it is about to be empty. I figured I could fix this with Arduino. Looking around the internet, I couldn't find anyone doing something similar. After some general research, I determined there were a few different ways to track the volume left in the keg:

  1. Flow Valve

    • Pros:

      • Very accurate

    • Cons:

      • Changing the pressure of the beer leads to more foam

      • Potentially unsanitary

2. Scale

  • Pros:

    • Pretty accurate

  • Cons:

    • Cutting holes in the kegerator for the wires and Arduino is not ideal

3. Accelerometer - The Winner!

  • Pros:

    • Very small and easy to install

  • Cons:

    • Somewhat accurate

    • Needs to be calibrated initially


In the end, I decided on using an accelerometer. It would be accurate enough and the least intrusive installation. This was important too since, after all, this wasn't even my kegerator.


Pseudocode:

The basic idea would be simple. Arduino works but constantly running in a loop. In that loop the program will basically do the following:

  • Set variables such as the total ounces in a keg for which keg size we are using, etc.

  • "While loop" that checks accelerometer data.

    • If one of the axis breaks a certain threshold (beer is pouring) then start counting downwards from the total ounces in the keg.

    • Display how many ounces are poured on the screen for initial calibration reference

    • After this loop finishes, do some math subtracting the ounces poured from the keg total and determine how many beer pours are left (12 oz and 16 oz)

  • Display helpful data such as how much beer is left on the screen in a variety of ways

    • Make sure we are always on Wi-Fi. Display errors if we lose connection


An Offline Prototype:

The idea would be that I could take the tiny accelerometer chip, screw it into the top of a tap handle, and start tracking whenever the handle breaks a certain plane in which it starts to pour. When the beer is pouring, we will have to get a rough idea of the flow rate which is easy enough to do by pouring a few ounces into a shot glass or measuring cup and determine how much time it took. After that, we simply count down, ounce by ounce, from the total ounces left in the keg. Speaking of that - a kegerator can hold a variety of keg sizes - we need to account for this too.

Because I was developing this project and learning Arduino simultaneously, I only knew how to use LCD screens and my Arduino UNO board (which doesn't have WiFi). I also wasn't familiar with amazing I2C protocol at the time and was therefore left with a giant mess of wires.

Organized Chaos: Before knowing about I2C

As I learned more, I cleaned up the wiring by using I2C, and began 3D printing cases for the project with my Prusa Mini. The project had nearly finished for my initial goal. The code was written, there was a working prototype, and the hardware had a somewhat clean looking case. I also added features such as a 3-way rocker switch (on the left of the picture below) which changes between a 1/6, 1/4, and a 1/2 barrel keg depending on position, and a big red button that the user could press to reset the keg, alerting the program to start over. As I went through the lessons and researched Arduino on my own though, it wasn't long before I had some ideas in improving the design and taking a giant leap forward.

The offline project box. A working prototype.

The Internet of Things:

As soon as I learned about ESP8266 and ESP32 chips, I knew that I had to implement them into the Kegerator Tracker. This was a much smaller board and Wi-Fi was built in! Not only thins, but the data can sync up the Arduino Cloud. While this was a really nice feature to have - now the data can be accessed and tracked from anywhere, including a phone - it was also important because it saved the data in the event that the Arduino lost power. Moving to the cloud was a huge step forward, albeit probably an obvious one to those who know even a little about Arduino.


With my new knowledge and discovery of the Arduino Cloud with it's pretty dashboards, I had an idea. Why not just print out an entire tap handle with the spare 5" monitor I had laying around? I could use a Raspberry Pi to power the monitor, show the dashboard in full screen mode, and mount an Arduino on the back with the accelerometer to feed the data.

After many iterations, the design was functional, but not exactly what I wanted. This was in part due to the size of the screen. The tap handle, while functional and informative, was essentially a monitor case with a grip. I wanted to create something better that more closely resembled an actual tap handle.


The "tap handle" was also very thick with the Raspberry Pi, Arduino, and cases.
Back view (with the Arduino board not mounted and a Pi Zero for sizing)
There are always hiccups along the way
Lots of prototypes for different versions of the handle

My next and final design was to print an entire tap handle out and make the inside of it hollow. It still had to be thick and somewhat strong though, as it had to pull the lever on the kegerator. With my 3D printer being a Prusa Mini, the maximum print size was 7", and I was going to use every millimeter. My plan was to recess everything inside of the handle- the accelerometer, the Arduino and (most) of the wiring. The board I would use for this would be the Wemos D1 Mini, super tiny Arduino chip with Wi-Fi built in that would serve the purpose of this project well. I would then output the display on a tiny 128x64 pixel OLED screen. I was able to consolidate the important data into the screen. Every 10 seconds, the screen would show either the percentage of the keg left, or how many pints were available. In a smaller text on top of the screen, it would also show how many ounces total were left as well as how many 12-oz beer pours were left. I also synced the Arduino with date + time, so I have special Easter egg messages that appear at various times, e.g. "Merry Xmas!" on the Christmas day. More detailed and historical data was available on the Arduino cloud.

Oh yeah - and remember we had to be able to tell the program different keg sizes? The way we do this is through the Arduino cloud but messaging the program! The user simply has to message the program, and it will wirelessly update accordingly:

Now it was time for the final hardware piece. After getting the calipers out and printing many prototypes of the tap handle, I finally got a model I was happy with that fit everything perfectly. I soldered everything together, installed it, and screwed on the back cover and tested it out. Everything worked perfectly and the project was in a state that I was happy to call completed.

All set and ready for the backplate
Wiring diagram I drew up showing the configuration
Smooth as a baby's bottom

A list of hardware used as well as the source code and STL files can be found on my Github repo and Thingiverse profile accordingly.


If you have any questions on the project, feel free to comment down below. Thanks for reading!


-Ryan

Comments


bottom of page