Back to main menu

Dev life

Snack delivery machine: Part 1, the mechanics

Hacking on hardware is always fun, and it’s been a while since we’ve created something! In this brief series of blog posts, we are going to make an email controlled snack machine using a dry-food dispenser, a Raspberry Pi, a pair of stepper motors, and a little bit of 3D printing.



Hacking on hardware is always fun, and it’s been a while since we’ve created something! In this brief series of blog posts, we are going to make an email controlled snack machine using a dry-food dispenser, a Raspberry Pi, a pair of stepper motors, and a little bit of 3D printing.

This post is going to concentrate on the mechanics first, and then we’ll continue to electronics in part two.

Ready? Let’s go!

Prepping the components

We started with a snack dispenser that you can find at any department store or online. If you’re curious about where we got ours, we got it off of Amazon.

Picture of a snack dispenser

It’s a pretty simple machine: the goodies load in from the top and you can turn the handle to dispense them to a bowl underneath. But what if we attach motors to the dispensing mechanism? Enter, the motors — aka two 12V NEMA-17 steppers. We used a pair of these, but learned the hard way that the machine can benefit from a little bit more torque than 0.2Nm.

Picture of two motors called 12V NEMA-17 steppers

These little guys were perfectly sized (length 34mm), and fit snugly inside the dispensers.

A picture showing the motors attached to the snack dispenser

Figuring out the powertrain

In our machine, the dispense knob had a “flat-milled” shaft that gets inserted into the piece with rubber flaps. The motor was also flat-milled, but the problem was that the diameter of the motor shaft was much smaller.

Picture of a motor shaft

We needed an adapter or, using mechanical engineering lingo, a key, to make it work. Naturally, our first idea of how to solve the problem was, “Hey, we can just 3D print it!” Because one, 3D printers are awesome, and two, we measured the parts and started designing that little piece for 3D printing pretty immediately.

Blueprints to 3D print an adapter

It took us seven iterations to arrive to a decent design.

Picture of final schematic for the adapter

No kidding, semantic versioning applies very well here!

Picture of the 3D printed adapter

With the key printed it was ready to be attached.

Picture showing the adapter fits the motor shaft

Success!!! Just for fun, here is the video of the printer doing its thing.

Making everything better with a Dremel

Based on the placement of the flap’s axle relative to the mount arm of the chassis, we figured we could drill out a portion of the mount arm for the stepper. We took the part that holds the vessel and made some adjustments to it, which was the most exciting part.

Slack conversation discussing Dremel Fever

With a flat cutting head, we removed the plastic that wouldn’t let us insert the steppers.

Picture of two men putting the project together

Final assembly

After a few minutes of carefully channeling the Dremel Fever™, the servos fit snugly. To secure them, we needed to find something that would fit between the servos and the chassis. Looking around we found a nice eraser that would do the job. Who says we can’t take advantage of no longer used prototyping gear and deploy it to prod?

A picture of an eraser with lines drawn on it

Inserted it on both sides of the motor and it fit snugly.

Picture of eraser on both sides of the motor


We flipped the flappers to face the servos in the back of the dispenser and attached them with the key. The last thing we had to do was to cut the flaps to make sure the servos could easily spin the mechanism.

Here is the final product from the mechanical perspective.

Picture of the final result of the email controlled snack machine

Pretty cool, right?

With all of the mechanical pieces in place, we had to start building the brain of our little machine. What would become the brain of our hard work? A raspberry pi, of course. As we all know, almost anything is possible with a Raspberry Pi, but you’ll have to wait to see how that turned out until next week!

Related readings

An expanded Mailgun product suite to transform email deliverability

Today marks a special day for Sinch Mailgun. For over a decade, our focus has been to provide the best email experience for businesses all around the world. Now, we take...

Read more

Privacy, automatic engagements, and Mailgun’s bot detection

Now more than ever, users are concerned about their data privacy and what steps they can take to protect their personal information. And that’s something big players in the tech...

Read more

How does Mailgun keep your emails protected?

On the surface, email seems relatively harmless – but dig a bit deeper and you’ll discover there’s a treasure trove of personally identifiable information (PII) at risk. This risk...

Read more

Popular posts

Email inbox.

Build Laravel 10 email authentication with Mailgun and Digital Ocean

When it was first released, Laravel version 5.7 added a new capability to verify user’s emails. If you’ve ever run php artisan make:auth within a Laravel app you’ll know the...

Read more

Mailgun statistics.

Sending email using the Mailgun PHP API

It’s been a while since the Mailgun PHP SDK came around, and we’ve seen lots of changes: new functionalities, new integrations built on top, new API endpoints…yet the core of PHP...

Read more

Statistics on deliverability.

Here’s everything you need to know about DNS blocklists

The word “blocklist” can almost seem like something out of a movie – a little dramatic, silly, and a little unreal. Unfortunately, in the real world, blocklists are definitely something you...

Read more

See what you can accomplish with the world's best email delivery platform. It's easy to get started.Let's get sending
CTA icon