×
INDI Library v1.8.5 Released (19 Apr 2020)

April 2020 release of INDI Library v1.8.5 introduces new drivers while providing fixes and improvements to existing devices and core framework.

Raspberry real time (SOLVED)

3 months 2 weeks ago
gilesco
Expert Boarder
Expert Boarder
Posts: 95
Karma: 1
More
Raspberry real time (SOLVED) #49675

KillRoyCool wrote: good evening everyone

I have a raspberry Pi with KStars Indi Ekos installed on it. Everything works wonderfully in "remote". On the other hand, the drawback of the Raspberry is that it does not have a battery to save the time and the date. As I am in "hotspot" the date and time of the system are at my last internet connection. When I launch KStars, my usb GPS is taken into account and changes the date and time but just for KStars. THE Raspberry is still the old date. THE problem is that my saved photos are at the date and time of the RaspBerry. So here is my question: Can we set the Raspberry on time with the GPS? I did not find anything on the net ...
Thanks


The following chronyd.conf configuration, take the time from whatever is available GPS, Network or whatever, and syncs your system clock to it:
# Welcome to the chrony configuration file. See chrony.conf(5) for more
# information about usuable directives.
pool 2.debian.pool.ntp.org iburst

# This directive specify the location of the file containing ID/key pairs for
# NTP authentication.
keyfile /etc/chrony/chrony.keys

# This directive specify the file into which chronyd will store the rate
# information.
driftfile /var/lib/chrony/chrony.drift

# Uncomment the following line to turn logging on.
#log tracking measurements statistics

# Log files location.
logdir /var/log/chrony

# Stop bad estimates upsetting machine clock.
maxupdateskew 100.0

# This directive enables kernel synchronisation (every 11 minutes) of the
# real-time clock. Note that it can’t be used along with the 'rtcfile' directive.
rtcsync

# Step the system clock instead of slewing it if the adjustment is larger than
# one second, but only in the first three clock updates.
makestep 1 3
refclock SHM 0 offset 0.5 delay 0.2 refid GPS

Taken from the default Astroberry 2.0.1 configuration.

__
I blog my progress: www.coochey.net

Please Log in or Create an account to join the conversation.

3 months 2 weeks ago
avarakin
Expert Boarder
Expert Boarder
Posts: 91
More
Raspberry real time (SOLVED) #49737
Here is another approach which does not require additional hardware: setup laptop as ntp server and get RPi to sync time from laptop.

Please Log in or Create an account to join the conversation.

3 months 2 weeks ago
maxer
Gold Boarder
Gold Boarder
Posts: 260
Karma: 1
More
Raspberry real time (SOLVED) #49782
Hi guys,

I just tried this : www.raspberrypi.org/forums/viewtopic.php?t=161133
I used OSMC for the test and it worked, but it seems that the networkmanager in OSMC is not very happy when booting without any network connection and doesn't bring up the NIC but the time and date is set, I didn't do any debugging about the problem for now so I guess I have to try using Raspian also.

Br,
/Markku

EQ8, Small scope SW200, Big scope SW300, Xagyl FW, Guidescope Celestron 80mm, SX LodestarX2, SXVR-H9.
RPi3, Ubuntu Mate, and many Arduinos..
The following user(s) said Thank You KillRoyCool

Please Log in or Create an account to join the conversation.

3 months 2 weeks ago
maxer
Gold Boarder
Gold Boarder
Posts: 260
Karma: 1
More
Raspberry real time (SOLVED) #49794
I did a try with Raspbian Buster last evening and after updating and rebooting the time and date was correct from the DS3231 module without any network connection.

Br,
/Markku

EQ8, Small scope SW200, Big scope SW300, Xagyl FW, Guidescope Celestron 80mm, SX LodestarX2, SXVR-H9.
RPi3, Ubuntu Mate, and many Arduinos..
The following user(s) said Thank You KillRoyCool

Please Log in or Create an account to join the conversation.

3 months 2 weeks ago
KillRoyCool
Fresh Boarder
Fresh Boarder
Posts: 7
More
Topic Author
Raspberry real time (SOLVED) #49957
Thank you for your answers . I finally opted for an rtc card based on 1307. But if I type sudo hwclock -r the clock is on time but not the system time even after reboot. . If I type sudo hwclock -s the system is set to the correct time but after a reboot I still have the old system time and if I type sudo hwclock -r the time and date are correct. How to have the right time when starting the raspberry? I'm on Ubuntu mate 16.04. Thanks in advance friends

Please Log in or Create an account to join the conversation.

3 months 2 weeks ago
pyb
Fresh Boarder
Fresh Boarder
Posts: 15
More
Raspberry real time (SOLVED) #49958
Hi,

Have a look to this thread : www.indilib.org/forum/stellarmate/6494-i...ate-1-5-0.html#49752 .
Maybe it could help. In your case, you should probably have to replace ...ds3231 by ...ds1307

Pierre-Yves

Pierre-Yves
SW 200/1000, SW 72ED, EOS-100D, ASI-178MC, HEQ5-Pro (Rowan belt kit),
MyFP2ProM/v2.92 focuser, Joystick 8BitDo-N30,
Rpi4/Stellarmate 1.5.2 server, Dell Inspiron 13.3/Linux Mint 19.3

Please Log in or Create an account to join the conversation.

3 months 2 weeks ago
KillRoyCool
Fresh Boarder
Fresh Boarder
Posts: 7
More
Topic Author
Raspberry real time (SOLVED) #49965
Re: The Correct way to add a RTC

Quote
I finally found it. See the penultimate post on page 3:

www.raspberrypi.org/forums/viewtopic.php?p=842661#p842661


Thu Aug 24, 2017 5:54 pm
After searching for a long while, and after a lot of experiments, I've putted togheter all the information I've collected all around the Net about how to connect a realtime clock to the Raspberry and allow the OS use it as system clock even if no connections to a NTP server.
I've used a DS3231, but the following should work even with a DS1307. Just use ds1307 where into the following instructions is used ds3231.

The following, definitively worked for me, using Raspbian Jessie. So:
edit the file using sudo nano /boot/config.txt and add or modify a line that looks like the following:

Code: Select all

dtoverlay=i2c-rtc,ds1307
Edit the file using sudo nano /etc/init.d/hwclock.sh and comment out the content in order to be sure that the content looks like the following:

Code: Select all

#if [ -d /run/udev ] || [ -d /dev/.udev ]; then
# return 0
#fi

Then disable the fake-hwclock and enable the hwclock.sh with the following group of commands:

Code: Select all

sudo apt-get remove fake-hwclock
sudo rm /etc/cron.hourly/fake-hwclock
sudo update-rc.d -f fake-hwclock remove
sudo rm /etc/init.d/fake-hwclock
sudo update-rc.d hwclock.sh enable

Then modify the file using sudo nano /lib/udev/hwclock-set locate the following lines and be sure to comment it out:

Code: Select all

# if [ -e /run/systemd/system ] ; then
# exit 0
# fi

Now, create two system services in order to set the system's clock when the OS boot and also to write to the RTC at the shutdown. So, the first one:

Code: Select all

sudo nano /etc/systemd/system/hwclock-start.service

...and paste in it the following:

Code: Select all

[Unit]
Description=Set time from RTC on startup
After=network.target

[Service]
Type=oneshot
ExecStart=/sbin/hwclock -s
TimeoutSec=0

[Install]
WantedBy=multi-user.target

and the second one:

Code: Select all

sudo nano /etc/systemd/system/hwclock-stop.service

Paste in it the following:

Code: Select all

[Unit]
Description=Synchronise Hardware Clock to System Clock
DefaultDependencies=no
Before=shutdown.target

[Service]
Type=oneshot
ExecStart=/sbin/hwclock --systohc

[Install]
WantedBy=reboot.target halt.target poweroff.target

Finally, enable the services issuing once the following command:

Code: Select all

sudo systemctl enable hwclock-start hwclock-stop

You can also verify that the RTC module has been loaded using

Code: Select all

sudo lsmod

Please Log in or Create an account to join the conversation.

3 months 2 weeks ago
KillRoyCool
Fresh Boarder
Fresh Boarder
Posts: 7
More
Topic Author
Raspberry real time (SOLVED) #49966
It works so fine !
The following user(s) said Thank You maxer

Please Log in or Create an account to join the conversation.

3 months 1 week ago
maxer
Gold Boarder
Gold Boarder
Posts: 260
Karma: 1
More
Raspberry real time (SOLVED) #50032
Hi,

Interesting stuff.. now I even understand why the timesync to hwclock was working sometimes when shutting down the RPi but not at bootup.
I guess all that could be done with the raspi-config script using options to choose fake-hwclock or a RTC-module.

Nice work!
CS
/Markku

EQ8, Small scope SW200, Big scope SW300, Xagyl FW, Guidescope Celestron 80mm, SX LodestarX2, SXVR-H9.
RPi3, Ubuntu Mate, and many Arduinos..
The following user(s) said Thank You KillRoyCool

Please Log in or Create an account to join the conversation.

Time to create page: 0.660 seconds