Juhin Christophe thanked Paul in topic Raspberry real time 3 months ago

Juhin Christophe replied to the topic 'Raspberry real time' in the forum. 3 months ago

It works so fine !

Read More...

Juhin Christophe replied to the topic 'Raspberry real time' in the forum. 3 months ago

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

Read More...

Juhin Christophe is friends with gehelem

Juhin Christophe replied to the topic 'Raspberry real time' in the forum. 3 months ago

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

Read More...

Juhin Christophe replied to the topic 'Raspberry real time' in the forum. 4 months ago

Thank you for your contributions . But none of the solutions work for me. I am running Ubuntu Mate 16.04 with a Raspberry 3B +.
In hotspot, I will continue to set the time manually.

Read More...

Juhin Christophe created a new topic ' Raspberry real time' in the forum. 4 months ago

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

Read More...