16 Jul 2016
Kegbot + Kegberry Pitfalls
I just finished helping my homebrewing housemate build a kegbot + kegberry for his three tap kegerator. Kegbot is an open source project that provides tools for homebrewers to digitzie their kegerators, providing features such as volume and temperature monitoring and even RFID controlled beer access. Unfortunately, like many small opensource projects, kegbot’s documentation has a few gaping holes in it. Completing the project took more effort (research and debugging) than we originally thought it would. There were several problems we ran into that had no solutions posted in either the official forum or in the docs, which I found to be incredible. The purpose of this post is to share our kegbot configuration, the problems we faced and their solutions!
Our Kegbot Configuration
We decided on the DIY version of kegbot since the store on the kegbot website is semipermanently offline. I had a RasberryPi sitting around already so we decided to go with a kegberry instead of hunting down a compatible android tablet. Instead of installing the libaray on Raspbian on our own we used the kegberry image V2.1.1. We bought and flashed our own Arduino with the kegboard library. The only other hardware we needed was two kegbot compatible flowmeters from Adafruit.
How does the hardware fit together? Beer goes through the flowmeters. The flowmeters connect to the Arduino’s IO headers. The Arduino connects via USB with the Pi. The Pi then displays the kegbot server homepage (full of keg) statistics etc.) on a monitor connected to the Pi over HDMI. Also, we want to get the Pi WiFi enabled so that the kegbot-server is accessible anywhere in the house.
Steps we had no prolems with:
Flashing the arduino. There are many articles on how to do this on all platforms using the very simple Arduino IDE. Basically you download the IDE, clone the kegboard repo off of github, open the .ico file in the IDE, make sure it recognizes your arduino (which is connected to your computer, not your Pi, via USB), and then hit the upload button. Voila, you have a kegboard.
Getting the kegberry image onto the Pi and then pinging kegbot-server. Download the image and then google the best way to burn it onto your Pi’s SD card from whatever OS you are using. I used the venerable
ddcommand on OSX. Also, after booting the image for the first time I ran the
raspi-configcommand to change the Pi’s locale and a few other settings. To learn your Pi’s IP address on the LAN check the DHCP client list on your router.
Testing the functionality of the flowmeters. The Adafruit listing has a link to an Arduino sketch that displays the flowmeters tick counts on the serial monitor. I flashed the sketch onto the Arduino and then used it to test both flowmeters.
Once we had all this software loaded we plugged the Arduino into the Pi and pinged the Pi. Immediately we noticed two problems.
Problem 1 - Log Shows API Key Error
If you use the 2.1.1 image and you check the log portion of the admin panel in
the web interface you will see
NoAuthTokenError: The parameter "api_key" is
required. This one stumped me for a while, but I eventually found a post
on the kegbot forum that went over the solution. You need to edit the file
/home/kegberry/.kegbot/pycore-flags.txt so that it looks like this:
--api_url=http://localhost/api --api_key=<my secret api key here>
When you first open the file (SSH into the Pi and then use nano/emacs/vim) you will see that there is an error message printed erroneously in the middle of this file. Delete the error message and move the API key that has been pushed to the end of the file back into its proper place.
Problem 2 - Controller Not Found
Kegbot-server would not connect with the kegboard (i.e. the controller). Our solution to this problem was simply to take kegbot-server out of debugging mode. I haven’t exhaustively tested this solution but it worked twice for us. This may seem like an obvious solution, but I kept the server in debug mode because I figured that, ya know, debug mode would help me debug my controller connectivity problem! Nowhere in the docs (that I am aware of) does it mention this crucial fact!
Debugging Technique: If this does not fix your controller connectivity
problem I suggest your next step to be running the kegboard-monitor program.
Run the command
./python kegboard-monitor.py from
/home/kegberry/kegbot-pycore.venv/bin. If your board is connected you will
get a short message showing where in
/dev your board is, and then the program
will listen for messages coming from the kegboard. If you plug in a flowmeter
to the kegboard and then gently blow through it you should see messages flood
your screen. This is a great way to test your kegboard to Pi communication!
We got excited once the controller was found and immediately plugged our flowmeters in, hopped on the web interface and used it to add a flowmeter, tap and keg. We were then immediately dissapointed to see that kegbot-server was not registering pours.
Problem 3 - Pours not Registering
This was the problem that I found most frustrating. Maybe we overlooked
something in the docs…but I looked pretty hard and never read about this. We
knew that the kegboard was both connected to the Pi and that it was sending
pour signals (from the kegboard-monitor.py output). So why wasn’t kegbot-server
getting the message?!?!? Eventually I was looking through the Redis logs on
the Pi (I forget which ones…sorry) and I saw a clue that told me the
port name of the flowmeter is crucial. When you add a flowmeter in the
web interface via
admin --> controllers --> Flow Meters --> Add Flow Meter
you must name your flow meters port names ‘flow0’ and ‘flow1’, otherwise
kegbot-server will not register pours. I don’t understand how this detail is
not listed in bold font in the docs…
That concludes my list of gaping holes in the kegbot/kegberry documentation. I hope this was helpful to some other kegbot hobbyist out there!