Making Coffee


Arduino’s making coffee, not bad. I built a small prototype circuit that keeps time and has an alarm mechanism. When the alarm goes off, the relay is kicked for 2 seconds. The user can set the time and alarm, as well as toggle the alarm on/off.

The prototype is built on a breadboard. Here’s a picture with button legend:



I Connected the relay to the coffee machine (pins NO and Comm). Also, the relay coil pins are connected to the breadboard, where the legend mark Relay pins. See the circuit schematic below for more details.

After boot, the clock needs to be set. To do so, click the set button. Use plus and minus to change the time. To move from setting minutes to hours, click set again.

Setting the clock

Setting the clock

To set the alarm, click the display button. Then set the time similar to the way done with the clock.

Setting the alarm

Setting the alarm

To toggle the alarm on, click the alarm button.

Alarm on

Alarm on

The Board


The 16×2 LCD is connected directly to Arduino in 4-bit mode. The code uses the stock LCD library that comes with Arduino IDE (with some changes, see below in the code section).
The operation buttons are connected via an 8-bit shift register. The original purpose  was to use the shift register to have more outputs available. In the final design only 5 buttons are used, so it can be omitted easily (the code needs to be updated though).
Below is the schematic in image format. For eagle .sch file see here.

Eagle schematics for the coffe timer project

Eagle schematics for the coffee timer project

The schematics was done some time after the circuit was running. The picture of the breadboard may be more accurate.

The parts list is quite short:

  • 1 HD44780 compatible LCD (I used a 2×16)
  • 1 Shift register 74HC165N
  • 5 Momentary touch switches
  • 5 10K ohm resistors
  • 1 1.8K ohm resistor (for the relay)
  • 1 NPN 5v transistor
  • 1 Diode (normal glass ones)
  • 1 5VDC 10A relay (I used a super cheap SSR, 6VDC is also fine). 10A is a real overkill for most uses, a good calculation can be found here

The Code

Download the sources (zip archive) here.

The source code contains two libraries besides the applet itself. First of all, I added two functions to the LiquidCrystal library:

  • setCursorMode – Allows to blink a character. Used when setting the hour/minutes.
  • setCustomChar – The HD44780 controller allows setting up to 8 custom characters. These are used in the alarm symbol and for the coffee mug characters

In the zip there’s are replacement files for LiquidCrystal.h and LiquidCrystal.cpp. To use it, locate the LCD library in Arduino IDE (typically arduino-0015/hardware/libraries/LiquidCrystal/) . Replace the files with the supplied ones, or use a patch.

Another library is supplied in the zip. This library drives the 64HC165N shift register. It should probably work with any 165 style 8-bit shift register. To use, just dump the files in the library path of Arduino IDE (typically arduino-0015/hardware/libraries/).

Finally, the source code that runs on the controller is called CoffeeMan.pde. Open it with the Arduino IDE and download it to your controller.

The code is quite commented. I hope it’s readable. If any more details are required, leave a comment.

What’s Next

This was a nice learning project, but it takes some extra work to refine it for real usage.

First, there are a couple of problems with the design so far. The display used here is too large for practical use. A 2×12 would be suffice. While it doesn’t seem to be a mainstream product, it’s available from several vendors (here, here or in large quantities). Even an 2×8 is enough to show time and some graphics, but it might be a bit too compact.

Another issue is a connector. It seems logical that the relay will reside in the machine, with a cable connected to the controller. One possible option is to use 3.5mm mono jack (like the ones used in microphones).

Last, the board needs to be redesigned as a standalone, this has been done before. A minimal approach is too restrictive in this case, since the circuit will need an external crystal (if the clock is to be anywhere near accurate).
Using an ATMega8 instead of Arduino’s 168 seems very logical, since the codespace used is quite minimal (4K instructions).

Feel free to comment and ask questions.



Filed under coffee, prototype

4 responses to “Making Coffee

  1. We used 2N5109 as the power transistor of the circuit, 1n4004 silicon in place of the glass one, and SN74LS165AN as the IC. it doesn’t work. Tack switches are not working and there is an error with the code. Can you help us?

  2. We are having a problem with the resistor, relay, transistor and diode connection to the relay. There seems to be no voltage drop in those components. What should we do?

    • I would first check the power supply (especially if you’re powering the relay with the Arduino).
      The relay needs a decent amount of current which means you can’t just power the Arduino from a USB port. Try to use a wall wart or a 9v baterry. For more notes on how to power Arduino see this guide and this one.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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