Both my birdbox systems and my Portable (garden) PiCam need to know the time & date in order to properly time-stamp video clips and events.
Up until now I have relied upon an old HP Compaq D510 to help set the correct time, but I’ve finally got around to replacing this with a not quite so old Pi B v1 Rev1.
Although the D510 was quite economical, my Pi replacement should consume less than 5% of the power of its predecessor.
My garden Pi camera systems are on a closed network, so cannot take advantage of any internet time services. I solved this problem last year by manually setting the time/date on an old D510 located in our garage, and set the system to write the current date/time into a text file every 60 seconds using cron (see: Updating Time).
I have six D510s that I saved from a skip back in 2009, but the time has now come to send them all to calculator heaven.
I need a Real Time Clock
The first step was to fit an RTC to my oldest Pi. I already had a DS1302 RTC module, so I loaded this to a small piece of strip-board and added a long pin header.
The wiring details and basic software are the same as for my earlier RTC post. I renamed the RTC compiled C code “setClock” and copied it to a location on the system path (i.e. /usr/bin).
However, I wanted a GUI to make it easy to adjust the time when I need to remote into this headless server and put the clock right.
The Gambas Interface
I wrote a very simple Gambas app which looks like this:-
When the Pi time server starts, this Gambas app sets the Pi to the current RTC time using the setClock C program from my earlier post.
Public Sub _new()
Exec [“setClock”] ‘run the RTC “C” program setClock
‘this sets the system time to the current RTC time
The user interface allows me to change the date and/or time.
Public Sub btnResetTime_Click()
‘User can manually update RTC time
strTimeDateSetting = Format(DateBox.Value, “yyyymmdd”) & Format(TimeBox.Value, “hhnnss”)
lblStatus.Text = “Time reset to: ” & DateBox.Value & ” ” & TimeBox.Value
lblStatus.Text = lblStatus.Text & ” >>> String: ” & strTimeDateSetting
btnResetTime.Enabled = False
Public Function SetPiClock() As Boolean
Exec [“setClock”, strTimeDateSetting]
However, I don’t expect the DS1302 RTC to drift too far between now and the end of summer.
Pi Camera System Config
The original configuration is described in this earlier post. The only change to the Raspberry Pi camera system is to edit the IP address in /etc/fstab so that they now mount the Pi rather than the D510.
For more detail: RaspberryPi Simple Time Server