Home Forums Game Frame Hardware Modding RTC integration for time keeping while unplugged

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #878
    Special-K
    Participant

    I was thinking about the GF clock firmware, and the fact that it won’t retain the current time through a power-off event. It reminded me of an Arduino powered clock I have, which uses an RTC breakout board with battery to resolve this particular problem. Specifically, they used a ChronoDot (link), but there are others.

    The physicals connections are fairly simple. Aside from VCC and GND, there is only the I2C data and clock pins. Since I don’t have details on what Arduino is being used, It’s hard to say if this is doable. Perhaps Jeremy could provide a hint?

    I also don’t know how much of a space crunch there is in the onboard flash. In practice, setting and retrieving time from the RTC can be done with the Wire library alone, but if there’s enough room, there’s an RTC specific library that can also be leveraged (link). Given that the Game and Clock modes cannot be present in flash due to size restriction, space is obviously a factor. The question is, just how much of space crunch exists with the Clock firmware?

    #882
    Jeremy Williams
    Keymaster

    Well, for most people, adding a battery isn’t going to be an option. I tied both of the battery pins to ground, as suggested if you don’t incorporate a battery. That said, if one were dedicated, they should cut the pins off of the RTC chip itself and solder battery leads to them instead. There is almost certainly enough space in Flash to add a check to see if the clock is set or not on boot (currently compiled sketch size: 30,796 bytes of a 32,256 byte maximum).

    Sorry if this is a hassle. It really does draw minimal power on low brightness setting, and barely anything when the display is turned off (.5 Watt), so leaving it plugged in seems practical.

    #1348
    Eric
    Participant

    Mine is plugged in 24×7 in my office/alternate media room, prominently displayed. I had the same idea to add an RTC after losing the time during power on/off. Some folks (my daughters) say it is too bright, so I turn it off when they are in my office for an extended period. I haven’t explored the menu options enough, evidently, as I didn’t know I could lower the brightness.

    Great to learn learn it has an RTC already. I’m not really worried about power draw, it’s more the ability to keep the time between power outages, toggles, etc. Would also love to auto dim at night, which sounds like an easy software mod I’ll explore.

    I’m getting ready to move from “stare at its awesomeness” to “hack at it” mode, so I’ll pull the board and look at the RTC chip and pins.

    #1349
    Jeremy Williams
    Keymaster

    Here’s a quick diagram of how I think you would do it. I’ve never actually tried it, but this is how it should work. Only the one pin needs to be severed, but it’s very important that it not touch the PCB or it will be grounded. The soldering job is not for the weak of heart. Ideally you would use a hot air rework station to remove the DS1307 chip, bend that battery pin upwards, and then reattach the other pins to the PCB as before.

    If anyone tries this, let me know! I’d be happy to provide you with some customized firmware to support it.

    Attachments:
    You must be logged in to view attached files.
    #1384
    onkel
    Participant

    I have made the hardware hack.

    Please share the customized firmware to support the DS1307 with battery.

    #1385
    Jeremy Williams
    Keymaster

    Very cool, onkel! I’ll try to get something written tonight but I’ve come down with a cold so fatigue may get the better of me. I’ll follow up here when it’s ready.

    #1388
    onkel
    Participant

    Never mind. I guess i found that you just need to replace “adjustClock()” with:

    if (!rtc.isrunning()) rtc.adjust(DateTime(__DATE__, __TIME__));

    Testing this tomorrow.

    #1389
    Jeremy Williams
    Keymaster

    I don’t think that would do it, exactly. There’s a boolean that tracks whether it’s been set. Try the attached project and let me know if it works. If it does, I’ll push the changes to GitHub.

    Attachments:
    You must be logged in to view attached files.
    #1391
    onkel
    Participant

    Your code did not work but i fixed it by replacing the code in adjustClock() to:

    if (rtc.isrunning()) {
    now = rtc.now();
    rtc.adjust(DateTime(now.year(), now.month(), now.day(), currentHour, currentMinute, currentSecond));
    } else {
    rtc.adjust(DateTime(__DATE__, __TIME__));
    }

    This way the RTC is set to DATE/TIME when you first flash the firmware and after you can use the manual clock setting to adjust hour/minutes using the current date.

    #1394
    Jeremy Williams
    Keymaster

    I just attached a battery to my breadboard Game Frame and my code worked exactly as intended. Can you describe what you mean when you say it didn’t work?

    With my code, you do have to set the time once, but after that it retains the time between power cycles. Your code change to adjustClock() will set the time to compile time rather than ask the user to manually set it. At best, this will be a second or two behind (since it’s not actually set until after compile, when the board reboots and runs code), and it will revert to compile time if the battery dies or is removed (rather than ask the user to reset the clock).

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘Hardware Modding’ is closed to new topics and replies.