Civlo85 / gsmHat

Using the Waveshare GSM/GPRS/GNSS Hat for Raspberry Pi with Python
MIT License
61 stars 26 forks source link

Cant get any result? #4

Open robbyatbln opened 3 years ago

robbyatbln commented 3 years ago

GNSS_status: 0 Fix_status: 0 UTC: Latitude: 0.0 Longitude: 0.0 Altitude: 0.0 Speed: 0.0 Course: 0.0 HDOP: 0.0 PDOP: 0.0 VDOP: 0.0 GPS_satellites: 0 GNSS_satellites: 0 Signal: 0.0 pi@raspberrypi:~ $

this is what the original gps.py do:

AT+CGNSTST=1 OK $GNGGA,192954.811,,,,,0,0,,,M,,M,,5C $GPGSA,A,1,,,,,,,,,,,,,,,1E $GLGSA,A,1,,,,,,,,,,,,,,,02 $GPGSV,3,1,12,21,70,288,,08,60,193,41,01,45,284,,32,43,100,397D $GPGSV,3,2,12,22,40,230,,10,32,058,43,27,29,161,33,14,22,308,72 $GPGSV,3,3,12,28,21,316,,03,12,229,,24,05,023,,23,01,055,7C $GLGSV,3,1,10,65,64,067,29,88,60,112,33,81,59,319,,66,38,186,63 $GLGSV,3,2,10,72,23,034,,87,20,121,,80,16,320,,82,11,309,67 $GLGSV,3,3,10,73,08,008,,79,05,269,66 $GNRMC,192954.811,V,,,,,0.00,0.00,120421,,,N5D $GNVTG,0.00,T,,M,0.00,N,0.00,K,N*2C

this is my skript :

from gsmHat import GSMHat, SMS, GPS import time gsm = GSMHat('/dev/ttyS0', 115200)

GPSObj = gsm.GetActualGPS()

Lets print some values

print('GNSS_status: %s' % str(GPSObj.GNSS_status)) print('Fix_status: %s' % str(GPSObj.Fix_status)) print('UTC: %s' % str(GPSObj.UTC)) print('Latitude: %s' % str(GPSObj.Latitude)) print('Longitude: %s' % str(GPSObj.Longitude)) print('Altitude: %s' % str(GPSObj.Altitude)) print('Speed: %s' % str(GPSObj.Speed)) print('Course: %s' % str(GPSObj.Course)) print('HDOP: %s' % str(GPSObj.HDOP)) print('PDOP: %s' % str(GPSObj.PDOP)) print('VDOP: %s' % str(GPSObj.VDOP)) print('GPS_satellites: %s' % str(GPSObj.GPS_satellites)) print('GNSS_satellites: %s' % str(GPSObj.GNSS_satellites)) print('Signal: %s' % str(GPSObj.Signal))

pi 4 all new also pi 3 tested an an old 2018 img also tested same problem

by Robby

ThinkTransit commented 3 years ago

I had the same problem, things to check.

  1. Make sure you wait long enough for the GPS to start up and get a signal. This can take 30+ seconds depending on signal.
  2. Some Waveshare devices return a different amount of data items from the GPS, try my fork and see if it helps https://github.com/ThinkTransit/gsmHat
  3. Check gmsHat.log file
robbyatbln commented 3 years ago

Thanks a lot, I found out that all little time sleep resolve my problems. It need just a little time to initiate it a after the Com port settings.

By Robby

MarvellousBee commented 3 years ago

I'm currently experiencing the same issue.

I tried every solution suggested by @ThinkTransit. (waited several minutes, my hat returns 21 values, .log file does not exist on my machine).

Is there anything else that can be done?

ThinkTransit commented 3 years ago

When you get a new GPS device that has never been used before it will take a long time to get the first fix. The device needs to download the Almanac data from the satellite network, this data is only transmitted every 12 minutes. This means if you have bad reception you may have to wait a long time. With one GPS device I had to leave it outside for 4 hours before I got it working. After the first fix then it should pickup a signal quickly.

Trying leaving it switched on and outside for a few hours.

What hardware are you using?

MarvellousBee commented 3 years ago

Switched it on, will post an update in a few hours. I had it switched on for a few hours already. Is there a way to see if that data is already here?

I'm using a Pi 4B.

MarvellousBee commented 3 years ago

7 hours have passed, did not work.

ramteid commented 3 years ago

Same issue here, using an SIM7000E on a Raspberry Pi Zero W

JoniRinta-Kahila commented 3 years ago

I using Waveshare Raspberry Pi GSM/GPRS/GNSS Bluetooth HAT SIM868 on a rpi4

I tried with this code

from gsmgpsHat import GSMHat, SMS, GPS
from time import sleep

gsm = GSMHat('/dev/ttyUSB0', 115200)
sleep(2)

GPSObj = gsm.GetActualGPS()

print('GNSS_status: %s' % str(GPSObj.GNSS_status))
print('Fix_status: %s' % str(GPSObj.Fix_status))
print('UTC: %s' % str(GPSObj.UTC))
print('Latitude: %s' % str(GPSObj.Latitude))
print('Longitude: %s' % str(GPSObj.Longitude))
print('Altitude: %s' % str(GPSObj.Altitude))
print('Speed: %s' % str(GPSObj.Speed))
print('Course: %s' % str(GPSObj.Course))
print('HDOP: %s' % str(GPSObj.HDOP))
print('PDOP: %s' % str(GPSObj.PDOP))
print('VDOP: %s' % str(GPSObj.VDOP))
print('GPS_satellites: %s' % str(GPSObj.GPS_satellites))
print('GNSS_satellites: %s' % str(GPSObj.GNSS_satellites))
print('Signal: %s' % str(GPSObj.Signal))

and i got result

GNSS_status: 0
Fix_status: 0
UTC: 
Latitude: 0.0
Longitude: 0.0
Altitude: 0.0
Speed: 0.0
Course: 0.0
HDOP: 0.0
PDOP: 0.0
VDOP: 0.0
GPS_satellites: 0
GNSS_satellites: 0
Signal: 0.0

Log file looks like

2021-08-13 13:52:35,832 - gsmHat - INFO - Serial connection to /dev/ttyUSB0 established
2021-08-13 13:52:35,832 - gsmHat - INFO - Worker started
2021-08-13 13:52:35,833 - gsmHat - DEBUG - Sent to hat: AT+CMGF=1

2021-08-13 13:52:35,934 - gsmHat - DEBUG - Received Data: AT+CMGF=1
2021-08-13 13:52:35,935 - gsmHat - DEBUG - Received Data: OK
2021-08-13 13:52:35,935 - gsmHat - DEBUG - Lock Off
2021-08-13 13:52:35,935 - gsmHat - DEBUG - Sent to hat: AT+CPMS="SM"

2021-08-13 13:52:36,036 - gsmHat - DEBUG - Received Data: AT+CPMS="SM"
2021-08-13 13:52:36,037 - gsmHat - DEBUG - Received Data: +CPMS: 0,30,0,30,0,30
2021-08-13 13:52:36,038 - gsmHat - DEBUG - Received Data: OK
2021-08-13 13:52:36,038 - gsmHat - DEBUG - Lock Off
2021-08-13 13:52:36,239 - gsmHat - DEBUG - Sent to hat: AT+CGNSPWR=1

2021-08-13 13:52:36,340 - gsmHat - DEBUG - Received Data: AT+CGNSPWR=1
2021-08-13 13:52:36,340 - gsmHat - DEBUG - Received Data: OK
2021-08-13 13:52:36,340 - gsmHat - DEBUG - Lock Off
2021-08-13 13:52:36,340 - gsmHat - DEBUG - GPS powered on
2021-08-13 13:52:36,541 - gsmHat - DEBUG - Sent to hat: AT+CGNSTST=0

2021-08-13 13:52:36,643 - gsmHat - DEBUG - Received Data: AT+CGNSTST=0
2021-08-13 13:52:36,644 - gsmHat - DEBUG - Received Data: OK
2021-08-13 13:52:36,645 - gsmHat - DEBUG - Lock Off
2021-08-13 13:52:36,946 - gsmHat - DEBUG - Sent to hat: AT+CGNSINF

2021-08-13 13:52:37,048 - gsmHat - DEBUG - Received Data: AT+CGNSINF
2021-08-13 13:52:37,055 - gsmHat - DEBUG - Received Data: +CGNSINF: 1,0,20210813105236.000,,,,0.00,0.0,0,,,,,,1,0,,,22,,
2021-08-13 13:52:37,055 - gsmHat - DEBUG - New GPS Data:
2021-08-13 13:52:37,076 - gsmHat - DEBUG - Latitude: Could not convert  to float.
2021-08-13 13:52:37,077 - gsmHat - DEBUG - Longitude: Could not convert  to float.
2021-08-13 13:52:37,077 - gsmHat - DEBUG - Altitude: Could not convert  to float.
2021-08-13 13:52:37,077 - gsmHat - DEBUG - HDOP: Could not convert  to float.
2021-08-13 13:52:37,077 - gsmHat - DEBUG - PDOP: Could not convert  to float.
2021-08-13 13:52:37,078 - gsmHat - DEBUG - VDOP: Could not convert  to float.
2021-08-13 13:52:37,079 - gsmHat - DEBUG - Received Data: OK
2021-08-13 13:52:37,079 - gsmHat - DEBUG - Lock Off
2021-08-13 13:52:37,280 - gsmHat - DEBUG - Sent to hat: AT+CPMS="SM"

2021-08-13 13:52:37,382 - gsmHat - DEBUG - Received Data: AT+CPMS="SM"
2021-08-13 13:52:37,385 - gsmHat - DEBUG - Received Data: +CPMS: 0,30,0,30,0,30
2021-08-13 13:52:37,386 - gsmHat - DEBUG - Received Data: OK
2021-08-13 13:52:37,387 - gsmHat - DEBUG - Lock Off
2021-08-13 13:52:37,588 - gsmHat - DEBUG - Sent to hat: AT+SAPBR=2,1

2021-08-13 13:52:37,690 - gsmHat - DEBUG - Received Data: AT+SAPBR=2,1
2021-08-13 13:52:37,693 - gsmHat - DEBUG - Received Data: +SAPBR: 1,3,"0.0.0.0"
2021-08-13 13:52:37,694 - gsmHat - DEBUG - Received Data: OK
2021-08-13 13:52:37,694 - gsmHat - DEBUG - Lock Off

how can i find out where is the fault?

ThinkTransit commented 3 years ago

In your log file look at the line

2021-08-13 13:52:37,055 - gsmHat - DEBUG - Received Data: +CGNSINF: 1,0,20210813105236.000,,,,0.00,0.0,0,,,,,,1,0,,,22,,

This line is telling you that the receiver doesn't have a GPS fix yet.

See page 192 of reference manual https://www.waveshare.com/w/upload/0/02/SIM7070_SIM7080_SIM7090_Series_AT_Command_Manual_V1.03.pdf

How long have you left the device outside?

JoniRinta-Kahila commented 3 years ago

I've been waiting for a few hours now. But the antenna is next to the window, not outdoors.

Now i put the device outdoors. let's see how it goes tomorrow.

JoniRinta-Kahila commented 3 years ago

still does not work.

2021-08-14 11:59:24,809 - gsmgpsHat - DEBUG - Received Data: +CGNSINF: 1,0,19800105235949.000,,,,0.00,0.0,0,,,,,,0,0,,,,,