Acquiring GPS data without blocking execution

I'm working on a project that would require acquiring GPS data. The issue is that getting a GPS fix can take a long time, especially if inside a building. To mitigate this long wait, I would like my program to continue working while the GPS waits for the proper fix.

Which Microcontroller should I use? ESP32 or ESP8266 or Pico? What library should I use to implement this example of parallel processing?

Thank you

All of the GPS libraries I know of accept data one character at a time. In loop() you check the serial port connected to the GPS and if there is a character waiting you process it.

I like the TinyGPS++ (a.k.a. TinyGPSplus) library. It has "isValid" functions for most of the data fields so you can use the data once it becomes valid.

The problem is that when the microcontroller is capturing data from the GPS, it's unable to perform another task like displaying the heading from the magnetometer or getting the time from the RTC library.
I'm interested in having the GPS data captured as a separate parallel process to the loop. Once the GPS data is acquired, the latitude and longitude are used b the loop.

Not true. You simply write code that has the Arduino do other things while checking occasionally for a valid fix. Please read post #2 more carefully.

Study the Arduino Blink Without Delay example to learn the basic idea.

Only if you have written poor code.

I did not submit any code with my question. So your statement that I have written poor code is just slander! :expressionless:

You did not need to. If this statement is true...

Then your code is poor, as you should not be waiting.

Maybe if you posted your code, we might be able to suggest a better way to approach the problem that you are facing.

I had a stand alone 328p and ended up using the internal uart within the micro to talk to the satellite receiver. Worked much better than the libraries..

At least you can get a byte at a time ...

:smiley_cat:

Forum members have provided more than enough information to solve the problem. Implement their suggestions, and let us know if you run into further trouble.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.