0

so I'm working with a raspberry pi pico w and the neo-6m gps module, I am trying to print my data on my serial monitor but this I get a "none" output here's my code,

from machine import UART, Pin #imports the UART and Pin 
import time


gps_module = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))

if gps_module :
    print("getting data")

#Used to Store NMEA Sentences
buff = bytearray(255)

TIMEOUT = False

#store the status of satellite is fixed or not
FIX_STATUS = False

#Store GPS Coordinates
latitude = ""
longitude = ""
satellites = ""
gpsTime = ""

#function to get gps Coordinates
def getPositionData(gps_module):
    global FIX_STATUS, TIMEOUT, latitude, longitude, satellites, gpsTime
    
    #run while loop to get gps data
    #or terminate while loop after 5 seconds timeout
    timeout = time.time() + 8   # 8 seconds from now
    while True:
        gps_module.readline()
        buff = (gps_module.readline())
        print(buff)

        break

getPositionData(gps_module)

I did the connection well(I think), the led in the gps module is blinking as but I can't pick up any data

  • Just a guess, since I have no experience with the gps module, but in your while loop (which will be executed only once) you read two times in a row the module's output, and print the second one. Mayby there are no data in the second time, due to the short interval. Try to replace the 3 lines after the while with: `print(gps_module.readline())` – TDG Jul 25 '23 at 10:36
  • This question may yield more help over at [Raspberry PI](https://raspberrypi.stackexchange.com/) stackexchange where folks can speak to both the programming and the physical set up to help troubleshoot further. – itprorh66 Jul 25 '23 at 13:58

1 Answers1

0

as this looks to be from the tutorial: https://microcontrollerslab.com/neo-6m-gps-module-raspberry-pi-pico-micropython/

you maybe should remove the break and instead also wait 500ms or something and repeatedly wait for input to be printed as maybe the GPS module does not answer first time around within ms of executing your script.

def getGPS(gpsModule):
    global FIX_STATUS, TIMEOUT, latitude, longitude, satellites, GPStime

    timeout = time.time() + 8 
    while True:
        buff = str(gpsModule.readline())
        print(buff)
    if (time.time() > timeout):
        TIMEOUT = True
        break
    utime.sleep_ms(500)
curimania
  • 31
  • 5