← Builds / BLD-01

Arduino keypad lock for a coffee machine

How to add an Arduino keypad lock to a coffee machine: a four-digit PIN, a relay on the start button and status LEDs, all hidden inside the case.

BuildRepairSmall applianceElectronics

The coffee machine in my shared office kitchen was only ever meant for home use, and with hundreds of people from several companies passing through every day it didn't last long before it broke. I took it home to repair it, and while it was apart I made sure it wouldn't be worked to death again: I fitted an Arduino keypad lock, so the machine only brews once the right four-digit PIN has been entered. The same idea works on almost any appliance in a shared kitchen.

Watch the full build

Pressing play loads the video from YouTube (privacy).

Tapping power and wiring the relay

The brains of the build is an Arduino Nano. I opened up the machine's main control board, found a voltage regulator I could tap for power, and traced a 0 V point I could use as ground. The regulator's 3 V side was too low for the Nano, so I took power from the 12 V side and let the Nano's own regulator do the rest. The start button on the front is the one that sets the coffee flowing, so I interrupted that signal with a relay controlled by the Arduino. That meant desoldering and lifting two pins on the surface-mount switch, cutting one back with a rotary tool, gluing the switch down so it couldn't work loose, and wiring the relay in series with it.

Building the keypad and LED board

Everything was soldered onto a small piece of perfboard. I mounted eight of the Nano's header pins upright so the keypad's ribbon cable could plug straight onto them, and added a red and a green LED to show whether the machine is locked or unlocked. Because there's water running through the machine, all the joints got a generous coat of hot glue.

Fitting the keypad to the case

On the side panel I cut a slot for the keypad ribbon and made a small window for the status LEDs using a length of acrylic rod. I polished the inner face through the grits up to 1200 (and finished it on a junk-mail envelope at midnight) so it carries the light cleanly, then left the outer face at 400 grit so it diffuses the red and green into a single glow. I used the same light-pipe trick again a few months later on my motion-sensing TV switch-off box. Circuit-board standoffs were epoxied inside the panel so nothing shows on the outside.

Testing, and a PIN you can change

The first test lit the keypad up perfectly but the machine still wouldn't pour. The culprit was too much hot glue around the modified switch, which stopped the front button from pressing it. Once that was trimmed back it worked first time. I also programmed a change-code sequence into the software, with the code stored in the Nano's EEPROM, so the PIN can be changed from the keypad itself and survives the machine being switched off.

Usual caveat: this is an educational project, and modifying the electrics of your own appliances is at your own risk and may void the warranty.

More from the workshop