The coolest vending machine

My 13 year old daughter has been fascinated by vending machines for a long time. Let’s face it, there’s something magical about making a robotic machine come to life and having it do your bidding.

For a long time we talked about making one and finally, once summer came around, I agreed to build her one.

So, what does it do?

The Coolest Vending Machine is a product dispenser with five independent compartments. It is really cool because it is refrigerated (pun intended). It is also cloud connected and even has a camera, for you to view remotely the product delivery. It is analytics ready and a full citizen of the IoT world we live in.

Electronics

There are three MCUs in this project, connected by an I2C bus: an ESP32-CAM for cloud connectivity, an Arduino Uno to manage the systems in the front of the machine and an Arduino Nano for the back systems.

Relays are used to power components that require more power than what the Arduinos can provide, such as the Peltier element, the laser and the controller compartment fan.

As I learned in my earlier projects, it is important to have removable connectors between any two components on the system, to facilitate troubleshooting and replacement if needed.

Arduino Uno controls front systems

Most wiring was done using 20 AWG silicone insulated wire and multiple types of connectors were used, including crimp terminals and JST. The wires soldered to the Arduinos were 24 AWG, due to the size of the holes on the MCUs.

In all The Coolest Vending Machine has 226 component connections, which means twice as many wires and four times that number of soldered connections and crimped connectors.

Payment system

A coin acceptor was used to accept payment and a 3D printed drawer with a SG90 servo was used for refunds.

The Coolest Vending Machines allows you to pay for a product with a combination of 5 different coin values (2€, 1€, 50c, 20c and 10c). You can cancel the purchase before you complete payment and the machine will return the coins you had inserted. If it is unable to deliver the product you chose, it will refund you, but it does not provide change.

Coin acceptor and refund system

You have good tutorials on how to program the acceptor here and here. It helps if you have an oscilloscope, but it is not required. Basically the acceptor is trained to recognize a coin type and programmed to send a number of pulses when it receives such coins. In this case I programmed it to send one pulse for each 10 cents, which means it sends two pulses when a 20 cent coin is inserted, as depicted in the image below.

Coin acceptor pulses sent to Arduino when 20c coin is inserted

The downside of this system is that the coin acceptor will need to send the Arduino controller twenty pulses for each two Euro coin inserted, which takes 2 seconds. This is something you see in commercial machine with this type of coin acceptors – they take longer to confirm the insertion of a large value coin than a smaller value one.

Power

In the architecture diagram above different colour lines represent different voltages, so The Coolest Vending Machines uses two DC power sources to supply 5 and 10 Volt. Part of the circuit uses 3.3 V, which is provided by the ESP32-CAM.

Two power sources

State diagram

The diagram below represent the sequential states when using the machine, including failure to deliver a product purchased. The LOG circles indicate what is logged to the cloud for analytics.

HMI Screens

In this project I used a Nextion HMI display (NX4832T035_011R). It’s a very cool technology because you load the screens and animations (e.g. progress bar) on the display itself and it just receives commands from the Arduino controller and sends it the inputs received on the display (e.g. button presses).

A total of 18 screens were designed, to cover the full interaction portfolio.

HMI screens and properties

The structure

The Coolest Vending Machine is made with plywood, painted with blue acrylic paint on the outside, and white on the inside of the product compartment.

Painted exterior panels
Coolest Vending Machine interior

Product extraction is done with a 3D printed drawer, that lifts a ramp to prevent intrusion. The drawer closes upon release, by means of a spring.

A spring shuts the product drawer upon release.
Video of the drawer in operation

The ramp has dual color for increased depth perception.

No. Not really. I just ran out of red filament mid-print and had to switch to another color 😉

Cooling

The compartments that holds the products is refrigerated using a Peltier element placed in a hole in the back of the machine. The cold generating side of the Peltier element is directed to the inside of the machine and is attached to a metal dissipator. The hot side is attached to a fan heatsink on the outside, bonded with some heatsink plaster.

Peltier element with dissipators
Cooling system viewed from the outside

The cooling system also includes a LM35 temperature sensor (nice tutorial here), which measures the internal temperature of the machine, close to its roof.

LM35 temperature sensor

Door systems

The door of The Coolest Vending Machine has an acrylic window, lit around its border by WS2812b (neopixel) segments. Don’t forget to add a capacitor when powering these sensitive things.

The coin return system, the coin acceptor, the buzzer and the HMI display are also mounted on the door.

Systems mounted inside the door
Door from the outside

There is a contact switch on the bottom of the machine to check that the drawer is closed before starting to deliver of a product. The switch is oriented properly using a 3D printed support.

Contact switch

Product delivery

To deliver a product, a stepper turns a metal coil. When the product reaches the end of the tray it falls and intersects a red laser beam, pointed at a PGM5539 photoresistor.

Laser pointed at variable resistor

The steppers are driven by A4988 drivers with heatsinks. You have a nice tutorial here.

The steppers are held by 3D printed supports, designed in two models: one with two steppers side-by-side, for smaller products, and another with a single stepper, for larger products.

3D printed stepper supports – dual product model

Lessons learnt

The approach for this project was all wrong. After toiling away almost a year, I gave up, before a single product was dispensed. The project is a feature rich monolith and was a classic waterfall disaster.

The takeaway is that a project like this should be lean and agile, starting with a minimum viable product that you complete quickly and learn from, before iterating in order to increase functionality.

Lesson learned 🙂

If you enjoyed this project, please leave a comment. I would really enjoy hearing from you!

Leave a Comment

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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.