Configure RTC DS3231

rtc ds3231 rtc ds3231 rtc ds3231

Yodeck Players do not include an on-board real-time clock. What does that mean? It means that if your Player is offline for a prolonged period of time, it might lose track of time, and scheduling features might not behave correctly.

The Problem

The Players (based on Raspberry Pi) do not have an RTC (Real Time Clock) module on board.

The cost of the RTC is fairly low (you can find them on eBay ), but it needs to be considered if your deployment is time-critical.

rtc ds3231

The Technical Details

Two clocks are important in Linux: the ‘hardware clock,’ also known as RTC (Real Time Clock), CMOS or BIOS clock, and the ‘system clock.’

  • The RTC is a battery-backed clock module connected to the Player’s GPIO ports (Raspberry Pi) that keeps time even when the Player is shut down (or has no power).
  • The second clock is called the ‘system clock,’ maintained by the operating system, Linux in our case.

At boot time, the hardware clock is used to set the system clock, and from that point onwards, the system clock is used to track time. At regular intervals and shutdown, the system time is used to set the hardware clock to ‘save’ the time between reboots.

Without an RTC, the Player saves the current time on the SD card every hour. If there is a power failure, it will load the last time recorded on the SD card when the Player boots. It will then sync its time from the Internet NTP (Network Time) servers, or as a backup, our servers. But if there is no Internet access, the Pi will not sync time, so its clock might be off (from minutes to hours, depending on how long the power failure lasted). This will affect Scheduling, not content playback.

Configuring the RTC clock on a Yodeck player

To use the RTC module with Yodeck, in the monitor settings:

  • Enable the “Allow Raspberry config.txt Override” toggle.
  • In the “Raspberry config.txt Override Directives” field, enter the following directive:
    dtoverlay=i2c-rtc,ds3231
  • In the “Advanced Player Directives” field, enter the script (this is a single line of text):
    yodeck_run_custom_script=IyEvYmluL2Jhc2gKaWYgISBncmVwICdeaHdjbG9jayAtcycgL2V0Yy9yYy5sb2NhbDsgdGhlbgogICAgc2VkIC1pICdzL15leGl0IDAvaHdjbG9jayAtc1xuZXhpdCAwL2cnIC9ldGMvcmMubG9jYWwKZmkK

    Make sure that it is a single line, without spaces or line breaks.

After clicking the “Save” button, the player will automatically pick up the new configuration, apply it, and automatically reboot. After the reboot, the RTC module will be available on the system, and the time will be automatically set on boot. In any case, if the network is available, the time will sync with the default Debian NTP servers and our service.

The custom script essentially is a software hook that allows for custom configuration scripts to be used on the player. It just adds the command hwclock -sin /etc/rc.local, which will read the time from the RTC and set the boot system time.

You might need to check that the RTC module has the correct time by running sudo hwclock -r(the command should return the correct time). Otherwise, you can run sudo hwclock -wto update the saved time of the RTC using the system time. You can SSH the player by following this guide here .

Connection Diagram

rtc ds3231 connection diagram