×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Raspberry real time (SOLVED)

  • Posts: 10
  • Thank you received: 1
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
Last edit: 4 years 1 month ago by Juhin Christophe.
4 years 1 month ago #49335

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

  • Posts: 326
  • Thank you received: 50

Replied by Avocette on topic Raspberry real time

The answer to your question is Yes ....and No! Have a look in the Astroberry area of the forum.
4 years 1 month ago #49336

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

  • Posts: 1309
  • Thank you received: 226

Replied by Andrew on topic Raspberry real time

Yes you can. I have my Pi setup to correctly set the system time from GPS. It is a little bit of work to set up. You need GPSD and NTP. The tricky part is configuring GPSD to use the signal time when is greater than 1000 seconds off of the system time.
Install GPSD and NTP and optionally some additional tools.
*Disclaimer, it has been some time since I last set this up and I may miss something below.

<code>sudo apt-get install gpsd gpsd-clients ntp ntpstat</code>

Configure the following:
/etc/default/gpsd
DEVICES="/dev/ttyS0 /dev/pps0"
GPSD_SOCKET="/var/run/gpsd.sock"
# Other options you want to pass to gpsd
GPSD_OPTIONS="-D 5 -n"

/etc/ntp.conf
# Kernel-mode PPS ref-clock for the precise seconds
server 127.127.22.0 minpoll 4 maxpoll 4
fudge 127.127.22.0 refid PPS stratum 0
 
# Server from shared memory provided by gpsd
server 127.127.28.0 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.0 refid NMEA stratum 3 time 1 0.000

/etc/systemd/timesyncd.conf
[Time]
NTP=127.127.28.0
The following user(s) said Thank You: Juhin Christophe
Last edit: 3 years 4 months ago by Andrew.
4 years 1 month ago #49345

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

  • Posts: 437
  • Thank you received: 31

Replied by Paul on topic Raspberry real time

KillRoyCool,

An alternative to uisng GPS is to install a Real Time Clock (RTC) in the Raspberry Pi or to set it manually from the command line.

I have never been able to get my Raspberry Pi to read the RTC but when I have time I will have another go.

Paul
The following user(s) said Thank You: Juhin Christophe
4 years 1 month ago #49347

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

  • Posts: 1208
  • Thank you received: 559

Replied by Hy Murveit on topic Raspberry real time

The easiest, but of course least elegant answer, though is that you can set the time manually (each time you boot).
I have no RTC nor GPS, but rarely use it in the field. When I do, I look at my phone, and then type something like the following

sudo date -s "10 feb 2012 8:57pm"

I believe that's right, but unfortunately I can't test right now.
Google search seems to confirm, e.g.
www.garron.me/en/linux/set-time-date-tim...me-command-line.html
4 years 1 month ago #49348

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

  • Posts: 326
  • Thank you received: 50

Replied by Avocette on topic Raspberry real time

I agree with your manual workaround, but with everything else automated and indi drivers for auxiliary functions like indi_gpsd available, it just seems a shame to be struggling in the dark........
4 years 1 month ago #49349

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

  • Posts: 326
  • Thank you received: 50

Replied by Avocette on topic Raspberry real time

Just wondered if this is unique to the Adafruit GPS Module or would work with a USB GPS dongle? When my USB GPS has worked I have normally set up /etc/default/gpsd with DEVICES="/dev/ttyACM0"
Last edit: 4 years 1 month ago by Avocette. Reason: spelling
4 years 1 month ago #49350

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

  • Posts: 554
  • Thank you received: 138

Replied by Chris Rowland on topic Raspberry real time


Could this be scripted with the time obtained from the INDI device?

I've done something like that in the ASCOM/Windows world.

Or, if your mobile phone has a data connection, use it as a hotspot. That way the internet time would be available through the phone.
4 years 1 month ago #49355

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

  • Posts: 326
  • Thank you received: 50

Replied by Avocette on topic Raspberry real time

I have just made a new installation from the AstroPi3 script on Raspbian (newly updated to 3.2). This does not behave like the older version I have used for some months which did update the system time as well as the KStars time and geographic position from the USB GPS.
I have the feeling that there are several bugs in the latest KStars releases which seem to interact in unhelpful ways. These bugs appear to be identical to those I found in the Astroberry 2.0.1 image so don't seem to have been introduced when Radek was building that image. I am not knowledgable enough to investigate what's going on myself, but if someone wishes me to feedback logs etc. I would be happy to follow instructions......
4 years 1 month ago #49361

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

  • Posts: 1309
  • Thank you received: 226

Replied by Andrew on topic Raspberry real time


Ah, yes, this is just my configuration. You will have to enter your own device location accordingly.
Also it appears one additional aspect I have implemented was missing, a python script that is run at startup via a line in rc.local
github.com/AltJ/gpstime/blob/master/gpstime.py
import os
import sys
import time
from gps import *
 
print 'Attempting to access GPS time...'
 
try:
	gpsd = gps(mode=WATCH_ENABLE)
except:
	print 'No GPS connection present. TIME NOT SET.'
	sys.exit()
 
while True:
	gpsd.next()
	if gpsd.utc != None and gpsd.utc != '':
		gpstime = gpsd.utc[0:4] + gpsd.utc[5:7] + gpsd.utc[8:10] + ' ' + gpsd.utc[11:19]
		print 'Setting system time to GPS time...'
		os.system('sudo date -u --set="%s"' % gpstime)
		print 'System time set.'
		sys.exit()
	time.sleep(1)

This is an alternative method that may work as well.
blog.petrilopia.net/linux/raspberry-pi-set-time-gps-dongle/
The following user(s) said Thank You: Juhin Christophe
Last edit: 4 years 1 month ago by Andrew.
4 years 1 month ago #49378

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

  • Posts: 10
  • Thank you received: 1
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.
4 years 1 month ago #49659

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

  • Posts: 398
  • Thank you received: 117

Replied by Doug S on topic Raspberry real time

A simple and inexpensive solution would be to get a HW based clock for the Pi. See links for a couple of approaches:
www.amazon.com/gp/product/B01A78GA1W
www.raspberrypi-spy.co.uk/2015/05/adding...to-the-raspberry-pi/
The following user(s) said Thank You: Juhin Christophe
4 years 1 month ago #49670

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

Time to create page: 0.550 seconds