SmartKegerator v2 Installation Guide

This project has been heavily modified to take advantage of the raspberry pi 2’s additional horsepower. If you are looking for the raspberry pi v1 code, look around version 62 in the repository. Version 70 and on are unlikely to work on the original pi, although I have not tried.

[Updated 10/4/2016: These instructions have been updated and now work with a clean raspbianPIXEL image]


Install a new copy of raspbian onto an sd card.

On your first boot, configure these:
Expand Filesystem
Boot to Desktop
Enable Camera
Configure keyboard (if not in UK) and timezone
Finish > Reboot

1) Update raspbian

sudo apt-get update
sudo apt-get upgrade
sudo rpi-update

2) Install requisites

sudo apt-get install qtcreator cmake libopencv-dev mplayer subversion qt4-dev-tools libqt4-dev libqt4-dev-bin qt4-qmake

3) Configure QtCreator

Launch QtCreator from start menu > Programming > QT Creator

Once in QT Creator:
Tools > Options > Build & Run > Qt Versions > Add > navigate to or paste: /usr/bin/qmake-qt4
Tools > Options > Build & Run > Compilers > Add > pick GCC
Then set compiler path : /usr/bin/arm-linux-gnueabihf-gcc-4.9
Click OK

Qt Creator seems to think that we are going to deploy on a remote target, to fix this :
Help > About Plugins
Uncheck Device Support > Remote Linux
Click Close and reopen Qt Creator

Tools > Options > Build & Run > Kits > Desktop-Qt4 4.8.6 (qt4)
Compiler: GCC
Debugger : /usr/bin/gdb

4) Compile facial recognition libraries

cd ~
git clone
cd libfacerec
sudo cmake .
sudo make

5) Compile QWT

cd ~
mkdir qwt
cd qwt
svn co svn:// ./
sudo make
sudo make install
cd lib/
sudo cp * /usr/lib/

6) Compile WiringPi

cd ~
git clone git://
cd wiringPi/

7) Get SmartKegerator source

cd ~
mkdir qt
cd qt/
mkdir SmartKegerator
cd SmartKegerator/
svn co ./

8) Edit config files

sudo nano ~/qt/SmartKegerator/config.txt

Make sure all of the paths are correct for your system. If you’re using a fresh copy of raspbian and followed each step here, you shouldn’t need to edit anything.

9) Run it!

Open QTCreator and File > Open Project > /home/pi/qt/SmartKegerator/

Click Yes when it asks about environment settings.

Click the green arrow on the bottom-left to start building. The first build will take a while. If everything worked you should see the application open! If you get errors, try google or come back here and post a comment.

9) Disable the screen saver

sudo nano /etc/lightdm/lightdm.conf

scroll down until you see


Remove the starting ‘#’ from ‘#xserver-command=X” and add ” -s 0 -dpms” to the end so you have:

xserver-command=X -s 0 -dpms

ctrl-x, y, enter to save

To use the Mimo-720S

See this post about configuring the touchscreen and kernel

Smart Kegerator

Discovery Channel Canada’s “Daily Planet” segment: (very similar to the walkthrough above)

Update 7/31/2015:

New installation guide has been posted here:


The purpose of this project was to allow my roommates and friends to be able to drink as much beer from the kegerator as they’d like, without guesstimating who owes what when it comes time to refill the kegs. The system uses two flow meters in the beer lines to detect when beer is poured, and once a pour has started, the raspi camera module turns on to run facial recognition (disabled when I shot this video) and charge the appropriate user for their beer. I wanted the system to be as passive as possible, requiring zero human interaction (no RFID cards, no selecting the user every time) but to record all pours and how much was poured. So far the system is running great, minus that accidental spill because my tap handles are too close together 🙂

Eventually I’d like to use weight sensors under each keg to get a better estimation of keg volume, and use a liquid probe thermometer to better estimate the temperature of the beer instead of the air. I’m also moving to a NOIR pi camera module after finding it had much better low light performance, and I’ll probably add some IR lamps to help illuminate the face for recognition when the lights are off. I also need to mount the camera a bit better, ideally higher and a littler further behind the tower, but the flex arm tripod worked great for this first implementation.

I’m also working on a new UI that will probably look something like this:

Mock up UI v2

Mock up UI v2

The source is currently avilable at but it’s certainly not finished or polished.

The UI is written in QT and C++, using python scripts for the gpio flow interrupts (the c++ interrupts seemed unreliable,but python’s implementation worked perfectly) and the C loldht script found on these forums to read the temp from the temp/humidity sensor.

I’ve made a quick and dirty fritzing image to illustrate the connections, but I’m not very good with frizing so I’ve included text as well.
On each flow meter, I connected the red to the pi’s 3.3v, black to ground, and the yellow pin to GPIO #23 and GPIO #24 for left and right sides respectively.
The temperature sensor, looking at the front of it (the side with the holes) the pins go left to right 1-4. Pin 1 to GPIO #17, so that I can turn it on/off by writing power out on pin 17. Pin 2 to GPIO #4. Pin 3 to ground. And lastly put a 4.7k ohm resistor between pins 1 and 2.

Rasperry pi

Mimo 720S display

Powered USB Hub

DHT22 temp/humidity sensor

Flow meters

Pi Camera module (NOIR seems ideal for low light)

100cm SPI cable (raspi camera cable)

Camera housing

Wide-angle lens

Techflex cable sleeve(I think it makes the raspi camera cable better looking)

For the gpio breakout:
10 pin ribbon cable

10 pin connectors

protoboard from radioshack

Mimo 720S solution –
Raspberry pi camera to opencv/facial recognition –

More info coming soon!

Kegerator Flow Meter Test

The first step along the road to getting the kegerator monitor up and running

Flow meter used available from adafruit:

Based on the code from:



#define lcdPin 6

SoftwareSerial LCD = SoftwareSerial(0, lcdPin);
// since the LCD does not send data back to the Arduino, we should only define the txPin
const int LCDdelay = 10; // conservative, 2 actually works

// which pin to use for reading the sensor? can use any pin!

// count how many pulses!
volatile uint16_t pulsesLeft = 0;
volatile uint16_t pulsesRight = 0;

volatile uint16_t lastPulses = 0;

// track the state of the pulse pin
volatile uint8_t lastFlowPinStateLeft;
volatile uint8_t lastFlowPinStateRight;

volatile int32_t lastFlowTimer = 0;

float litersPerTank = 18.9;
float pricePerTank = 78;

bool clearNextTick = true;

// Interrupt is called once a millisecond, looks for any pulses from the sensor!
uint8_t left = digitalRead(FLOWSENSORPINLEFT);
uint8_t right = digitalRead(FLOWSENSORPINRIGHT);

if (left != lastFlowPinStateLeft && left == HIGH) {
//low to high transition!

if (right != lastFlowPinStateRight && right == HIGH) {
//low to high transition!

lastFlowPinStateLeft = left;
lastFlowPinStateRight = right;

uint16_t pulses = pulsesLeft = pulsesRight;

if (pulses == lastPulses)
if (lastFlowTimer > -1)
if (lastPulses == 0)
clearNextTick = true;
lastFlowTimer = 0;

lastPulses = pulses;

void useInterrupt(boolean v)
if (v) {
// Timer0 is already used for millis() - we'll just interrupt somewhere
// in the middle and call the "Compare A" function above
OCR0A = 0xAF;
else {
// do not call the interrupt function COMPA anymore

void setup()
Serial.print("Flow sensor test!");

lastFlowPinStateLeft = digitalRead(FLOWSENSORPINLEFT);

lastFlowPinStateRight = digitalRead(FLOWSENSORPINRIGHT);


pinMode(lcdPin, OUTPUT);
lcdPosition(0, 0);
LCD.print("Starting Up");

lastFlowTimer = -1;
clearNextTick = true;
pulsesLeft = 0;
pulsesRight = 0;

void loop() // run over and over again
uint16_t pulses = pulsesLeft = pulsesRight;

if (clearNextTick)
clearNextTick = false;

if (pulses == 0)
if (lastPulses > 0)

lcdPosition(0, 4);
lcdPosition(1, 1);
LCD.print("Begin pouring!");
float liters = pulses;
liters /= 7.5;
liters /= 60.0;
liters /= 1.4; //weird const

float ounces = liters * 33.8;

float price = liters / litersPerTank * pricePerTank;

if (pulsesRight > 0)
lcdPosition(1, 0);
LCD.print("Oz: ");
lcdPosition(1, 9);
LCD.print(" $:");

// Reset
if (lastFlowTimer > 1000)
lastFlowTimer = -1;
clearNextTick = true;
pulsesLeft = 0;
pulsesRight = 0;


// wbp: goto with row & column
void lcdPosition(int row, int col) {
LCD.write(0xFE); //command flag
LCD.write((col + row * 64 + 128)); //position
void clearLCD(){
LCD.write(0xFE); //command flag
LCD.write(0x01); //clear command.