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.
To set the alarm, click the display button. Then set the time similar to the way done with the clock.
To toggle the alarm on, click the alarm button.
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.
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
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.
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.