GPS Logger, SD Card, BLE --> Initially working GPS module stops receiving new GPS data after the first BLE transmission

Hello everybody,
i am hitting a full stop here end and hope somebody can point me to the right direction.

The issue is regarding reading data from a GPS module, writing log files on a SD card and periodically streaming the content of those collected log files via BLE to a peripheral for further handling. Somehow the readings from the gps module break down after the first successful exchange via BLE from the gps data logger client with the BLE Server.

All the parts have been successfully set up in isolated sketches, so i assume it is connected to the integration of the different parts.

What is working so far:

  1. Continously collect GPS Data from a Matek Systems GNSS SAM-M10Q via SoftwareSerial using the tinyGPS++ Library for parsing on an seeed xiao nrf52840 with the “non-embed” board (because later on battery i want to make use of the lower power features - not there yet)
  2. Save the newly received GPS Data into files on a SD Card using the SD Library. For now each Minute a new file is created for debugging purpose, later more GPS data will be written to the same file (hourly or daily file rotation) before trying to send the content to the peripheral.
  3. Continously sending text (at first only a fixed String, but also the content of such files like the ones created by sketch 2 via BLE (using Adafruit Bluefruit) to a ESP32 based BLE Server for further handling (which in turn stores the content of the transmitted files in new files on its own SD card until the BLE connection is released and the ESP32 Server is able to proceed with the file handling (which will be starting a wifi connection and passing the file further via ftp but this is an open todo and not an issue for this post)

When it stops working:
When everything is combined into one sketch the GPS starts fine, data is collected and written to the log files until the trigger is reached to send the content of the collected files on the SD card via BLE to the ESP32 Server.
The sending is also successfull, but when the sketch goes back to collecting new GPS data it seems to go stale and cannot get a new fix of GPS data.
This seems strange to me as gps.location.isValid(); is still returning 1 and all variables storing the interesting GPS Data have first been reset to empty strings “” to then be populated again with data from the GPS module.
It actually seems to me like the GPS Module itself is providing the stale data (thinking it is valid thus return isValid()=1) for some time, before the data goes to 0, 0, 0, 0

I tried to stop and reintialize the gps module by stopping and starting the SoftwareSerial, no luck so far.

So my questions are:

  1. Can somebody provide the reason for why this happens?
  2. How can i prevent this? I tried to reset the gps module but no luck.

A lot of write up, but i hope i provided all necessary details.

Thanks a lot

P.s.the Idea for the Project is a DIY pet tracker with wireless data offloading.

Hi 1meic,
What kind of “Flow control” are you using on the serial port, Sounds like the fifo’s overrun?
you writing to the flash at all?
Did you configure the GPS to only send position data?
Any code you can post?
GL :slight_smile: PJ

Hello PJ,
thanks for your response.
I am not quite sure what you reffer to as Flow Control on the serial port and the fifo overrun.
I have to look into this.

I am currently not writing to the flash, only directly to the SD Card.
And i didn´t configure the GPS in a special way to only send position data (note that i also need the date and time information from the GPS). But maybe you are referring to limmiting the NMEA sentences to only those needed to reduce the data on the GPS interface…?

I will see to provide the code but have to clean up first, as it is a bit much spaghetti code as of now :smiley:

Hi, Yes, I did something similar here

The GPS modules spit a TON of data so I look at the ports fifo’s if your getting over-run or if you need any flow control between the devices. Then the code writing to the SD card, does it block the GPS data from coming in or are You using interrupts in some manner ?
GL :slight_smile:

Hello PJ,
thanks a lot, your remark regarding overrun helped a lot.
When i restructured the code for better reading i also changed to frequency of writting to the SD card and sending the content via BLE and this did the trick.

Now i can receive the files content from the Seeed Xiao Client via BLE on the Server side. Still some edge cases left to handle, but for now i can proceed.

Thanks again!