Astrofriend's homepage

www.astrofriend.eu
Share: Twitter Reddit Facebook Gmail Gmail Email
Search Astrofriend's homepage:

Valid CSS!

All pages shall now have been validated

Info Cookies (Kakor) / GDPR

Navigation

Advertisement /
Annons:

Advertisement / Annons:

My astronomy project:
Setup KStars with GPS


Content:

  1. KStars GPSD, 64-bit OS
  2. KStars GPSD, 32-bit OS
  3. KStars NMEA, 32-bit OS
  4. To be continued

Related projects:

Note:
I take no responsibility or liability for what are written here, you use the information on your own risk!


1, KStars GPSD, 64-bit OS:

Overview:

If you always have your observatory at a stationary place with LAN connection there is no need for a GPS. But I who take the car and drive to remote dark places have a need for the GPS clock and location. The GPS installation has always been difficult, maybe easier now with the more up to date OS 64-bit Bookworm version and KStars/Ekos 64-bit.

I follow this instruction partly that is told to work with Raspberry Pi5 and KStars 64-bit:

Older information about KStars and GPS:


GPS device:

Raspberry Pi5, KStars 64-bit, setup GSPD

The GPS dongle I use is the recommended U-blox7. It works much better than the earlier ones I have tried. But one disadvantage, it's sensitive to electro magnetic disturbance. I can't attach it direct to the Raspberry, I must have some distance between them. An extension USB cable of 0.5 meter solve the problem. I have also placed it on the opposite side of the telescope to where the Raspberry is placed.


Find the USB GPS port:

Raspberry Pi5, KStars 64-bit, setup GSPD

To setup it correct we must know which USB it's connected to. Disconnect the USB cable and give this command in the terminal window:

  • ls -l /dev/tty*

And then connect the USB cable again, note which new line that appear. In my case it's the port /dev/ttyACM0 that the USB GPS connect to.

As always before installing some new software, update the system before:

  • sudo apt update && sudo apt upgrade
  • sudo reboot

Installing indi-gpsd:

I noticed that this driver was already installed in my KStars 64-bit package. If not in your case, do the following.

Raspberry Pi5, KStars 64-bit, setup GSPD

The command below installs the indi-gpsd:

  • sudo apt-get install indi-gpsd

After one third of the installation it ask you if you want to proceed, type: Y (yes) and Enter.


Activate GPSD software and driver:

Raspberry Pi5, KStars 64-bit, setup GSPD

In the profile I have setup in KStars I add GPSD. GPSD is the driver that communicate with the GPS device. I add it on Aux 1. You find GPSD under "Others" devices.


Raspberry Pi5, KStars 64-bit, setup GSPD

GPSD is activated, if it's okay, Save.


Install gpsd:

Raspberry Pi5, KStars 64-bit, setup GSPD

The three following commandos do the rest of the installation, enable and restart:

  • sudo apt install gpsd
  • sudo apt install gpsd-clients

The following two software I'm not 100% sure that they are needed, anyway I installed them:

  • sudo apt install libgps-dev
  • sudo apt install libindi-dev

Enable and restart the system:

  • sudo systemctl enable gpsd
  • sudo systemctl restart gpsd

Setup GPSD file (old procedur):

Follow the instructions in the link above.

You can use this command to edit the file:

  • sudo nano /etc/default/gpsd
Raspberry Pi5, KStars 64-bit, setup GSPD

How I setup the GPSD file, but it will be different in your setup. In my case it's not ttyUSB1, it's ttyACM0 (old screen dump):

  • START_DAEMON="true"
  • DEVICES="/dev/ttyACM0"
  • GPSD_OPTIONS="-n"
  • USBAUTO="true"

When you find it correct, quit with Ctrl X, type Y (yes) and Enter.

After changes of GPSD setup a restart must be done:

  • sudo systemctl restart gpsd

Here are more information about GPSD:


Setup GPSD file (new better):

My GPS is the U-Blox7 which is recommended but I got a lot of problem with the system clock sync and location. It ended up with another setup of the GPSD.

You can use this command to edit the GPSD:

  • sudo nano /etc/default/gpsd
Raspberry Pi5, KStars 64-bit, setup GSPD

How I setup the GPSD file, but it will maybe be different in your setup:

  • START_DAEMON="true"
  • DEVICES="/dev/astro_gps_ublox7"
  • GPSD_OPTIONS="-F /run/gpsd.sock -n"
  • USBAUTO="true"

The "F" create the gpsd.sock file which is essential for the GPS Location in KStars. When you find it correct, quit with Ctrl X, type Y (yes) and Enter. A friend had to help me with this to get it correct, complicated.

This time I used the udev rules, a smarter way to address the devices if it's complex with many serial devices. Instead of: DEVICES="/dev/ttyACM0" which direct address it to a unique port I have setup it to a new name with some rules behind: DEVICES="/dev/astro_gps_ublox7".

Here are information how to use udev: udev rules . Main purpose is to make it independent where you connect your USB cables, it will find it anyway.

After changes of GPSD setup a restart must be done:

  • sudo systemctl restart gpsd

After this the GPS with GPDS and Chrony set the system clock and KStars set the location at startup. But there is a problem, every time the Raspberry is started up the location is lost in GPSD. I have to do a restart every time after it has started up. It's because of a bug in the GPDS, I have the version 3.22. It will be corrected later when doing an update, until then use the restart of gpds.

More information about the needed update of GPSD:

If you have to give a command often you can make a script for it: Make a Script .

Here are more information about GPSD:


Test of GPS receiver:

To listening to what the GPSD get from the GPS receiver, type this commando:

  • cgps -s
Raspberry Pi5, KStars 64-bit, setup GSPD

A first test if the GPSD receive any data, this normally never works, to my surprise it connect to the satellites and receives data. Normally you need at least three satellites with a "Y" to have a location, but five or more is better.

Quit with "Ctrl+C"

Other tools, stop with "Ctrl C":

  • xgps
  • gpspipe -r
  • gpsmon

The commando gpsmon listen direct to the GPS what it send to GPSD.


Install Chrony:

From Astroberry version 2.0.1 it use the Chrony to sync the system clock with GPS data. Much easier now to get it to work. Earlier if the system clock was wrong KStars was set with an offset to the system clock. That's fine for the most thing you do. But when doing Polar Alignment I got a lot of problem, I think it use the system clock direct and don't correct with the offset. I setup up Chrony to set the system clock direct to get rid of this problem. Chrony isn't installed normally and you must install it. A bit complicated and asked a friend for help.

Be sure to have Raspberry and KStars updated to latest version.

Install Chrony with:

  • sudo apt-get install chrony -y

Check that service is running:

  • systemctl is-active gpsd
  • systemctl is-active chrony

If correct installed both shall give a "active" as answer.

Setup Chrony:

Raspberry Pi5, KStars 64-bit, setup GSPD

To get it to work you normally has to add this line in the chrony.conf file. Place the line at the end of file.

Edit the file /etc/chrony/chrony.conf according to this (GPS time through GPSD):

  • refclock SHM 0 refid GPS offset 0.9999 precision 1e-1 delay 0.2

Look at the example above how I have done it. SHM 0 is the shared address GPSD send its data to Chrony.

Open the chrony.conf with the text editor nano with this command:

  • sudo nano /etc/chrony/chrony.conf

Copy the command above. In terminal window you can't use the mouse, use the arrows on the key board, right click and past.

Quit with Ctrl X, type Y (yes) and Enter to save.

Restart Chrony:

After changes of chrony setup a restart must be done:

  • sudo systemctl restart chronyd.service

Test if synched:

Test if it's synced, in the terminal window give this command:

  • sudo chronyc sources
Raspberry Pi5, KStars 64-bit, setup GSPD

This is what I got, first line (GPS) has time=0, it shouldn't be 0, something wrong.

With this command you can see what GPSD sending out:

  • sudo ntpshmmon

It should be something like NTP0 (SHM 0) in the text string, that is what address Chrony listening to. After I fixed the problem it looked like this:

Raspberry Pi5, KStars 64-bit, setup GSPD

Only the first line is important, the other four lines comes from internet because it's connected to internet. If the GPS work it should have some figures for the time. Chrony choose the time with best quality, if not internet connected it's only GPS there.


Clean up installation:

Raspberry Pi5, KStars 64-bit, setup GSPD

To clean up after the installation, type in following command:

  • sudo apt autoremove

Reboot your Raspberry.


INDI Control Panel:

Open: INDI Control Panel>GPSD>Main Control

Raspberry Pi5, KStars 64-bit, setup GSPD

Next check if there is any time and location data received there from the GPS. It connects after less than a minute, it looks like the new OS 64-bit is updated and work.

Note:
System Time update is set to Never, because the GPS/GPSD/Chrono set the system clock direct.


Raspberry Pi5, KStars 64-bit, setup GSPD

In the Options menu. Set your location, this is used if you don't get any GPS data. Note: I don't give the exact position, easier then to know If there is real GPS data or only default data. As time source click the System. KStars only take the Location information from the KStars/GPSD. Don't forget to Save.


Sources Time and Location:

There are more, open the Ekos>Mount tab.

Raspberry Pi5, KStars 64-bit, setup GSPD

In later versions of Ekos these GPS settings has been moved from Indi to the Mount tab.

With the latest changes with Chrony:

  • Unmark Time
  • Mark Location, Set GPSD

Because Chrony set the system clock with GPS data direct. This is done even if KStars isn't running.


KStars' star chart:

Raspberry Pi5, KStars 64-bit, setup GSPD

Check in the KStars star chart that it use the GPS Location. This test is done without connected to internet. If it hasn't lock to the GPS location, try to do a restart of GPSD, see above at setup GPSD.

Go Back to content

Go Back
To page II

Advertisement / Annons: