Tuesday, September 18, 2012

What time is it?

The Pi doesn't have a real time hardware clock, in order to save $$. But that doesn't mean you cant have date returning the correct time.

ntp client is installed by default. All I do when I configure a box is to add a local time provider:

fdion@raspberrypi ~ $ sudo vi /etc/ntp.conf

where it says:
# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
I added:
server clock1.unc.edu

Instead of clock1.unc.edu, choose one that is close to you from this list:

fdion@raspberrypi ~ $ sudo /etc/init.d/ntp restart

[ ok ] Stopping NTP server: ntpd.
[ ok ] Starting NTP server: ntpd.

fdion@raspberrypi ~ $ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
 ns.unc.edu      .INIT.          16 u    - 1024    0    0.000    0.000   0.000
-   2 u    8  128  357   84.964   -7.069  12.917
+a1.hotfile.com   2 u   80  128  367   33.450    1.298   1.592
+ponderosa.piney     2 u    9  128  357   47.021   -2.056  28.562
*clock.team-cymr      2 u   17  128  377   57.341    1.629   4.500

The other thing we have to fix is the timezone. Maybe you are in the right default timezone, but more than likely (statistically more probable) that you are not. So how do we adjust this?

fdion@raspberrypi ~ $sudo dpkg-reconfigure tzdata

Current default time zone: 'US/Eastern'

Local time is now:      Tue Sep 18 18:01:43 EDT 2012.
Universal Time is now:  Tue Sep 18 22:01:43 UTC 2012.


Let me check the LCD display (driven by the GPIO pins):

This particular Pi runs headless, so that's pretty convenient to get the dhcp assigned IP. I do have to make this a little bit more permanent, although I will switch to a different display (which I also have) that will give me a little more feedback. I'll post about how to do all this soon enough.

No comments: