Close

More operational suggestions

A project log for Raspberry Pi Zero W desk clock

An LED desk clock driven by NTP on a Pi Zero W

nick-sayerNick Sayer 03/07/2017 at 05:100 Comments

For those who want to alter the timezone for the display, I've tested this and it works: you can set the TZ environment variable as is traditional on *nix. For example, if you want a UTC display, you can

export TZ=UTC

and then run the clock executable and the display will show UTC.

When you add the clock executable to /etc/rc.local (or take other steps to run it automatically on startup), you may notice that it starts by showing the wrong time (usually some time in the past) for a little bit, and then snaps to the correct time. This is because (normally) the Raspberry Pi has no RTC hardware to keep the time when the power is off. If you allow the pi to shut down gracefully, it will write the current time to a file and use that during boot. The clock will be wrong by however much time it was off, but the benefit to this method is that the clock will never go backwards (as it would if it started at time zero every boot).

If this isn't good enough for you, you can add an i2c RTC clock (the easy way is with a breakout board) and that will allow it to preserve time across power loss.

Discussions