The origin story of this project is a bit unusual. We didn't really need an alarm clock, but we wanted to try out an OLED screen, some encoders and an MP3 player. The alarm clock seemed to be a perfect little "test drive" project. Oh, and we had a metal tea can and a fancy emergency stop button. Perfect for an industrial look and feel...
This was supposed to be a weekend project but it somehow got stretched a bit... Into almost eight weekends. The main functionality of an alarm clock is trivial - measure time and play an alarm sound when the alarm time is reached. And it wasn't the main functionality that stretched the project's duration so much. It was all the small things that make the device actually usable - the enclosure, the knobs, the display, recharging etc.
We started off with a red, metal, tea can that we painted black (not without some difficulties):
The can seemed perfect as it had the right size and could be easily opened. It was also quite stiff to provide a sturdy enclosure for the device.
Next, we connected all components together on a breadboard:
The connections diagram below, depicts how all the components were connected to each other:
We decided to use two knobs with encoders - one for setting hours and the other for minutes - and a three-state rotary switch. The switch would allow the user to set the mode of operation to either "regular", "set time" or "set alarm". Then there was the big push button at the top of the can that would arm the alarm and disarm it. We wanted to try out an OLED display so we decided to use a 1.3", blue SH1106 OLED display to show the time and device state icons (e.g battery status). The alarm sound was supposed to fit the industrial look of the device so we found an MP3 with submarine diving alarm on SoundBible (the sound was recorded/synthesized by Daniel Simon). To play this MP3 we employed a DFPlayer Mini module connected to a 0.25W speaker (a bit too weak actually, but small enough to fit into the can with all the other components). As a micro-controller, we chose to go with the Arduino Pro Mini (3.3V, 8MHz). Finally, we wanted this gadget to run off a battery so we included a 2500mAh LiPo battery, a charging module and a barrel socket for easy recharging:
The biggest challenge was to get all those "user interface" components to fit nicely together. We wanted the knobs to be mounted on the front side of the device, just under the display and above the mode switch. Initially, we considered mounting all those components separately onto the front side of the can but it quickly became apparent that this approach wouldn't work too well as the knobs required a thicker surface to be mounted on and the display required four screws and some space between its board and the surface it was to be mounted on. Hence, we decided to cut a piece of PCV - more or less the size of the whole front side of the device - and mount the display and the knobs to this PCV. We would then mount the PCV inside the device using the openings for knobs and the nuts that came with them. The display would be mounted only to the PCV which eliminated the need for drilling more holes in the tea can and we ended up with a clean, no-bolt look. The PCV also turned out to be a great template for making openings in the can:
After drilling the holes for the knobs, we were able to mount the PCV to the front of the can and use it to drill/cut the remaining openings exactly where we needed them:
We ended up with with four openings in the can's front and a PCV with display mounted onto it (shown below with other components laying around):
The PCV fitted nicely inside the can along with the speaker that we mounted on the bottom with a piece of double sided bonding tape:
The next phase was to assemble the board with Arduino Pro Mini and the DFPlayer module:
The board has 18 pins on its side that connect the Arduino and the DFPlayer to all external components. There's also a special two-pin socket for connecting the battery. The four pins on the Arduino Pro Mini are used only for programming and are usually left disconnected.
There are quite a lot of wires inside that can:
The battery is mounted on the side of the can. The charging module is mounted on the battery and a special connector was used to connect the battery to the micro-controller. The connector reduces the risk of accidentally inverting the current:
In the back of the alarm clock, there's only one small component - a barrel jack socket for connecting the power supply:
After mounting all the components inside the can, we could finally start to do some trials. But before that, we needed to program the Arduino Pro Mini. This version of Arduino board does not have a built-in USB-to-Serial converter so programming it requires using an external converter. Such a device communicates with the PC via a USB cable and with the Arduino board via a four-pin connector. We've intentionally made this four-pin connector on our Arduino Pro Mini easily accessible as we expected that, at least initially, the firmware will need to be installed quite often (and boy, were we right on this one). Hence, to program the alarm clock, we only need to remove the top lid and connect the four-wire cable from the converter:
With the firmware installed, we could finally start the trials... The first working prototype used large fonts for displaying time:
This looked good, but had a surprising downside of being too bright at night. Those few digits could lighten up a whole room... We tried reducing the brightness of the display, but unfortunately the driver for SH1106 only allows to reduce the brightness by a very small amount so we decided to use smaller fonts and ended up with this:
Which at night looks like this (the light behind the device comes from an external source and is not generated by the alarm clock):
This is fine, but less readable than the bigger font. This leaves us with two options:
- Create a new font - large so it is readable but also thin so it will not emit too much light
- Revert to the large font but cover the display with some semitransparent, dark film
We haven't decided on the solution yet...
All in all, the device works as we expected. It displays current time - although is a bit off and needs some tweaking - and plays the alarm sound at the specified time. The battery lasts for about four days which is less than we hoped for but acceptable, especially considering how easy it is to recharge it. The user interface is superb - the knobs are great for setting numerical values and the big push button on the top does its job perfectly. The display was also a pleasant surprise. It has a very good contrast (as one would expect from an OLED display), is bright (maybe even too much) and is easy to control from Arduino code. Its downsides are poor contrast/brightness control and a relatively large power consumption. We've also gained experience with playing MP3s through small speakers and with working with metal cans. This may come in handy quite soon...
There are few issues that need some work:
- Alarm volume: The current alarm isn't bad but for a real "industrial" alarm clock, the sound should be more... alarming.
- Time precision: The device does not use a hardware timer, relying instead on the Arduino Pro Mini and its internal clock. This is not the most exact clock on the planet. We have implemented a time correction mechanism but it is rather basic.
- Display's brightness: already described earlier.
Alarm MP3 by Daniel Simon (obtained from SoundBible):