-
Notifications
You must be signed in to change notification settings - Fork 21
Home
Sensors attached to the keg feed information about the current state of the beer back to the iPad, where that data is processed and snazzily displayed. An RFID reader attached to the system allows users to ‘swipe in’ to the KegBot and keep track of how much beer they’ve had, as well as rate the beer currently in the keg. The iPad also displays general information about the beer currently on tap.
Let’s start from the bottom, closest to the beer. At the lowest level, we have a LM335A analog temperature sensor, ID-12 RFID reader, and a SwissFlow SF800 flow sensor attached to an Arduino microcontroller. The temperature sensor is a an analog sensor, though we’ll probably go with a digital one-wire sensor in the future (hey, we only had 24 hours to build this thing!). We mounted the temperature sensor on the side of the keg towards the bottom; ideally we would know the temperature of the beer in the keg, but since it’s not practical to get a temperature sensor inside the keg, this was the next best thing. The flow sensor sends the Arduino an electrical pulse every time ~.164mL passes through it. By counting the pulses we can calculate the volume and flow rate of the beer passing through the tube. The RFID reader sends distinct codes to the Arduino every time a card comes within range. While many kegbots attach the RFID reader directly to the host computer, we had to attach the RFID reader to the Arduino since we only had a single serial connection going to the iPad (more on that later). We used Mikal Hart’s NewSoftSerial library to instantiate an interrupt-driven serial port using another GPIO pin that receives data from the RFID reader. The Arduino is running a modified version of KegBot.org’s Arduino firmware that handles the packetization of all the sensor data. We had to add support for the ID-12 RFID reader as well as the analog temperature sensor, but other than that, the Kegboard code is unmodified.
To use the iPad’s dock connector for serial communication one must either be a part of Apple’s MFI (Made for iPhone/iPod/iPad) program or jailbreak the iPad. We opted to jailbreak the iPad. Note that while jailbreaking the iPad can usually be reversed by restoring the device from iTunes, Apple’s official stance is that it “can violate the warranty and can cause the [device] to become unstable and not work reliably”. So proceed at your own risk. After the iPad is jailbroken, the serial port in the iPad’s 30 pin dock connector can be opened just like any POSIX serial port:
int fileDescriptor = open(/dev/tty.iap, O_RDWR | O_NOCTTY | O_NONBLOCK);
There is one caveat here: any program that will access the serial port must be in /Applications on the iPad’s file system. It took us a while to figure this one out. This means you cannot install your application from XCode and expect them to immediately work. You must first move it to /Applications using ssh. We opted to send new builds directly to the iPad using scp. This turned out to be a great setup, because we could program the iPad without disconnecting it from the Arduino.
scp -r KegBot/build/Debug-iphoneos/KegBot.app root@[IP ADDRESS OF IPAD]:/Applications
Be especially careful when making connections to the iPad; make sure to check the pinout of the connector that you are using several times. We used a PodBreakout v1.4 board which had a different pinout than other versions of the same PodBreakout board.
The iPad software is the center of Yelp’s KegBot. Under the hood, we built a parser that interprets the input from the Arduino, processes that stream, and gives the important data to the view controllers handling the UI. Currently we use CoreData to store information about the beer and users, though in the future we’d like to move this data to an independent backend so we can support multiple KegBots in different locations.