BrewBox | Modular Cocktail Maker

by GordonCedric in Circuits > Raspberry Pi

364 Views, 3 Favorites, 0 Comments

BrewBox | Modular Cocktail Maker

Instructables Poster.png

Hello everyone!

Today I'm going to be explaining how I built my personal cocktail machine that can be easily scaled to anyone's needs.
In my version I only use 2 containers for drinks, but if you want to make it have more (for example 4 containers) then do also follow along as I will be giving instructions for this aswell.

Do note if you want multiple containers, make sure that you not only get an extra pump but also extra temperature sensor + ultrasonic sensor.

Supplies

- 1x Raspberry Pi
- 2x 12v pumps (or more)
- 1x 12v power supply
- 1x 1602A 16x2 LCD display
- 1x MCP3008
- 2x Transistor (1 per water pump)
- 2x DS18B20
- 2x HY-SRF05
- 1x Force sensing resistor (FSR)
- 2x 47kΩ Resistor
- 3x 2.2kΩ Resistor
- 3x 220kΩ Resistor
- 3x 12mm buttons (for on the front of the case, I had 12v 12mm buttons which light up in red and I just powered them by the 12v power supply. However this is completely optional, regular buttons work too :) )
- 1x 74HC595 Shiftregister
- 2x Breadboards

Assembly of Circuit

Fritzing_schem.png
IMG_4515.jpg

So for the first step, I would recommend building the circuit
In my case I used 2 breadboards since this gave me alot more room to build everything.
Do note on the electric scheme you can see on the top US-100CSC, these are the HY-SRF05 ultrasonic sensors.
For some reason Fritzing displays this different.

You can also see what it would look like when this is all assembled.
In my picture you don't see the front buttons yet since they hadn't arrived then.
However that doesn't really matter because I had small buttons on the farthest breadboard.

In my experience I would also recommend putting the buttons and Shiftregister (for the LCD) on the same breadboard.
This makes putting it in the case alot easier.

Setting Up the Pi

Now that you have build the circuit, we have to set some things up first.
Since we are going to be running everything on the Raspberry Pi, we need to set up the dependencies, etc...

For the advanced readers, here's the list of all the dependencies/packages:

Raspbian packages:

  • Apache 2
  • MariaDB

Raspi interfaces:

  • 1-wire
  • I2C

Pip packages:

  • Flask-CORS
  • Flask-SocketIO
  • Mysql-connector-python
  • gevent
  • gevent-websocket

Pi setup:

So, to install these packages we first have to do a global update/upgrade.
To do this, you have to run following commands:

sudo apt update
 sudo apt upgrade

So now that that's updated, we will also have to enable the correct interfaces, to do this, just run:

sudo raspi-config 

This will open a new window, here you navigate to Interfaces and enable 1-wire and I2C.

With the interfaces enabled, we can proceed to install Apache2, to do this simply run:

sudo apt install apache2 -y

When Apache2 is installed, you can do the same for our MariaDB:

apt install mariadb-server mariadb-client -y

It will ask you to do the secure install, simply follow the steps on screen to set everything up.
Make sure you remember your credentials since you will need them to set up the database.

Now that your MariaDB is set up, it's time to clone the github repository.
You can do this by simply typing:

git clone https://github.com/GordonCedric/BrewBox

This will clone the entire project on your Pi.
The last step needed for the environment is telling apache2 where the frontend will be.

Simply go to /etc/apache2/sites-available and edit the 000-default.conf file.
On the line DocumentRoot, fill in the path where you cloned the github directory and in that directory you navigate to Code/Frontend
This will make the website always show up when the Pi boots.

Pip Packages:

Now that our Pi is all ready to use, we also need some packages for Python.
These can be easily installed by using following commands:

pip3 install flask-cors<br>pip3 install flask-socketio<br>pip3 install mysql-connector-python<br>pip3 install gevent<br>pip3 install gevent-websocket

Database

EERD-schema.png

In the image above you can find the EER scheme.

To get the database, you can simply go in the cloned repository and navigate to Code/database-export.
The database.sql can be imported using MySQL Workbench or PHPMyAdmin

Unfortunately some of it is in Dutch (I started this project in dutch, but then switched over to english, my apologies for this).

However below you will find a handy-dandy cheatsheet to see what each table is and what the values are:

Dranken: This table is for all the types of drinks that will be in the cocktail machine. Aswell as in which container they're stored.

  • id: This is the ID of the liquid
  • naam: This is the name of the liquid, which is also showed in the system
  • container: This is the container in which the liquid is being held. 0 = Not active right now

------------------------------------------------

dranken_has_cocktails: This is the table that stores which drinks are in which cocktails aswell as in what percentage they should be dispensed. This is shown by the foreign keys.

------------------------------------------------

Cocktails: Fairly straight forward, these are the cocktails that are in the system.

  • id: The ID of the cocktail
  • name: The name shown in the system for the cocktail.

------------------------------------------------

geschiedenis: This is the history of each dispensed cocktail.

  • id: ID of each dispensed cocktail
  • timestamp: The timestamp of when this cocktail was dispensed
  • cocktails_id: Foreign key for which cocktail was dispensed.

------------------------------------------------

historiekDevices: This is the history of sensordata, anything that was meassured, will be saved here.

  • id: The identifier of the row
  • devices_id: Foreign key to which sensor/device meassured it
  • value: The value of what was meassured
  • timestamp: When it was meassured

-------------------------------------------------

devices: These are all the devices/sensors connected. Very important: This has to be 100% correct, if you forget to add in a sensor here, the system won't work

  • id: The device ID, write this down when adding your sensors since you will need this later.
  • type_id: The type of device/sensor, this is a foreign key to deviceTypes
  • name: The name of the device/sensor

-------------------------------------------------

deviceTypes: These are the type of devices, I would recommend not changing anything in here since it's all set up for what you need.

Understanding the Code

EnCIn03.png

Since you have now set everything up, it's time the fun part: CODE

Firstly it's also important to know, my drink containers are 17cm high with a capacity of 2.5L.
If you have a different container, make sure you go in the ProjectKlasse.py to line 93 (function get_volumes) and change the 17 for each sensor to the max distance that your ultrasonic sensor can read.
Also below that you can also change the max capacity of your container.


The system is built very modular, this means you can pretty much expand to as many pumps as you want.
To achieve this, I made an extremely easy class named ProjectKlasse.py
You can find this in the Code/Backend/helpers.

To add a new "container" (temperature sensor, ultrasonic sensor and pump) simply follow these steps:

  1. In the database in the table devices, add all the components.
  2. In ProjectKlasse.py simply go in the init function and add a new pump with it's GPIO pin to the transistor
  3. Do the same thing for the temperature sensor and ultrasonic sensor. For the ultrasonic sensor (class name Ultrasone) you first have to give the GPIO pin of the trig and then the echo connections.
  4. in the setup function you also have to run the setup for the ultrasonic sensors, to do this, simply do self.__sensorname.setup()
  5. All you have to do now, is also add the sensors to the functions that retrieve the temperature/volumes. This can be done by going to get_temperatures(self) and adding in a new line calling the sensors.get_temperature and also returning this value.
  6. For the ultrasonic sensor simply copy one of the sensors and change the sensor names.
  7. Lastly, add in the dispense_drink function your pump by adding an elif(pump == 3) and saying that pump3 has to go active and stop with a time.sleep(pumptime)

Making It Look Cool 😎

IMG_4752.jpg
IMG_4753.jpg

With all the electronics done, we can now start by making the case.
The side panels are basically lasercut, you can find the lasercut files below.
It's only 1 side, but you can just lasercut it and then mirror it in Illustrator.

I would recommend making the top part of the machine a bit higher, since now my components are crammed inside, and as mentioned before, getting it out (without damaging anything) is nearly impossible.

That way you have 2 evenly sized panels (unlike me who made a small mistake while making the other side).

The front panel lasercutting files are also below.

To assemble this all I used wood glue and let it dry overnight.
I would recommend putting some nails in with a nailgun for extra support.

Putting in All the Components

IMG_4794.jpg
IMG_4795.jpg
IMG_4796.jpg

With the entire case built, it's time to put in the components.
This is where it all went wrong for me, since I didn't meassure the size of my circuit.

However, I was able to get everything in and as long as I don't move it too often, I feel like it should stay fine.