This is only a preview of the September 2023 issue of Silicon Chip. You can view 38 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Salad Bowl Speakers":
Items relevant to "pH Meter Module":
Articles in this series:
Items relevant to "Coffee Grinder Timer":
Items relevant to "PIC Programming Adaptor":
Items relevant to "30V 2A Bench Supply, Mk2 – Pt1":
Items relevant to "Voltage Inverter / Doubler":
Purchase a printed copy of this issue for $11.50. |
Flavio Spedalieri’s Arduino-based
Coffee Grinder Timer
Take your coffee grinder (or other motorised
appliance) to the next level with a custom
timer module, programmable presets and an
LCD or OLED screen.
G
ood coffee grinders are expensive
– even basic, manual models operated by a simple switch can cost over
$500, and some well over $1000! You’d
think that they’d throw in a timer for
that much money, but there’s often a
premium of several hundred dollars
on models with timers.
Having a programmable timer in
a coffee grinder used for making
espresso is a big advantage. Once
you’ve determined the correct grind
setting and time to make a good coffee,
it will produce a consistent amount
of grounds so that each cup is consistently good.
Too many grounds will choke off the
water flow, while too few will make
weak coffee. You want minimal variation from cup to cup.
It would be ideal to buy a grinder
that does an excellent job of making
the coffee grounds without spending
siliconchip.com.au
too much money, then add a timer if it
lacks one. That’s what I did, and you
can do the same.
Why spend so much when you can
get a coffee grinder at Kmart for $18?
Because it won’t be ideal for making
good-quality espresso. It won’t grind
finely enough or consistently enough,
won’t be adjustable enough, and will
take quite a long time to produce
enough grounds for one cup. It also
won’t last very long.
While this project is designed to add
a timer to a coffee grinder, it could be
used for just about any appliance that
runs off the mains and can be switched
using a solid-state relay. It could also
be used to switch low-voltage AC or
adapted to switch low-voltage DC.
The circuit is simple, and the parts
are inexpensive; with some work, you
can upgrade just about any grinder
with this programmable timer.
In my case, I wanted to add a timer
to a used Compak K6 grinder (a well-
regarded unit) that was generously
donated to me by Dean and Rose Kiner
of Siboni’s Coffee in Pymble NSW.
I had two main jobs to do. One was
to design the electronics and create
the software for the timer itself. The
other was to figure out how to modify the grinder to nicely integrate the
electronics.
A timer should be easy to use and
free from complexities, with a simple
menu for making adjustments. I considered using a DIN-style timer; however, they can be difficult to use and
require substantial clearance to fit,
meaning it would have to be external
to the grinder. So I decided to base it
on an Arduino module, as I am familiar with that ecosystem.
The first part of this article will concentrate on the timer module and its
functions. It could be adapted to many
other applications or even built as an
external module, making it easy to add
to use with any suitable appliance. It
is incredibly handy for more precise
measurement and dosing of the coffee grounds.
Note that some timerless grinders
have a ‘doser’ mechanism that catches
the grounds and apportions them to
suit the coffee machine. This has several disadvantages, including stale
coffee getting stuck in the doser, especially since you have to keep it close to
full for the doses to be accurate.
If adding this timer to a grinder with
a doser (as I did), it would be necessary to remove the doser and replace it
230V AC Mains Safety
The entire timer module can be built, tested, and made functional without
touching mains voltages.
However, should you wish to interface the module to a solid-state relay (SSR)
for mains switching as described, please follow all the precautions described
in this article for safely working with 230V AC mains.
That includes using correctly rated parts and wiring, properly insulating all
exposed conductors and avoiding touching any part of the circuit when the
mains cord is plugged into an outlet.
Australia's electronics magazine
September 2023 57
Photo 1: the Arduino Pro Mini is
basically a shrunk version of the Uno.
It’s no longer officially made, but
plenty of clones are still available.
Photo 3: the three buttons that control
the Timer all have integral LEDs.
You could use three similar types of
buttons if you want.
with a chute that dispenses the ground
coffee straight into a ‘portafilter’ basket or similar.
an I2C serial interface, the addition
of a ‘manual grind’ display, a rotary
encoder for easier time setting, the
reconfiguration (and reduction) of the
buttons, adding visual feature through
LED fades and flashes, plus an ‘offset mode’ and the ability to display
the firmware version and disable the
splash screen.
I eventually added support for multiple display types, including OLEDs.
Timer design
I found some code online for a very
basic two-preset timer to control an
electrical appliance. A 16×2 character backlit LCD with a parallel interface was used as the display, with four
control buttons (+/−, P1, P2 & manual) for control. It integrated with the
appliance’s multi-switch, which was
rewired to activate the timer (effectively giving it five buttons).
I loaded this code to understand
how the timer would work from an
end-user/operator perspective. Still,
I knew I would have to redesign the
circuit and rewrite the code to suit my
needs better.
Some improvements I made include
the ability to drive the LCD through
Arduino software
Besides being easy to use with a
clear display, I decided the software
should have a screen saver mode
(where the screen is turned off after
five minutes of inactivity) and the
visual LED fades. The Arduino platform I ended up using is the Pro
Mini board (Photo 1) with the usual
ATmega328 microcontroller.
One advantage of using the Pro Mini
is that I could prototype the system
using an Arduino Uno (Photo 2) and
then transfer it quickly to the compatible Pro Mini later.
I split the software up into nine
source code files:
1. the main program
2. button press handling
3. display driving
4. rotary encoder sensing
5. utility functions
6. initialisation
7. LED driving
8. & 9. splash screens for the two
OLED display options
These files and the compiled HEX
file are available for download from
siliconchip.com.au/Shop/6/248
Button configuration
Photo 2: the prototyping rig used to
develop the software, based on a few
small modules and jumper wires.
58
Silicon Chip
I reduced the button requirement to
three; one button to select between the
two presets, one to trigger the selected
preset and one for manual grinding.
The rotary encoder is used to set the
Australia's electronics magazine
times and has a fourth integrated button to access the menu. Photo 3 shows
how I mounted the three buttons, and
you can see the rotary encoder above
them.
However, the code also has the
option to have two different trigger
buttons, one which triggers preset 1
and one which triggers preset 2.
Editor’s note: that is how the grinder
at our office works, as it makes it convenient to select between single- and
double-shot espresso.
Display options
As mentioned earlier, the original
concept used a 16×2 character LCD.
However, I realised that a smaller
screen would be needed to fit within
a limited space inside the grinder.
I therefore modified the software to
support a 128×64 pixel OLED display
with an SSD1306 controller using the
U8G2 Display Library – see Photo 4.
After testing several OLED screens,
I arrived at the Digole Digital Solutions DS12864OLED-2W white-onblack OLED (Photo 5). As driving it is
different from the generic SSD1306
screens, there are two different versions of the firmware to handle both
types of 128×64 OLED screen. Table 1
shows the various software versions I
have developed that are available to
download.
The Digole screen (www.digole.
com) is a graphic type with a fast
update response and only needs a
small library to drive it. It does need
fonts to be loaded into the four user
font addresses.
The more common 128×64 graphic
OLEDs using an SSD1306 or SH1106
controller can also be used, but
they have a slightly slower display
response. For these, the I2C communication speed may be improved by
adding the function call “u8g2.setBusClock(600000);” in the initialisation code.
If using the Newhaven character
OLED, the display has a reset pin
which can either be driven from the
Arduino or connected to an RC circuit
to pull it low for about 40ms during
power-up. It uses the US2066 chipset;
however, the I 2 C Display library
is used (www.dcity.org/portfolio/
i2c-display-library/). This requires
the following code changes to function correctly.
Inside the function I2cChar
Display::oledBegin(), where the
siliconchip.com.au
Photo 4: the graphic
OLED screen (left) is
much more compact
than the alphanumeric
version (right).
Photo 5: the selected
OLED screen fits
neatly behind the new
custom-made front
panel, painted black.
following two lines are found, change
0x00 on the second line to 0x10:
// Set SEG Pins Hardware Configuration
sendCommand(0xDA);
// Enable SEG Left, Seq SEG pin config
sendCommand(0x00);
The 16×2 character LCD with I2C
interface is the simplest display from
the software point of view, but it is
much larger than the other options,
and isn’t capable of displaying graphics.
Circuit details
The resulting circuit is shown in
Fig.1. The Arduino Pro Mini, OLED/
LCD screen and rotary encoder modules are powered by 5V DC from
the switch-mode power supply. The
Arduino updates the screen using
a two-wire I2C serial bus, via its A4
(SDA) and A5 (SCL) pins.
Internal pull-up currents are enabled
on digital input pins D5, D7 & D8 to
detect when pushbuttons S1-S3 are
pressed. The integral LEDs in those
buttons are driven by digital outputs
D10, D11 & D9. Two of these (D10 &
D11) have series current-limiting resistors to set the LED currents to around
9mA, while the third does not because
the switch includes a series resistor
for its LED.
While the resistor integrated into
switch S3/LED3 is designed to allow it
to operate from 12V, it isn’t too much
dimmer when driven from 5V.
The LED in the solid-state relay is
driven directly from the D12 digital
output. It has an integral 1.5kW resistor and supports a control voltage
range of 4-32V DC. As it only draws
less than 4mA at 5V, the Arduino output can easily drive it. The SSR’s outputs are connected in series with the
mains supply to the grinder motor, so
it switches the motor on while the D12
output is high.
The rotary encoder I used is mounted
on a small PCB, which includes three
pull-up resistors for the two encoder
contacts and the integral switch. Pins
1 & 2 are for ground and the power
supply that drives the pull-ups, while
the remaining three pins are for the
encoder and switch contacts. These
go to digital inputs D2-D3 and D4 on
the Arduino, respectively. They are
debounced and decoded in software.
Fig.1: the Timer circuit is straightforward, with the Arduino module controlling all functions and updating the display
over a two-wire I2C serial bus. It controls the SSR that switches the grinder motor via a digital output and uses three
buttons (with integrated LEDs) and a rotary encoder for user input.
siliconchip.com.au
Australia's electronics magazine
September 2023 59
If you want to use a different rotary
encoder than I did, refer to “Encoder
Setup” in the main code file to adjust
its behaviour.
While there are no doubt various
SSRs that could be used in this application, I chose a high-quality unit,
with much higher voltage and current
ratings than necessary, for a long life.
My grinder motor is rated at 245W
(1.02A) <at> 240V AC. You should
check yours against the ratings of
your selected SSR; the one I specified
should suit most grinders.
The operation and functions of the
Timer are listed below:
#1 Splash Screen
As a departure from traditional
nomenclature, I adopted a more
generic “PRESET 1” and “PRESET 2”.
By default, the firmware uses single
button control as fewer holes needed
to be drilled in the grinder. In this
case, pressing the Select button toggles between the two presets. The Run
button illumination will Flash once
when Preset 1 is selected and twice
when Preset 2 is selected.
The firmware also supports two buttons, one for Preset 1 and a second for
Preset 2. Pressing the associated button will change the preset program
accordingly. This second switch can
be connected to pin D6 of the Arduino
Pro Mini and then to Ground.
#4 Program Mode
Photo 6: the grinder I started with; it
had seen a lot of use. Note the large
doser assembly attached to the front
and the original, tall hopper on top.
If “Display Start” is enabled, the
splash screen will be displayed on
power-up for four seconds (see above
and Screen 1). The displayed message
is preconfigured in the initialisation
file. If “Display Start” is disabled, it
will instead immediately display the
default Preset 1 (Idle Mode).
The Run button illumination
increases from off to bright as it enters
idle mode.
#2 Idle Mode
Pressing the encoder button/knob
(Program) enters the program mode
for the currently displayed preset. The
Run button illumination extinguishes
in program mode. The display changes
to show “PROG <> PRESET”. Turning the encoder knob will change the
preset time.
Pressing the encoder button will
return to the current preset (Idle
Mode) and will save the time if it was
changed. The Run button will flash
four times on exit.
#5 Offset Mode
Screen 1: an example of the splash
screen displayed on the OLED module.
Screen 2: the Firmware Version
Display screen on the OLED module.
60
Silicon Chip
Following power-up, the timer
defaults to Preset 1 with the displayed
time loaded from EEPROM.
The Run button continuously cycles
between dim and bright every three
seconds.
#3 Switching Preset Program
The firmware has two preset times,
inspired by commercial timed grinders that usually have ‘single cup’ and
‘double cup’ options.
The ‘double cup’ grind is not necessarily twice the time of the ‘single
cup’, as single and double espresso
filters usually hold 7-10 grams and
16-18 grams of coffee, respectively.
That, and the way roasted coffee beans
vary, mean the times both need to be
adjustable.
Australia's electronics magazine
Offset mode allows for ‘on-the-fly’
preset time adjustment throughout the
day without changing the saved preset
time. This lets you experiment with
the amount of coffee without changing the stored presets.
Rotating the encoder dial/knob in
Idle Mode automatically enters Offset Mode. When the displayed time
is lower than the preset, the LCD will
show “<OFFSET”, and when higher,
it shows “OFFSET>”.
If you turn the encoder to return
to the preset value, the display will
return to “PRESET”.
While in Offset Mode, pressing the
encoder (Program) button will enter
Program Mode and clicking again
(to exit) will update the stored preset value in EEPROM with the new
siliconchip.com.au
value. The Run button will flash four
times on exit.
Note that for the V2.65 firmware
(single button configuration), once
Offset Mode has been activated, when
returning to normal Idle Mode, the
Preset button must be pressed twice
to change the preset.
#6 Grinder Activation
Pressing the Run button runs the
grinder for the currently selected preset time. The Run button illumination
will extinguish when the grinder is
operating, during which time a countdown is shown on the screen. When
it finishes, the display returns to idle
mode and the Run button will re-
illuminate.
#7 Manual Grind/Purge
A manual grind/purge button is an
important feature of any grinder. Pressing and holding the Manual button
causes the grinder to run while the button is held down. The display shows
“MANUAL GRIND” during this time
while the Run button cycle-flashes.
#8 Enable/Disable Splash Screen
To enable or disable the splash
screen, press and hold the Select button (or P1 if you’re running the dual
preset button firmware) for four seconds. The Run button will flash at
1Hz. Release once the display shown
above appears.
Again, on this screen, hold that button for four seconds to save the change.
The Run button will flash four times
on saving the change to EEPROM
and returning to the Idle screen. The
Splash Screen is toggled on or off each
time you go through this procedure.
#9 Firmware Version Display
Press and hold the rotary encoder
siliconchip.com.au
Table 1 – software versions
Name
Screen
Preset buttons HEX file?
1B_128x64OLED
128×64 graphic OLED
(SSD1306)
1
Yes
2B_128x64OLED
128×64 graphic OLED
(SSD1306)
2
No
1B_DS12864OLED
128×64 Digole
DS12864OLED-2W OLED
1
Yes
1B_NW1602OLED
16×2 character Newhaven
NHD-0216AW-IB3 OLED
1
No
1B_1602LCD
16×2 character LCD
1
No
2B_1602LCD
16×2 character LCD
2
No
(Program) button until the Run button begins flashing, then release it.
The firmware information will be
displayed for four seconds before
returning to Idle Mode (also see
Screen 2). The Run button flashes
once on exit.
Note that most of the screengrabs
shown are for the 16×2 alphanumeric
displays. As seen in Screens 1 & 2, the
OLED has a more square aspect. In
most cases, it shows the same information as the LCD screens, just reformatted to better fit the OLED.
Grinder conversion
The coffee grinder to which I added
this timer was an old Compak K6 that
I refurbished and modified at the same
time. Photo 6 shows it in its original
state.
As it was ‘well-loved’, I completely
stripped the grinder (Photo 7), cleaned
everything and sandblasted the housing (Photo 8).
Converting it to be doserless
required the removal of the old dosing chamber, re-engineering the outlet
port and mounting a spout or cone. A
Rancilio Rocky doserless grinder spout
(which Dean also provided) was my
first choice (see Photo 9).
I also considered retrofitting a dose
cone from a Mazzer Mini but decided
against it as they are expensive (over
$250).
Also, it would have been too tall,
pushing the placement of the portafilter holder much lower than where
the display is positioned.
You might notice that I reduced
the size of the hopper, something that
was not required but that I decided to
do. I accomplished this by marking,
hand-cutting and sanding the hopper.
A felt strip on the inside edge of the
hopper lid made for a snug fit.
One of the main challenges was
Australia's electronics magazine
Photo 7: the cut-down hopper and
the curved front panel with the doser
removed. That made attaching the
new chute and display challenging.
Photo 8: the stripped chassis after
sandblasting. Note how I have ground
away some of the metal around the
opening at the top so the new flatflanged chute can be fitted.
September 2023 61
Photo 9: after reshaping the orifice,
the chute (designed for a different
type of grinder) fits nicely.
Photo 10: this handmade timber piece
covered up the gap left by removing
the doser.
modifying the existing casing, which
had a curved section where the outlet port is, to mount the spout with
its flat mating flange. This required
modification to both the case and the
original plastic coffee outlet adaptor.
If you can modify a grinder that has
a flat front face, that will make everything a lot easier!
To pay homage to Siboni’s Coffee and one of my favourite blends,
“Romeo”, I programmed the “Romeo”
graphic to appear on the splash screen,
as seen in Photo 5 and Screen 1.
With the timer ready, I started cutting and drilling holes in the grinder
case for the switches, screen, and
mounting point for the portafilter fork.
I used the portafilter holder from a
Mazzer Mini grinder.
Depending on the design of your
grinder, its motor might be switched
by a manual switch or a relay. In my
case, it was a 16A mechanical relay.
I simply removed this and connected
the SSR in its place.
I securely mounted the SSR and
switch-mode power supply inside the
grinder case and wired up the switchmode supply to the incoming mains
(after the power switch).
One question was how to fill in the
original gap at the top of the grinder,
where the doser used to attach, and
how to tidy up the front face.
For the top of the grinder, I wanted
to use a piece of timber as it would
add a ‘warm tone’ to the project. I
cut three sections of Tasmanian Oak,
glued them together, then sanded and
contoured the piece (Photo 10). Two
Neodymium magnets secure it to the
body and allow for its removal if the
front needs to be disassembled, eg, to
remove the spout for servicing.
I gave the timber piece several coats
of walnut stain before two coats of
Scandinavian Oil and final coats of
beeswax.
I also needed to produce a new
front face to attach the spout, portafilter holder and timer display. I first
mocked up the plate for the front
face with card (Photo 11), then 3mm
ply, and eventually translated it to
1.2mm-thick aluminium (see Photo
12). I hand-cut the aluminium stock
(using a nibbling tool) and finished it
by hand. I conducted a final fitment
test before painting it (Photo 14).
I added an indentation above the
portafilter holder to position the filter
directly under the spout. As a bonus,
it can aid in holding the filter in place
during grinding (shown in Photo 14).
With the grinder housing completed, all holes cut, drilled & tapped,
fitment tested and the timber in-fill finished, it was time to sandblast the case
and prepare for final painting.
I gave the case five coats of black
satin paint with a final sandy texture
finish, sealed with a clear topcoat.
As you will see from Photo 16, I
opted to mount all the new controls
along the side of the base, as there was
plenty of room, except for the rotary
encoder, which is mounted above the
Photo 12: the metal face plate was
made from 1.2mm-thick aluminium
and painted to match the body.
Photo 13: the OLED screen fits nicely
near the base. The new front panel
will cover its mounting screws.
Aesthetic details
Photo 11: I cut and folded this card to
figure out how to shape the new metal
front panel.
62
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
buttons on the side of the main body.
Wiring it up
As I had already installed the
switch-mode supply and SSR, as mentioned earlier, all that was left was to
wire the Arduino and other modules
as per the circuit diagram (Fig.1).
Given the simplicity, I mostly used
point-to-point wiring to connect the
components to the Arduino. You can
see how it all (just) fits inside the
grinder base in Photo 15.
If your grinder does not already have
a relay to control the motor, you will
need to cut one of the wires going to
it and connect the two ends across the
SSR’s mains terminals.
The power supply and SSR both
need to be solidly anchored to the
case. Use mains-rated wire for the new
connections to the switch-mode power
supply and fully insulate all new or
modified mains connections.
Cable tie the Active and Neutral
wires to the switch-mode supply
together at both ends. Also, cable tie
the mains wires to the SSR together
if possible.
I haven’t gone into great detail about
how I modified my grinder because
most of the steps will depend heavily on the specifics of your grinder.
Still, if you want to see exactly how
I did it, you can see all the details on
my website at www.nightlase.com.
au/?pg=coffee
The lead photo and Photo 16 shows
the final result with the grinder up
SC
and running!
Photo 14: a bracket and a detent in
the front panel hold the portafilter in
place during grinding.
siliconchip.com.au
Parts List – Timer for coffee grinders
1 Arduino Pro Mini (MOD1) [Core Electronics 018-MINI-05]
1 230V AC to 5V DC 1A enclosed switch-mode power supply
[Jaycar MP3295]
1 USB/serial adaptor (to program MOD1)
1 Digole DS12864OLED-2W or SSD1306/SH1106-based 128×64 pixel
graphic OLED (MOD2)
1 25A 480V AC solid-state relay (SSR) [Kyotto KD40C25AX]
1 chassis-mount momentary pushbutton with integral white LED (S1/LED1)
[Core Electronics ADA1479]
1 chassis-mount momentary pushbutton with integral red LED (S2/LED2)
[Core Electronics ADA1439]
1 chassis-mount momentary pushbutton with integral green LED and
current-limiting resistor (S3/LED3) [Jaycar SP0804]
1 five-pin rotary encoder module with integral pushbutton plus knob (RE1)
[www.aliexpress.com/item/32790788377.html]
2 220W ¼W resistors
various lengths of mains-rated wiring, heatshrink tubing, cable ties etc
various screws, nuts and other mounting hardware
Photo 15: this photo inside
the grinder base shows the
added 5V power supply
(upper left), SSR (bottom
middle, under Presspahn
insulation), buttons and
some of the new wiring.
Cable ties were used
extensively to prevent
wires from floating around
in case they came loose,
and all mains connections
were fully insulated.
Photo 16: the finished
grinder conversion, with
the OLED screen, buttons
and rotary encoder visible
towards the bottom.
Compare this to the
original (shown in Photo 6)
to see the transformation.
Australia's electronics magazine
September 2023 63
|