A Nursing Clock


Even hobbyist work with electronics requires some serious time investment, and in the last months I didn’t have any excess of it, having all my time divided between work and father duties. Still, I did manage to squeeze a bit of UltiBlink stuff into the latter, making a clock that reminds us of our infants nursing times; and today I found time to finally write about this.

So, a lifetime ago, that in actuality were just some 4 months, I devised a multiplexing 8×8 RGB LED board running off a single DM633 chip, ordered ten of them, received and soldered a couple. It was a prototype, meant to be heavily used to see the defects and improve on them. Thankfully I did assemble one before the child was born. And even programmed some effects into it, as can be seen on the UltiBlink FB page.

In any case, a baby infant needs to be fed every 3 hours (approx.). So, as I had a contraption capable of displaying time, I decided to give it a quick fix in that direction. The idea was to make it usable by the mother who stubbornly refuses to learn my genius RGB clock concept. I did it and am glad that she quickly learned to use it and finds it useful (as evidenced by the fact that she does press the button when I’m away).

So, here it is.

 

1 – The Nursing Reminder

Simple, really. You press the button, the clock counts three hours, then lights up a white LED in the corner of the 8×8 matrix (overlaying a color present there, if any). Then it consequently lights up three more corner LEDs at 20 minutes’ intervals. When four are lit, come on, it’s 4 hours already, the baby is hungry! Simple. Just don’t forget to press the button before nursing.

 

2 – The Clock

The clock is based on the concept already implemented in my 5×3 RGB Clock that I use at home, but in a single most simple and understandable mode. It displays the hour as a digit and minutes as hues gradient (check the link to see the RGB clock main principle).

The problem was with double digits, namely 10, 11 and 12. In my 5×3 clock I use Roman numerals on top of each other. With 8×8 matrix there were more options. The full numbers looked too thin and uncool, the hex notation is dull, so I decided on making full digits half-visible:

Well, after a couple of months use I can say that it’s ok, but 10 and 11 look too similar if something is partially obscuring them (like a flower).

 

3 – The Rest

The clock itself has a battery and runs even if the contraption is disconnected from mains (it uses the DS3231 chip). I needed it to also remember the last time the button was pressed. Atmega328 has EEPROM, but it has a limited lifespan of write/rewrite cycles, so using it was not an option (as it was to be written each time the button is pressed). Thankfully, the DS3231 doesn’t just count time, it also has some registers that can be written and read. At first I thought of encrypting the time into the useless year, month and day registers, but these can change automatically. Thankfully, I remembered to read the datasheet and bingo! The alarm registers:

uint16_t budilo

void setAlarm()
{
 Wire.beginTransmission(0x68);
 Wire.write(byte(0x08));
 Wire.write(decToBcd(minute));
 Wire.write(decToBcd(hour));
 Wire.endTransmission();
}

void getAlarm()
{
 Wire.beginTransmission(0x68);
 Wire.write(byte(0x08));
 Wire.endTransmission();
 Wire.requestFrom(0x68, 2);
 uint8_t alarMinute = bcdToDec (Wire.read());
 uint8_t alarHour = bcdToDec (Wire.read());
 budilo = alarHour*60 + alarMinute;
}

These alarm registers are pretty interesting. They can store time (as needed), they can trigger a signal at stored time, but what’s more, they also can trigger these signals (easily converted into interrupts) at preset intervals like a second, a minute, an hour and so on. Didn’t know about this, can be useful in clocks (in fact, I never needed this feature, as my clocks either don’t suffer from checking time each cycle, or check time in between their animation cycles when using hard floating point arithmetic).

Here’s the datasheet if you don’t have it already.

 

Aahhh, it feels good to be back. Hopefully I’ll be able to appear here more frequently from now on.

Leave a comment

Your email address will not be published. Required fields are marked *