Introduction: The Drinkinator - the Portable Party Bartender!

About: A beginners guide to raspberry pi and Arduino development by beginners.

Some months ago I came up with an idea, which was to build a rocket ship simulator for my friends kids and make it cloneable for each of their families. We are all programers, but no hardware guys.

Some planning and I realized I know nothing about hardware, halting a great idea. The arduino I bought sat and went nowhere.Then someone joked I should build an automated bar. After a little research, I found two amazing projects, the Inebriator and bar2d2, but got stumped on approaching hardware and development didn't start. Motors, voltages, and some fundamentals were needed.

Then I stumbled onto http://learn.robotgeek.com/projects/70-shotbot-project.html and lightbulbs went off! Their project was simple, but it showed how to control pumps via logic. From there I thought I could control it from a raspberry pi with a nice interface.

I ordered a boatload of parts, and then on a whim bought some LEDs.

Before proceeding, take the time to read the tutorials on this site:

http://learn.robotgeek.com/getting-started/32-geekduino/56-geekduino-getting-started-guide.html

Seeing the guides, it is easy to understand why I leaned so heavily on this product set, info was in one place. That got me from 0 to 60 in a couple days.

I also found Jeremy Blum's
Exploring Arduino: Tools and Techniques for Engineering Wizardry extremely helpful

Customizing or building on a smaller scale
The beauty of the barmanager library I created is that it allows you to scale up or down the pump number very easily. If you want to start with 4 pumps, go ahead! The customization section of this instructable will walk you through how to change this from the default build of 12 pumps.

Step 1: Be Safe

As with anything alcohol related, you bare the responsibility for your own actions and the actions of your guests.

  1. Grab car keys, safe serve, and be responsible.
  2. Don't drink and drive, make sure your guests don't, and make sure you don't over serve. Consider adding rfid and monitor your guests drinking!
  3. The author(s) of this article take no responsibility , certainly assumes none, and offer this information to inspire inventors only.

Step 2: The Hardware List

Disclaimer

I'm not employed by, associated with, or endorsing any vendor or products. With that said, the RobotGeek products enabled a quick build to happen with no electronics experience.

Links to products are found here http://learn.robotgeek.com/projects/70-shotbot-project.html

These are the products I used to construct each part of the Drinkinator.

Pump Electronics - aka Drinkzilla

  • 12 pumps (no powercord)
  • 12 drink spouts
  • 2 large workbenches ( you don't need these)
  • Geekduino
  • Sensorshield
  • Sensor cables
  • 2 dc squid cables
  • 2 6v power cables
  • Arduino mount
  • 1 white funnel (bpa free!)
  • The pump kits came with silicone tubing but I bought a tube pack so I can replace them later, as they wear down.
  • Power bar


Interface - Drinkinator

  • Raspberry pi 2
  • 16mb sdhc card
  • Raspberry official touchscreen
  • Power adapter 5v
  • Usb cable
  • Logitec Wireless keyboard/mouse. I use this for programming the pi and hide it while the Drinkinator is in use.



Lightshow - Lightzilla

  • Neopixel ring -16 size
  • Neopixel jewel - 7size
  • 20 or 22 gauge wiring(smaller wire was better for neopixels)
  • I used an arduino mega that was gathering dust, but that is overkill. Use a nano!


Woodframe
I used 2x2" wood posts and used compressed particle board for bottom, middle and cover

  • hinges
  • 3" wood screws
  • white primer
  • black paint
  • wire guides


Drink Tray

  • Glass ash tray
  • Silicone sealant
  • Left over wood from posts and horizontal pieces
  • Wood glue
  • small nails to affix workbench to frame (optional)


Tools

  • Knife
  • Wire stripper
  • Drill
  • Hammer
  • Table and Saw

Step 3: Software List

Pi OS/Programs

  • Jessie Debian OS
  • Kivy
  • Pyserial
  • Arduino IDE 1.0.6! Geekduino requires this.

Arduino Library

  • Adafruit neopixel library - which I bastardized it's light example to control jewel and ring independently but connected.


Development - Arduino/geekduino programs

  • I started with my netbook/windows to program the arduino and test the pumps in the arduino IDE.


Development - Pi

  • When I started the interface for the raspberry pi, I literally used nano on the pi to create the interface.


Download the software packages found here
NOT AVAILABLE AT THIS TIME - I have concerns that a business might be using my code and making money off this. I will write a small tutorial section of code to help up and coming inventors, but not a full product to help deter those companies.

Step 4: Writing Your Own Interfaces - How to Communicate Between Pi and Geekduino

If you want the source code to the GEEKDUINO (ARDUINO) side, I've included latest version here

https://github.com/nextprojectawesome/testprojects...

The way an Arduino works is it just loops infinitely.

  • This is cool because it can go forever
  • You can write variables to do things
  • You can write code that does things based on input/output
  • That input can be in the form of a serial connection from an Arduino
  • When using serial connection it has to be available and the buffer should be filled if you want to do things with the text sent. In the loop code of the Drinkinator I simply wrote
if(Serial.available()) { handleIncomingRecipe(Serial.readStringUntil('\n')); //Get Entire Line }

This basically says "when there's a serial connection, read from the buffer until an endline character found and pass it off to a function called 'handleIncomingRecipe'"

Then I wrote a simple parser in questionable code that simply looks for delimiters, which I set as

  • Colon for command
  • Pipe for instruction
  • Plus for end of instruction

So RECIPE:1|30|4000+2|50|4000+3|20|4000 indicates

  • pump 1, serve 30% of 4000 (the glass size)
  • then next command is serve pump 2, 50% of glass size 4000
  • and then pump 3 serve 20% of 4000glass size

The idea was to have the pi control glass size, recipes, and so on.

  • The arduino doesn't care what's on each pump, it just controls the pumps
  • Also the PI doesn't know anything about pins, etc, it just knows the Arduino it's talking about has X number of pumps, so the instruction the Arduino gets says PUMP 1, and the code GetPump translates that to which pin

So the logic is not crazy difficult. Arduinos are powerful tools, but this code was tangibly easier than the PI side of things.

Raspberry Pi Interface to the Arduino

You could write a simple interface using Python, or you can take it next level with the Kivy language. Below I`ll show you the important lines of code needed to interface with a PI using Kivy.
First and foremost, you need to initialize the Arduino in your main function.

if __name__ == '__main__':

global arduino

try:

print "\nDRINKINATOR: Will try to connect\n"

arduino = serial.Serial('/dev/ttyUSB0',9600)

print "DRINKINATOR: Arduino connection succeeded\n"

except:

print "Failed to connect"

exit()
Drinkinator().run()
arduino.close()

If startup fails because it can`t connect to the arduino, it might be you`re using a different USB connection. This means either trial and error, or making a slight change to the code for

serial.Serial('/dev/ttyUSB0',9600)

where ttyUSB0 is the entity you`re initializing. You can figure out the proper port name by following the troubleshooting steps here
http://www.seeedstudio.com/recipe/166-basic-pi-lt-...

Next, however your application builds the recipe to server, you must construct a single command string and send it to using the arduino.write statement.

arduino.write(serialString); #output to arduino!

Remember,the arduino expects a string in the format of:

RECIPE:1|30|4000+2|50|4000+3|20|4000+\n

Where it denotes PUMP number (this is not pin, if you have 6 pumps, it will be pump value 0-5 and in arduino code you map pump to pins). This is followed by percentage of glass to fill, and final number is time it takes to full glass. If you use the robot geek pumps the accuracy is there, this method works 100% of the time unless your glasses differ in size or you haven`t taken the time to adjust the numbers for the size of your glasses.

A Good App Will Have Three Components

  1. Editable files for recipes and configuration (i.e. glass size)
  2. An interface
  3. A bar manager program that changes recipes based on the ingredients available

Recipes

  • There are a lot of online apps and drink bibles out there. Find ones that you like.

Interface

  • Find a simple Kivy app and learn from it, then build one.

Configurable Items in the interface

  • Originally I had the glass size code at the arduino level, but I wanted to make the glasses definable in the app. I estimated that a double shotglass was typically 4000, a TALL shotglass was 6000 and Tumbler about 22500, but this will really depend on your own glasses. Make sure to define this when you pass the command to the arduino.

Step 5: Breaking It Down

Compared to other instructables, this is a small project, but if this is your first, it is a big undertaking.

Break it into problems

  1. geekduino, pumps, and programming. Get the Drinkzilla program up and running. Use the serial monitor in the IDE to send test commands. Once electronics work , build a frame/case.
  2. Build a case.
  3. Pi, touchscreen - get it running
  4. Kivy - get the demo program running
  5. Kivy - get the Drinkinator program running.
  6. Integration test (with water!)
  7. Once everything works, tackle the neopixel project. We deliberately used a second arduino to keep this simple. We did start to add serial hooks, but in the end decided to make it standalone and just run patterns all night
  8. Beta test
  9. Usage
  10. Storage and cleaning


A note about this step's Image

We drew out everything to start, had a solid design, but we were flexible enough to simplify and adapt as we learned new things. While the final outcome wasn't the exact design, it was pretty darn close! In fact we had build the framework to support the utilities shown in the above diagram, now we just need to build fancy interfaces to do the work, but that wasn't necessary, so we didn't try to do it since text editing the resource files is trivial for now. In other words, don't take on too much, and keep it simple until you have all the pieces working!

Step 6: Pump Assembly and Geekduino Control

So your shipment has arrived, but then you have a big shocker, you have to assemble the pumps!

Go to the documentation and read the guide. It is very graphical

  1. Build all the pumps
  2. Build all the spouts
  3. Put the pumps /spouts on a workbenchboard like in shotbot video.
  4. Put in tubing
  5. Label the pumps 0-11
  6. Using the Drinkzilla file as a guide, plug each pump into the appropriate pin. Note analog pin 0-7 corresponds to digital 14-21, as per http://learn.robotgeek.com/2-uncategorised/183-getting-started-with-robotgeek-wiring.html.
  7. Plug the squid cables into each pump and plug the power cables into the squids.
  8. Attach geekduino to sensor shield
  9. Using arduino IDE upload the drinkzilla sketch to the geekduino

Step 7: Testing Pump Hardware

Testing Rig

  • Put pump/spout/workbench on a box, similar to shotbot video. In my case I did a quick rig that took about an hour to build. What I learned was the pump and spout must be above liquid source!!!
  • Get a large drink container , fill it with water, taking care to put input tubes from pump into it. Under the spouts, put another large container to catch the output.


Testing just the pump

  • Press red button on top of each pump and prime the tubes. If it fails you may have made a mistake in wiring or input tube.


Testing pump with geekduino
To test, plug geekduino into your computer and upload the Drinkzilla code.

In the Arduino IDE serial monitor (the button on the top right of the screen), try these commands, but make sure to change the dropdown to NEWLINE in the serial monitor.

to test pump 0-4 send
RECIPE:0|20|4000+1|20|4000+2|20|4000+3|20|4000+4|20|4000+

pump 5-9 Send
RECIPE:5|20|4000+6|20|4000+7|20|4000+8|20|4000+9|20|4000+

pump 10-11 Send
RECIPE:10|20|4000+11|20|4000+

If a pump fails, check wiring, then check you used right pins. If a pump runs for no reason, it is the same cause. I chose the pins I did because they are not reserved for other things by the geekduino.

A note about this step's gallery

Prototyping is an important part of development. In this case I went "all in" with the hardware and when I built a case I was lucky I tested it early before spending significant amounts of time developing it. The first rig I had was very compact and you can see I had the source and the destination cups below the pump. I thought the pumps were leaky because liquid still flowed even when the pumps weren't running. Then I rewatched that robot geek video and realized the spouts had to be at same height. As a result, I moved on to Mark II and had a bigger, but way more awesome rig with more room to do cooler stuff. Even better, I didn't take too much of a hit weight wise.

Step 8: Case Assembly

After integration the pumps, tackle building the case.

Make sure spouts are same level as the pumps. In my case the liquor bottles are placed in the area below the pumps.

Build Walkthrough
Part 1:
https://youtu.be/dDy7FfWGMSA
Part 2:
https://youtu.be/H9T0ltZ1mLA

My case is light and transports very easily

Step 9: Preparing the Raspberry Pi2 and Touchscreen

Not being a linux guy, this was painful. Debian is like taking a trip back to windows 3.1.

Some important points

  • Setup Jessie to boot to command line. This solves the ctrl-c not working in kivy. Launching a kivy app from within the os gui's cli/terminal doesn't work. It must be a boot to command line!
  • Ctrl -c to exit a kivy app


Videos of setup
Pi - https://youtu.be/xQ5f65VZEPY
Part 2 - https://youtu.be/AouPnWxBNek
Part 3 - https://youtu.be/2TWPYCQd1BQ

The Drinkinator code must be placed in a folder on the Pi, and ran via python "python main.py". If you just want to test the interface and don't have the hardware ready yet, just use "python main.py debug". It disables the serial hooks and enables more robust log lines.

Step 10: Setting Up the Drinkinator Program on the Raspberry Pi

The entire Drinkinator folder code must be placed in a folder on the Pi, and ran via python "python main.py".

If you just want to test interface and don't have the hardware ready yet, just use "python main.py debug". It disables the serial hooks and enables more robust log lines.

Step 11: Integration Testing

Using the same test rig you used to test the Geekduino, run a usb cable to the Geekduino from the raspberry pi.

Run "python main.py"

If it fails, your usb port might be different. Correct the line

serial.Serial('/dev/ttyUSB0',9600)
in main.py

You can figure out the proper port name by following the troubleshooting steps here
http://www.seeedstudio.com/recipe/166-basic-pi-lt-gt-arduino-communication-over-usb.html

Once loaded

  1. Pick a size
  2. Pick a drink
  3. Click 'Serve'

The line to the right of the recipes is a scrollbar. There are 21 recipes at the time of this writing.

Step 12: Drinktray Light Show

Neopixel Setup
Wire the neopixel jewel and ring as pictured.

We actually took one of the sensor wires and repurposed it so we didn't have to solder it to the Arduino. We liked the idea that pieces are modular and easily removed.

Install the Lightzilla program in this second Arduino and test the program. It takes a few seconds but it should start running infinite patterns.

Drink Tray
We took a board and used a drill attachment to make a big round hole about 1/4" larger than the neopixel ring.

We cut a second board the same size and glued it below the board with the hole. This gave us a space for the neopixel to sit. We then primed and painted everything.

We then drilled a large hole in the middle of this resting place and threaded the neopixel wire through it to an Arduino sitting on the underside of the tray. We then used super adhesive tabs to secure the ash tray to the wood then used silicone around the tray to seal it! This Arduino will have its own power cord to power the board and neopixels. Since there is only two neopixels there should be a sufficient amount of power without needing a separate power for the neopixels.

Step 13: Setup for Real Use

Look at inventory.txt

Place the appropriate liquors in the appropriately numbered bottles. Place bottles under the pumps. I actually wrote the numbers on the underside by the tubes to make it easy. Similarly I had a printed version of inventory.txt in case I needed to do refills.

I placed juices in a side tupperware filled with ice to keep them chilled. See the virtual walkaround to see what it should look like:
http://youtu.be/n5kO0W1mFEg

  • Plug in geekduino (power)
  • Prime pumps (see note below)
  • Attach geekduino to Pi via usb
  • Start drinkinator program
  • Start serving!



Priming the Pumps
This is a fun activity. Basically you use the manual pump buttons and free pour several shots. If you know your recipes, it can take as little as four shots to prime everything!

In my case I use the following to create four shots manually to prime the pumps

  • Polar bear
  • Blue lagoon
  • Butterscotch
  • Walk on the beach (passion)
  • Little piece of heaven (?)

Step 14: Customizing

Glass sizes
In Drinkinator's main.py code on pi, update drinksize amounts to correspond to your glass sizes. Eventually I will create a "glasssize.txt" to make this easy. The current glass sizes are essentially:

  • Glass=2oz shotglass
  • Tall=3oz shotglass
  • Glass =tumbler glass

I believe 3000=1oz and you will want to calculate to about 80% of that.

Inventory and Recipes
The bar manager library was a simple / quick program that does three key things:

  1. Inventory.txt says what liquids are on what pump. When barmanager loads the recipes it creates a menu consisting of all recipes that have ingredients found in inventory.txt. This menu is used to generate the buttons on the touchscreen.
  2. The bar manager loads recipes specified in drinkindex.txt. The actual recipes are found in the recipe folder. To add a recipe, create a text file in same format as the others, then create a reference in the drinkindex.txt
  3. If you have a good recipe, convert amounts to percentages of the recipe. The bar manager will convert it to amounts when it has to look at size if glass it has to fill.


The beauty of the barmanager library is that it allows you to scale up or down the pump number very easily.

Changing number of Pumps

Inventory.txt indicates the number of pumps and what ingredients are on what pump. Adding or removing these lines tells the PI what's available. You then need to update drinkzilla program to recognize (or remove) what pin numbers your new/removed pumps are on. Once this is done, just restart the Drinkinator program/upload the new arduino program and the barmanager will figure out everything.

A note about customization
I fully intend to build in utilities into the kivy program to manage these so the text files are never modified manually.

Step 15: Maintenance

So at the time of writing this, I couldn't find any manufacturer recommendations for this. Please give feedback if you have some good ideas!

My thinking in this is that liquor and sugary liquids like rum, blue caracao will stain and cause blockage.

My solution is to first remove liquor bottles. Then empty the tubes as much as possible by serving 3 or 4 shots. In my case I served polar bear, piece of heaven, butterscotch, blue lagoon and this pretty much emptied all the tubes. In some cases I had to use the red manual button to finish the job. No wasted alcohol, just strong last shots :)

Then, placing a drink container with hot water, I ran each pump for 30 seconds, draining the output to the sink using funnel and a large tube.

  • Remove funnel, remove tubes, wash all.
  • Run pumps with a cloth under each pump to drain remaining liquid.
  • Seal tubes and funnel in bag until next use when finally dry.

Step 16: Drinks and Ingredients Notes

Canadians get peppermint schnapps, creme de menthe and creme de cocoa in clear liquids. They look/taste different then 'AfterEights' and actually should be served very cool by shaking with ice, hence the "polar bear" name.

Looking back I noticed some recipes may have been overwritten. I plan on going and fixing them. I will likely make a customdrinkindex.txt so updates don't overwrite any user added recipes. That should be done by end of year.

Step 17: Visual Touches for Fun

Step 18: Taking the Drinkinator to the Next Level

Check out the Music Light Effects I've added to the Drinkinator:

Drinkinator V2.5 Visual - See other videos on youtube channel for the different music modes