Building a voice controlled drinks dispenser with Lego and Raspberry Pi

The last two weeks have been the not-quite-Easter Spring school holidays. That meant 16 days to fill with a tech-loving nine year old.

We had plenty happening in the first week, but on the second week both my wife and I were back at work, so I got my son working on a project involving some Lego and a Raspeberry Pi.

Our idea was to build a voice-controlled drinks dispenser. We’d use Alexa to trigger a Raspberry Pi, which in turn would drive a small water pump. Skipping ahead, here’s a look at the finished machine:

Step one of the project took place in the (messy) basement at my work. Ewan brought in a big box of Lego and set about building a frame to hold a water bottle that would act as the ‘tank’ inside the water dispenser.

The basement workshop

Next, we soldered a couple of jumper wires to a cheap water pump we found on eBay. To keep things really simple, we used another eBay find, a mechanical relay board, to control the motor.

The 5V power to the motor was pulled directly off the 5V & Ground GPIO lines on the Raspberry Pi (a bit sketchy, I know) so that everything could run with minimal wiring from the same 5V 2A USB power supply.

Everything in place, ready to pour

The software side of things turned out to be a bit easier than I’d feared. Using John Wheeler’s Flask-Ask Alexa Skills kit for Python and Nishit Patel’s excellent tutorial, we had our Pi hooked up to a custom Alexa Skill in under an hour.

Ngrok running the tunnel from Raspberry Pi to the Alexa Skills server in the foreground, while our Python script using Flask-ask runs in the background

For now we’re just pouring water (or juice) from a single bottle, but it would be fairly trivial to hook up several of these cheap water pumps to pour a variety of drinks, or even make a cocktail!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.