Updated 26 February 2021

Making a dumb coffee grinder slightly less dumb.

This is a programmable timer tethered to a Rancilio Rocky coffee grinder. The Rocky is a "dumb" grinder and electrically very simple. Basically it's an ac motor with an on/off switch and a momentary push-button to grind. This project adds an electronic timer so that repeatable grind quantities can be produced without having to stand over the grinder. Features: - Four programmable presets (A, B, C or D). - Left/Right buttons to select preset. - Up/Down buttons to adjust grind duration for selected preset (0.25s increments up to 60s). - Grind button to initiate grind and begin countdown timer. - Oled display (128x64) to show preset menu and countdown timer. - Aluminium enclosure. - Single cable (3-core) tether to grinder for power and control. Code, schematic and PCB layout are all on github.

**WARNING! This project deals with mains power and should not be attempted by anyone who isn't licensed to do so. Please be safe!**


Various components were used for this project to build the power supply and control circuitry, however, for most makers, it's much easier and safer to grab an off-the-shelf power supply. With that in mind, here are the main components that you will need:


Along with general skills such as soldering, PCB etching, and machining, this project requires a fair amount of maker intuition. Only attempt it if you are confident to do so.

Grinder Tether

A three-core cable is required to tether the grinder_timer to the coffee grinder. The cores are required for power (active, neutral) and to actually switch on the grinder (motor). The tether cable is connected at both ends via spade connectors. Within the grinder, the spade connectors splice into existing spade connections with no modifications required. The cable is run through the same grommet as the grinder's AC supply cable. There is no permanent modification to the grinder required.

Coffee grinder power supply schematic


The grinder_timer takes power from the coffee grinder. Since the grinder is a simple AC circuit, the grinder_timer had to include power transformation/rectification/regulation to provide 5V for the other components. The power sub-circuit uses basic components to provide 5V to the AVR and other components.

  • Transformer 240VAC/6VAC x2 @ 0.25A (secondary coils connected in parallel for 6VAC at 0.5A)
  • Bridge Rectifier
  • Filter Capacitors - 470uF, 10uF, 2x 0.1uF
  • Voltage regulator LM7805
  • Relay 5A/250VAC

Control power supply schematic

Motor Control

The grinder motor is switched on/off by grinder_timer via a relay. Closing the relay simply completes the neutral side of the grinder motor circuit.

AVR Circuit

The main circuit is based on an ATmega328p AVR micro. It is connected to pin headers for connecting the buttons and a USB/Serial adapter. Another pin header is for I2C control of the OLED and includes pull-up resistors on the clock and data lines. There's a six-pin ISP header for programming. I wanted the countdown timer to be reasonably accurate so there is a 32.768kHz crystal connected so as to implement an RTC (real-time clock) with the AVR.

AVR schematic

OLED Module

The display is a 128x64 pixel mon OLED driven by an SSD1306. It is controlled by the AVR's I2C (TWI) peripheral. The module is physically connected via a pin header on the main circuit board.

OLED breakout schematic

Prototype Circuit

I developed the prototype of the electronics on a bread-board simultaneously with the schematic CAD.

Breadboard prototype for AVR circuit


Early development stages of the code were written exclusively with vim from the terminal (terminator). However, I had read about Atom and decided to try it out so at some point in development I switched over.

The code is all interrupt driven. Pushing any button runs the pin-change interrupt that checks which button and performs the appropriate action.

The grind button enables the timer/counter 2 peripheral which is set up to use the external 32.768kHz crystal. This is the timer that actually counts down the desired duration. This could have been done with an internal oscillator, but I wanted to learn about using the AVR as an RTC for more accurate and consistent timing.

The AVR's internal EEPROM is used so that the stored presets survive a power cycle.

One trick I missed with the OLED module is the requirement to toggle the reset line as part of a start-up sequence at boot (datasheet included on GitHub repo). I simply tied the reset line to the AVR's reset line. I eventually found this was causing issues at power-up because the OLED reset is supposed to be toggled a minimum duration after the oled power stabilises. Ideally, this would be done with code using one of the AVR's GPIO pins tied to the OLED's reset pin. The workaround I figured out was a capacitor across the OLED's reset pin with enough capacitance so that on power-up there is effectively a delay setting the reset line high while the capacitor charges up. This is a bit of a bodge but seems to work and has the benefit of not requiring an additional GPIO pin. However, if I need to iterate, the next circuit design would probably include AVR control of the OLED's reset line.

I designed a seven-segment-style font for the timer display. This design was done using a spreadsheet which is included in the reference material on the repo. Each digit is 24x48 pixels.

Circuit Design

The schematic and PCB layout were designed with KiCad. Prior to this project, my only circuit CAD experience was with Eagle. I used this project to familiarise myself with the open source alternative. All the KiCad project files are included in the GitHub repo.

The PCB layout outer-dimensions was driven by the size of an aluminium enclosure I wanted to use. This enclosure was selected based on the most cumbersome component - the PCB mounted transformer.

PCB layout image

PCB Fabrication

I designed the PCB to be fabricated using the toner-transfer method a single-sided copper-clad board. After etching, I cut the board to size, drilled the holes and started populating.


The PCB was mounted within an aluminium enclosure. The lid was cut to mount the OLED and the five buttons, all of which connected to the PCB via headers. The tether cable connects to the PCB via spade connectors and runs through a hole (with grommet) through the enclosure. The other end of the tether cable runs through the existing power-cord grommet on the grinder and ties into the three connection points via 3-way spade terminal splices.

Boxing it Up

Initial hardware mounting for the enclosure

Final test fit of all grinder control hardware

Boxing up and connecting the grinder

Finished coffee grinder control box

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.



Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.