Send GPS coordinates every 5 minutes to a server

Helo,

I want to build me a script, that sends my GPS coordinates to a server. The server receives them and saves it in a database.

For example:

  • Send (44.3232, 34.4432) to a PHP Script to http://[myserver.com]/gpsscript.php?x=44.3232&y=34.4432
  • Receive it and save it in a database.

I can use cronjob to run the script. The case is that’s not a problem to save it, but I don’t know how to get the GPS coordinates on Librem 5 by a script.

Can you help me?

3 Likes

Probably easiest to create a text file with the data logged and then upload it to a cloud drive or something like that, such as Proton Drive.

1 Like

I once did this with a shellscript.
In the end it wasn’t very difficult, everything was put directly into the format that the google maps api wanted.i think i uploaded it as gpx files and a php script displayed it on the server side.

I can search my hard disk to see if I can find any if you want.

1 Like

You can read the GNSS information stream directly from /dev/gnss0
?

Of course then your script would have to wait for a GNSS fix i.e. read and parse until you either get valid coordinates or you give up. (Is the assumption that you are outside while this happens? Have you confirmed that you ordinarily do get valid coordinates?)

Do you care about altitude?
Do you care about timestamp? (I understand that the server side can capture some kind of timestamp provided that the data is communicated immediately from the Librem 5 to the server.)

1 Like

Just out of curiosity, is your script transferring your location info in plain text online?

To take this further: an L5 / linux phone app (GUI) that let’s user send location safely to server(s) or apps (sms) and set the parameters (how often and maybe using some events, like logging in and taking a photo etc.). There is need for something similar, as has been previously discussed. So, if someone does a script, why not take it a bit further…

1 Like

If you Python then the script linked from another topic: Random GNSS enquiry may be a good starting point.

1 Like

Yes plain text.

1 Like

I only want to get Latitude and Longitude.

1 Like

I’d rather use:

sudo socat unix:///var/run/gnss-share.sock -

as this won’t cause troubles with multiple applications using the GNSS module simultaneously.

4 Likes