maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

getting gps to work on raspberry pi 3

Sat Apr 06, 2019 1:01 am

I have a raspberry pi 3 , rpi gps add-on v2.0 and antenna gps 900-1
if i run

Code: Select all

cgps -s
says "No Fix". and this message appears in terminal

Code: Select all

cgps: caught signal 2 
and if

Code: Select all

 gpsmon
says

Code: Select all

 tcp://localhost:2947          JSON slave driver>
(84) {"class":"VERSION","release":"3.16","rev":"3.16-4","proto_major":3,"proto_minor":11}
(32) {"class":"DEVICES","devices":[]}
(122) {"class":"WATCH","enable":true,"json":false,"nmea":false,"raw":2,"scaled":false,"timing":false,"split24":false,"pps":true}
however

Code: Select all

sudo gpsmon /dev/serial0
shows the GPS data then turns off and it's just message

Code: Select all

Read error from device
any solution?
I dont know how to fix it...

and thank you in advance

DirkS
Posts: 9845
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: getting gps to work on raspberry pi 3

Sat Apr 06, 2019 5:54 pm

maha1 wrote:
Sat Apr 06, 2019 1:01 am
rpi gps add-on v2.0
Exactly which add-on is that? There are quite few GPS boards...

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Sat Apr 06, 2019 8:58 pm

model : IM150627005

fruitoftheloom
Posts: 19826
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: getting gps to work on raspberry pi 3

Sat Apr 06, 2019 9:11 pm

maha1 wrote:
Sat Apr 06, 2019 8:58 pm
model : IM150627005

:?:

https://www.itead.cc/wiki/RPI_GPS_ADD-ON_V2.0
adieu

My other Computer is an Asus CS10 ChromeBit running Chrome Operating System.
HP Envy 4500 Wireless Printer supported by HPLIP software in Raspbian Buster.
Raspberry Pi Model 2B v1.1

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Sat Apr 06, 2019 9:16 pm

yup that's it

User avatar
NGC6543
Posts: 75
Joined: Thu Feb 28, 2019 7:30 pm
Location: Lancashire, UK

Re: getting gps to work on raspberry pi 3

Sat Apr 06, 2019 9:37 pm

Did you follow any guide on setting it up?
Have you disabled the console access on the serial port?
Have you installed gpsd?

Most of the instructions on the 'net work for most GPS modules. You should be able to cat the NMEA strings without installing anything, as a first test, once you've disabled shell access on the serial port and rebooted.

Code: Select all

stty -F /dev/serial0 raw 9600 cs8 clocal -cstopb
cat /dev/serial0

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Sat Apr 06, 2019 11:47 pm

yes i followed a guide on setting it up and i ve been looking for a solution the last two days

i used those lines to disable

Code: Select all

 sudo systemctl stop gpsd.socket
 sudo systemctl disable gpsd.socket

sudo systemctl stop [email protected]
sudo systemctl disable [email protected]
yes i installed gpsd , disabled shell access on the serial port
and i made a try with those lines too

Code: Select all

stty -F /dev/serial0 raw 9600 cs8 clocal -cstopb
cat /dev/serial0
but still not working

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Sun Apr 07, 2019 4:46 pm

i ve just known that my raspbian version is 9 (stretch)
does this make any difference ?

User avatar
NGC6543
Posts: 75
Joined: Thu Feb 28, 2019 7:30 pm
Location: Lancashire, UK

Re: getting gps to work on raspberry pi 3

Sun Apr 07, 2019 5:28 pm

I'm on Stretch (with recommended software).

I'm new to the RPi and Linux in general, so if anyone else wants to step in they can probably help more. However, the second thing I did with mine, last week, was set up a GPS module and configure the Pi to use the PPS output for the time source for ntp. I then did it again with a second Pi and different module, so I should hopefully have some clue :lol:

The first thing is to make sure you actually have a serial data stream. No other software is required. The Pi has two serial ports

/dev/ttyAMA0 - hardware UART for Bluetooth support
/dev/ttyS0 - software UART on GPIO 14+15

I think there are aliases to those names as well. Once you disable console access on tty, and with nothing else running and hogging the port, you should be able to cat the serial stream. If not, something is wrong. Maybe the serial ports have been swapped - I actually did that, to put the hardware UART on GPIO14,15 for my GPS module. If you don't get the NMEA strings on either port, then the only thing I can think is that you don't have a connection or the module isn't talking.

This is one of the guides I read. Try going back to the start of your setup, and go through the serial port setup and test here. The link should take you to the exact start point on the page:

http://www.unixwiz.net/techtips/raspber ... tml#gpshat

User avatar
rpdom
Posts: 14483
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: getting gps to work on raspberry pi 3

Sun Apr 07, 2019 5:51 pm

NGC6543 wrote:
Sun Apr 07, 2019 5:28 pm
The Pi has two serial ports

/dev/ttyAMA0 - hardware UART for Bluetooth support
/dev/ttyS0 - software UART on GPIO 14+15
They are both hardware UARTS.

One is a fully featured UART. The other is a mini-UART with fewer features. It also has the disadvantage that its timing is derived from the system clock and will change when the CPU changes speed.

User avatar
NGC6543
Posts: 75
Joined: Thu Feb 28, 2019 7:30 pm
Location: Lancashire, UK

Re: getting gps to work on raspberry pi 3

Sun Apr 07, 2019 5:58 pm

rpdom wrote:
Sun Apr 07, 2019 5:51 pm
They are both hardware UARTS.
Thanks for the correction :)

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Sun Apr 07, 2019 6:30 pm

NGC6543 wrote:
Sun Apr 07, 2019 5:28 pm
I'm on Stretch (with recommended software).

I'm new to the RPi and Linux in general, so if anyone else wants to step in they can probably help more. However, the second thing I did with mine, last week, was set up a GPS module and configure the Pi to use the PPS output for the time source for ntp. I then did it again with a second Pi and different module, so I should hopefully have some clue :lol:

The first thing is to make sure you actually have a serial data stream. No other software is required. The Pi has two serial ports

/dev/ttyAMA0 - hardware UART for Bluetooth support
/dev/ttyS0 - software UART on GPIO 14+15

I think there are aliases to those names as well. Once you disable console access on tty, and with nothing else running and hogging the port, you should be able to cat the serial stream. If not, something is wrong. Maybe the serial ports have been swapped - I actually did that, to put the hardware UART on GPIO14,15 for my GPS module. If you don't get the NMEA strings on either port, then the only thing I can think is that you don't have a connection or the module isn't talking.

This is one of the guides I read. Try going back to the start of your setup, and go through the serial port setup and test here. The link should take you to the exact start point on the page:

http://www.unixwiz.net/techtips/raspber ... tml#gpshat
@NGC6543 thanks for the link
i followed it and i noticed that the root in /boot/cmdline file is different, mine is root=/dev/mmcblk0p2

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator$

but in instruction root=/dev/mmcblk0p7
and in the next step ,i dont need Bluetooth so i added those lines in /boot/config.txt

Code: Select all

# Use the /dev/ttyAMA0 UART for user applications (GPS), not Bluetooth
dtoverlay=pi3-disable-bt 

and i noticed that i already have this

Code: Select all

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

and

Code: Select all

# Enable audio (loads snd_bcm2835)
dtparam=audio=on
enable_uart=0
dtoverlay=pi3-miniuart-bt
which made me confused
finally i received that error message

Code: Select all

cat: /dev/ttyAMA0: No such file or directory
and even

Code: Select all

 sudo gpsmon /dev/serial0
gpsmon:ERROR: device open of /dev/serial0 failed: No such file or directory - retrying read-only
gpsmon:ERROR: read-only device open of /dev/serial0 failed: No such file or directory
which used to give result
it's a big mess
any help is greatly appreciated
Last edited by maha1 on Sun Apr 07, 2019 6:56 pm, edited 1 time in total.

User avatar
NGC6543
Posts: 75
Joined: Thu Feb 28, 2019 7:30 pm
Location: Lancashire, UK

Re: getting gps to work on raspberry pi 3

Sun Apr 07, 2019 6:53 pm

OK....

Get a spare SD card, install Raspbian afresh, and start from scratch. Once you have the Pi running, run raspi-config and do the following:
..Go to the interfaces
....Select serial
......turn off the shell access
......leave the hardware enabled
..save and reboot.

Then try my two lines from above to set the serial port parameters and cat it. You should get an output. At least then we know your hardware is working and we can take it from there.

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Sun Apr 07, 2019 7:13 pm

At least then we know your hardware is working and we can take it from there.
i already know that the hardware is working because it gave me position before by using this line

Code: Select all

sudo gpsmon /dev/serial0   

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Fri Apr 12, 2019 7:10 pm

hi again @NGC6543
i followed your instructions
Get a spare SD card, install Raspbian afresh, and start from scratch. Once you have the Pi running, run raspi-config and do the following:
..Go to the interfaces
....Select serial
......turn off the shell access
......leave the hardware enabled
..save and reboot.

Code: Select all

stty -F /dev/serial0 raw 9600 cs8 clocal -cstopb
cat /dev/serial0
and this is the result

Code: Select all

[email protected]:~ $ stty -F /dev/serial0 raw 9600 cs8 clocal -cstopb
[email protected]:~ $ cat /dev/serial0
$GPRMC,185240.00,V,,,,,,,120419,,,N*78
$GPVTG,,,,,,,,,N*30
$GPGGA,185240.00,,,,,0,00,99.99,,,,,,*6C
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV,1,1,00*79
$GPGLL,,,,,185240.00,V,N*40
$GPRMC,185241.00,V,,,,,,,120419,,,N*79
then i started working with that link that you proposed previously

it works great until the pps part
it shows that error

Code: Select all

[email protected]:~ $ sudo ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
i think it could be the fault of the pps pin number
i made a search and i found my gps pinmap here https://www.itead.cc/wiki/RPI_GPS_ADD-ON_V2.0
but no ssh pin
do you have any idea?

User avatar
NGC6543
Posts: 75
Joined: Thu Feb 28, 2019 7:30 pm
Location: Lancashire, UK

Re: getting gps to work on raspberry pi 3

Fri Apr 12, 2019 11:23 pm

From a quick look at the schematic, it seems the PPS output isn't connected to the GPIO. It is on one of the jumpers on the board though, labelled 1PPS. You can connect it manually to a GPIO. Just check the schematic - pin 1 on the jumper is the PPS and the other pin is ground so connect the right one.

On mine I have the PPS on GPIO4 but you can use whatever you want if you set it in the PPS dtoverlay:

dtoverlay=pps-gpio,gpiopin=4

Edit to add: The output you got from the serial port looks right for having no GPS fix.

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Sat Apr 13, 2019 9:11 am

thank you so much it solved the problem
i kept working on the link
the gps status is active but when i run

Code: Select all

gpsmon

Code: Select all

tcp://localhost:2947          u-blox> C
iver":"u-blox","subtype":"Unknown","activated":"2019-04-13T08:56:34.381Z","flag
s":1,"native":1,"bps":9600,"parity":"N","stopbits":1,"cycle":1.00,"mincycle":0.
25},{"class":"DEVICE","path":"/dev/pps0","driver":"PPS","activated":"2019-04-13
T08:51:33.718Z"}]}
(122) {"class":"WATCH","enable":true,"json":false,"nmea":false,"raw":2,"scaled"
:false,"timing":false,"split24":false,"pps":true}
>>>b5620a0400000e3
(60) b56201063400f02a1c000000000000000040c44304260000000000000000c05ab726000000
000000000000000000d00700000f270200226701007266
>>>b5620a0400000e3
(208) b5620130c800f02a1c00100200000401000100a50000000000000702000100a5000000000
0000d03000100a50000000000000604100100a50000000000000e05000100a50000000000000806
000100a50000000000000107000100a50000000000000908000100a50000000000000309000100a
50000000000000b16100100a50000000000000218000100a50000000000000a19000100a5000000
0000000f1a000100a50000000000000c1d000100a5000000000000051f000100a50000000000000
078100100a50000000000008baa
(26) b56201041200f02a1c000f270f270f270f270f270f270f27c7fb
(24) b56201201000f02a1c000000000000000f00ffffffff72e2
(20) b56201320c00f02a1c00000000000000000075cc
(60) b56201063400d82e1c000000000000000040c44304260000000000000000c05ab726000000
runing gpsd -s

Code: Select all

gpsd: invalid option -- 's'

User avatar
bensimmo
Posts: 4074
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: getting gps to work on raspberry pi 3

Sat Apr 13, 2019 10:13 am

It's a Ublox GPS and gpsmon does everything itself, if it sees a native setup it will selected it native driver, he it seen the Ublox so you are getting Ublox data from it (not the nmea).
Nothing to worry about

Gpsd is correct, there is no -s, there is a -S port-number
But GPAs sits in the background doing its stuff, you set setting in it configuration files.

Then cgps, xgps, ntp and any program you write to access the data from 'gpsd', it can even be on another computer or device if you open the port to the network.

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Sat Apr 13, 2019 10:34 am

bensimmo thanks for replying
sorry i m just a beginner,i dont really undrestand what u mean
but i can't see any data using cgps and xgps too

Code: Select all

 Time:       2019-04-13T10:29:15.000Z   ││PRN:   Elev:  Azim:  SNR:  Used:
│    Latitude:   n/a                        ││
│    Longitude:  n/a                        ││
│    Altitude:   n/a                        ││
│    Speed:      n/a                        ││
│    Heading:    n/a                        ││
│    Climb:      n/a                        ││
│    Status:     NO FIX (12 secs)           ││
│    Longitude Err:   n/a                   ││
│    Latitude Err:    n/a                   ││
│    Altitude Err:    n/a                   ││
│    Course Err:      n/a                   ││
│    Speed Err:       n/a                   ││
│    Time offset:     -2.762                ││
│    Grid Square:     n/a     

do you have any idea how to solve it
or any other way to get latitude and longitude data

User avatar
NGC6543
Posts: 75
Joined: Thu Feb 28, 2019 7:30 pm
Location: Lancashire, UK

Re: getting gps to work on raspberry pi 3

Sat Apr 13, 2019 11:11 am

maha1 wrote:
Sat Apr 13, 2019 10:34 am

Code: Select all

│    Status:     NO FIX (12 secs)           ││
That might give a clue...

I've no idea what you should see if you don't have a GPS fix in cgps, because I've never run it without one. I made sure I had a fix before all of that when I set up mine, by watching the cat output from the serial port. That makes life much easier I would think, because then you know things should give you a sensible output.

Edit to add: It might be a dumb question, but you do have a GPS antenna attached don't you? I don't think that ublox module has a patch antenna embedded like mine does. Even if it did, those are useless indoors.

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Sat Apr 13, 2019 11:53 am

yes i have a gps antenna and it was attached the whole time

User avatar
NGC6543
Posts: 75
Joined: Thu Feb 28, 2019 7:30 pm
Location: Lancashire, UK

Re: getting gps to work on raspberry pi 3

Sat Apr 13, 2019 12:04 pm

Is it an active antenna, and have you put it at a window, or better yet, outside? Even an active antenna might struggle indoors, but if you put it out for a while it should be able to maintain a fix when you take it back indoors. First, it needs to get the complete GPS almanac from the transmissions, which I think takes 12.5 minutes to complete, then it can get a fix. It saves the almanac (if you have a battery backup) so it can start up more quickly in future.

As far as I can see, you just aren't getting a GPS fix, so there's nothing for cgps to show you.

maha1
Posts: 31
Joined: Fri Apr 05, 2019 10:08 pm

Re: getting gps to work on raspberry pi 3

Sat Apr 13, 2019 12:36 pm

yup that was the problem
finally i can see the data
thank you very much for your help i really appreciate it :D

User avatar
bensimmo
Posts: 4074
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: getting gps to work on raspberry pi 3

Sat Apr 13, 2019 5:20 pm

Sorry, basically it needs about 30mins outside, near a window to get its first fix, it should be quicker after that.
You would need Ublox8 style for a lock indoors (or better chance of one) compared.to the ublox6 you have.

cgps stops if it doesn't have a lock, gpsmon will normally keep on going.

It is a bit confusing to get things going and knowing what is what when you start out, I remember it well, the Pi3 had just been released and 'serial on gpio uart' didn't quite work as well as it does now

If you are not using gpsd, you don't need to set it up.
e.g. If you are using python to look at / dev/serial0 and read the nmea lines directly.

What are you using PPS for? What the project? :-)

Return to “Raspbian”