You like technology and party? This project is made for you!
In this tutorial we will create an automated cocktail machine with an graphic interface.
Everything controlled by the raspberry!
Step 2: Set up the raspberry piIn order to use the raspberry and the touchscreen, we will need a modified image of raspbian.
WIn32 disk imager:
After download install it.
Open it.
- 1/ you will see "device" in general the default is good (if you only have the sd card connected)
- 2/ Click on the blue icon folder and select the raspbian jessie image you have downloaded
- 3/ Click write and it's done.
You can now insert the card to the raspberry.
Putty:
It allow us to connect via SSH , open Putty (no need to install)
- Connect internet cable to the raspberry
- You need to find the ip of the raspberry 2 easy way:
- Connect to your box interface you will be able to see the device with the IP
- Connect the touchscreen and keyboard go to terminal then ifconfig
Now in Putty enter the ip adress will be something like 192.168.0.3 then enter
- it will ask to trust click yes (picture)
- login : pi password : raspberry
Leave the windows on the side we will come back here later
Step 3: Connecting the screenThe inconvenient of the screen is that it come already mount so when you plug it it will use all the pin of the rasp.
I have tested each pin to find out which one use the screen (check picture) to connect the screen it will be the same pin as raspberry once connected if you have install raspbian you will be able to use it.
Advice for the screen: the taskbar take some place , if you right click on it then panel setting => advanced => untick reserved space for taskbar.
Configure single click: Single click: IF you click to use only click on the screen on puty : cd /home/pi/.config => nano libfm.conf
Line 5 single_click = 0 change to single_click = 1
Step 4: Connecting the relay/RaspberryThe picture show for one water pump.
- water pump + = RELAY
- water pump - = Charger 12V
I used one charger 12V (cut the top) negative goes to the each pump (negative) and positive each channel of relay One charger is enough as only one pump will work at the time Repeat this for the 8 pump. To learn more about raspberry and relay amazing topic here.
Step 5: Code for the GUIWe are done for the material part (kind of).
Let's create the Graphic User interface:
You can now get back to putty once connected we gonna create our code on the desktop:
cd /home/pi/Desktop
Open a file:
nano drink.sh
To make sure file is executable
chmod +x drink.sh
And paste the code:
If you want to modify the code :
- "GPIO mode out" mean you turn on the pin (so the relay turn on)
- The Gpio = pin on the raspberry , but the physic pin are not the same of the system .
Check the picture.
So if you want to add or change a drink just modfiy the name in "menu boisson" and in the body of the code, you can see very easily each drink has a small section of code.
<p>#!/bin/bash<br>
while true; do
choice="$(zenity --width=400 --height=300 --list --column "" --title="Cocktail" \
"cocktail" \
"soft" \
"shooter" \
"cow boy")"
echo $choice
case "${choice}" in
"cocktail" )
while true; do
choice="$(zenity --width=400 --height=300 --list --column "" --title="test" \
"whisky coca" \
"wodka orange" \
"ricard eau" \
"tequila orange"\
"Gin orange")"
echo $choice
case "${choice}" in
"whisky coca" )
gpio mode 2 out
sleep 3
gpio mode 2 input \</p><p> gpio mode 0 out
sleep 4
gpio mode 0 input
</p><p> break
;;
"wodka orange" )
gpio mode 3 out
sleep 2
gpio mode 3 input \</p><p> gpio mode 7 out
sleep 4
gpio mode 7 input
break
;;
"ricard eau" )
gpio mode 24 out
sleep 3
gpio mode 24 input \</p><p> gpio mode 25 out
sleep 3
gpio mode 25 input
break
;;
"tequila orange" )
gpio mode 22 out
sleep 3
gpio mode 22 input \</p><p> gpio mode 7 out
sleep 3
gpio mode 7 input
break
;;
"Gin orange" )
gpio mode 23 out
sleep 2
gpio mode 23 input \</p><p> gpio mode 7 out
sleep 4
gpio mode 7 input
break
;;
*)
echo "bye"
break
;;
esac
done
;;
"soft" )
while true; do
choice="$(zenity --width=400 --height=300 --list --column "" --title="test" \
"orange" \
"coca" \
"eau")"
echo $choice
case "${choice}" in
"orange" )
gpio mode 7 out
sleep 6
gpio mode 7 input
break
;;
"coca" )
gpio mode 0 out
sleep 6
gpio mode 0 input
break
;;
"eau" )
gpio mode 25 out
sleep 6
gpio mode 25 input
break
;;
*)
echo "bye"
break
;;
esac
done
;;
"shooter" )
while true; do
choice="$(zenity --width=400 --height=300 --list --column "" --title="test" \
"whisky" \
"wodka" \
"tequila" \
"gin" \
"TGV")"
echo $choice
case "${choice}" in
"whisky" )
gpio mode 2 out
sleep 2
gpio mode 2 input
break
;;
"wodka" )
gpio mode 3 out
sleep 2
gpio mode 3 input
break
;;
"tequila" )
gpio mode 22 out
sleep 2
gpio mode 22 input
break
;;
"gin" )
gpio mode 23 out
sleep 2
gpio mode 23 input
break
;;
"TGV" )
gpio mode 22 out
sleep 1
gpio mode 22 input \</p><p> gpio mode 23 out
sleep 1
gpio mode 23 input \
gpio mode 3 out
sleep 1
gpio mode 3 input
break
;;
*)
echo "bye"
break
;;
esac
done
;;</p><p> "cow boy" )
while true; do
choice="$(zenity --width=400 --height=300 --list --column "" --title="test" \
"ricard pierre" \
"whisky coca" \
"wodka orange" \
"gin orange" \
"tequila orange" \
"cimetière")"
echo $choice
case "${choice}" in
"ricard pierre" )
gpio mode 24 out
sleep 4
gpio mode 24 input \</p><p> gpio mode 25 out
sleep 5
gpio mode 25 input
break
;;
"whisky coca" )
gpio mode 2 out
sleep 3
gpio mode 2 input \</p><p> gpio mode 0 out
sleep 6
gpio mode 0 input
break
;;
"wodka orange" )
gpio mode 3 out
sleep 3
gpio mode 3 input \</p><p> gpio mode 7 out
sleep 6
gpio mode 7 input
break
;;
"gin orange" )
gpio mode 23 out
sleep 3
gpio mode 23 input \</p><p> gpio mode 7 out
sleep 6
gpio mode 7 input
break
;;
"tequila orange" )
gpio mode 22 out
sleep 3
gpio mode 22 input \</p><p> gpio mode 7 out
sleep 6
gpio mode 7 input
break
;;
"cimetière" )
gpio mode 2 out
sleep 2
gpio mode 2 input \</p><p> gpio mode 3 out
sleep 2
gpio mode 3 input \
gpio mode 23 out
sleep 2
gpio mode 23 input \</p><p> gpio mode 25 out
sleep 2
gpio mode 25 input \
gpio mode 7 out
sleep 1
gpio mode 7 input
break
;;
*)
echo "bye"
break
;;
esac
done
;;
*)
echo "bye"
break
;;
esac
done</p>
Step 6: Final MountingI use a vertical furniture from IKEA was cheaper than to build myself. I cut a square from the front door to put the glass I made some hole in the shelve to pass a pipe , the pipe of the pump goes there. At the bottom i put a wire rack from a ventilation computer with a container for the leaking water
Step 7: ConclusionEverything is working properly but i have faced some unattended problem.
Few issue:
- The case is a bit tight ,when you fill up can be complicated. -
- The container for drinks are on the top and the glass at the bottom; it will create a siphon which mean even when the pump stop the liquid keep coming.
In order to avoid this use a horizontal case or like me you will have to make a small hole in the pipe in the emerge part.
Also you can see i have cable going everywhere which looks bad, so horizontal desk would be the best option .
Advice:
Put some stickers on each container to know what drink the relay is connected to.
Comments