The noble quest – to use the power of your mind to pour a beer.
When the incorrigible David Burton (Head of Innovation at Redweb) first mentioned his master plan, it was too much of a temptation to resist. So I didn’t. (This blog post would have been a bit of a non-starter otherwise.)
Once we’d discussed the idea in more detail, all of the pieces fell into place – the existence of the Redweb Wi-Fi Beta real ale (brewed on the premises by Mr Burton and served up in their swanky “loading bar” area), the availability of brainwave sensing products for comparatively little cash money and the fact that I was kicking about for an iOS project to ease myself back into such things dovetailed neatly together. As such, we began to research the various options for putting such a system together.
Whilst we’d originally planned on using some form of stepper motor or servo to control the spigot on the ale keg via an Arduino or Raspberry Pi (hence the name “Spigotron”), this was soon abandoned once we’d discovered the existence of solenoid valves – a solenoid valve effectively being a very fast acting valve controlled by an electromagnet. As such, a food grade, normally closed (hence only permitting flow when power was supplied) solenoid valve seemed the perfect means of controlling the flow of beer.
Our initial list of components was therefore as follows:
- NeuroSky MindWave Mobile.
- iPad and accompanying app.
- Arduino with Ethernet shield.
- >12v normally closed solenoid valve.
- Some transistors (never before have so many given so much for so few), a diode and some wires. And 9v batteries. And stuff.
We eventually supplemented this with a cheap Wi-Fi router, so that we could create a closed network rather than attempting to piggy-back off the existing infrastructure. (The Wi-Fi network available quite understandably didn’t have a router we could direct connect the Arduino’s Ethernet shield into, which thwarted our initial plans.)
Armed with these components, the plan was as follows:
- Use the MindWave Mobile headset to sense the attention level of the test subject. This would transmit the data via Bluetooth to the…
- iPad app responsible for handling the data supplied via the NeuroSky SDK and for providing a pretty UI. After massaging the data, this would then send an HTTP request to the…
- Arduino with Ethernet shield. This was direct connected to the Wi-Fi router the iPad was using and would check (using a tweaked version of the Ethernet library code sample) whether the incoming GET request was telling it pour or stop pouring. It would then set the control pin that was wired to the transistor’s base pin accordingly, hence activating the solenoid valve and enabling the flow of beer as required.
The iOS app itself came together pretty quickly (although the fact that the SDK documentation and sample code was out of date didn’t help – nice job NeuroSky) and I soon had a basic version of the app up and running. This initial version was universal (i.e.: iPhone & iPad), but the opportunities afforded by the screen real estate of the iPad proved too hard to resist, so the minimal iPhone version was culled along the way. The basic app was later supplemented with artwork from David to form the final app. This proved to be the easy part.
Sadly, whilst the basic circuit design we cribbed off the internet to control the solenoid should in theory have worked, it wasn’t all plain sailing – in the main due to the fact that our combined knowledge of electronics and the inner workings of solenoid valves was close to zero. (At the very least, I now know a lot more about solenoid valves than is ever likely to be useful in later life.) As such, we spent a fair amount of time during one of the HACKBMTH days discovering exciting things about both electronics and barometric pressure. Thankfully we had some assistance (in the form of Mark Benson) to help us along the way, so we were as least confident that we were heading in the right direction. (I’m intentionally not mentioning the stack of coffee tables that were taped together to get the test keg of water sufficiently high off the ground to generate 0.2 bar. Health and safety was not a key factor that day.)
After re-grouping for additional diagnosis, it transpired that the transistor we were attempting to use to make/break the solenoid power circuit was woefully under-powered for the task and hence was beginning to heat up to the extent where it was melting the breadboard that housed the control circuit. Once again, we were thankfully rescued (this time by the exceedingly handy Ashley Flude) and we ordered some more sturdy transistors. (These ones were rated at 12v and had a nice chunky heatsink to dissipate the heat. Always handy.)
Once the new transistors arrived, it was then simply a matter of rebuilding the circuit and hooking everything up the multi-meter for testing. By a stroke of genius/sheer luck we were thankfully greeted with a voltage that was correctly switching between ~12v and ground – precisely what was required to drive the solenoid.
As such, we’re now in the position where we’re ready to connect everything up and test the system with real beer. (David has been busting some moves constructing a platform to put the keg on, but I’ve yet to see this in full effect.) The plan is to set everything up tomorrow afternoon for some VIP guests, so fingers crossed all goes well and flooding is kept to a respectable minimum.
In the meantime, you can check out a brief video of the iPad app in action (and the exciting array of reflections on the iPad screen) below.