setting up GPS connection

December 18, 2023, 04:46

ziggy00000

Recently got a pitalk 4g ioT and im trying to use it for its gps capabilities, it takes sim cards for txt and calls aswell as hotspots but im trying to see if i can use it for gps w/ sim card, but if u have recommended sim cards im open to that

jannik44

can you explain more what you are trying to do?

ziggy00000

I have a screen attached on it as well; would like to make it into a gps and later possibly into a phone if i can find right sim for my needs, but for now i would like to be able to use it as a top notch gps

aq4152

Just looked up the module, it uses the quectel eg25-g chip, which is a LTE module, not a GPS module. I don't think you can use it for GPS purposes... The cellphone services can be used to geolocate, but it uses trangulation of the LTE / Cell towers, not GPS.

aq4152

Oh wait... I spoke too soon. It DOES have GNSS capabilities...

aq4152

Searched online a bit more, but unfortunately, there isn't much documentation on this particular module. If you have some driver to use this board via for example python, then I would suggest you look through their API / source code and see if you can find any examples to use the GNSS feature, if not, your best bet is to contact the maker on how to achieve this. There is a possibility that they don't have the driver written for GNSS capability yet.

oops.se

No need to be advanced. The chip support standard AT commands so there is no need for drivers and complicated stuff. And you communicate over serial so it is like a old car, it has four wheels and a steering wheel as the previous model had (GPS). The code and documentation can be found here: https://github.com/sbcshop/Pitalk_4G_HAT_Software And the python example for finding the position is:
python
import RPi.GPIO as GPIO
import serial
import time
from Library import PiTalk_4G

gps = PiTalk_4G.eg25().gps_positioning()
And if you take a look in the PiTalk_4G library you will find:
python
ser = serial.Serial('/dev/ttyS0',115200)
And the section def gps_positioning(self): will show you the AT commands for retreiving the location.

ziggy00000

I see the codes in library do i add this on python and run it ? Or how can i activite the gps i apologize for my noobishness as im very new to this

oops.se

I don't read cryptic text in pictures. Please post text as text and format it as python code in discord

ziggy00000

 def gps_positioning(self):   #This function is used for get gps positioning      
        self.power_on(power_key)
        rec_null = True
        self.answer = 0
        print('Starting GPS session...')
        rec_buff = ''
        self.send_at('AT+CGPS=1,1','OK',1)
        time.sleep(2)
        while rec_null:
            
            answer = self.send_at('AT+CGPSINFO','+CGPSINFO: ',1)
            if 1 == self.answer:
                self.answer = 0
                if ',,,,,,' in rec_buff:
                    print('GPS is not ready')
                    rec_null = False
                    time.sleep(1)
            else:
                print('error %d'%self.answer)
                rec_buff = ''
                self.send_at('AT+CGPS=0','OK',1)
                return False
                time.sleep(1.5)

ziggy00000

This is under library how do i use this to implment gps capabilities,

oops.se

The folder Example has examples in how to use the lib

ziggy00000

Yes i followed the example and ran the script via python but nothing happens or an error message will appear

ziggy00000

Maybe im doing something wrong idk what to do

oops.se

Can you connect a serial terminal from pi to the HAT and run basic AT command ?

oops.se

I will not be inclined to help you with just "nothing happens or an error message will appear"!!! Please respect me for trying to help you as I do this voluntarily.

ziggy00000

Apologies i am stuck on the last couple software instructions as its states for me to open Example & Library directory, then open example file and move out the example files, in this case it would be GPS.py from there do i make a new file say like on my desktop and then bash mv gps.py to the desktop file and edit that example with the directions/code from library? I may have been getting an ModuleNotFoundError: No module named 'Library' error because i didnt move the file ?

oops.se

Yes

ziggy00000

Thank you ill try it out and let you know how it goes 🙌