GPS code for arduino - #24
Open
AazamAlam wants to merge 1 commit into
Open
Conversation
GPS arduino code with loop() and setup() functions that initializes the SD card and puts data formatted into a single csv file. The gps processes it through a software serial port using UART communication protocol and uses a UBX library to simplify the code syntax and print to the csv file.
AnyiLin
reviewed
Jan 7, 2026
AnyiLin
left a comment
Contributor
There was a problem hiding this comment.
Sorry about the long delay for this. There were two main issues that I found, but otherwise it looks good. First, the delay(100) on line 102 can cause a buffer overflow for Serial. Instead, you should always run gps.read() and only save gps data if gps.ready() is true and 100ms have passed from the last save. Additionally, the gps_data.csv file already exists, then you may be writing in an extra header line in the middle of the file. Instead, we should probably delete the contents of the file every time we initialize the gps, since it will likely be different launches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First GPS arduino code version
GPS arduino code with loop() and setup() functions that initializes the SD card and puts data formatted into a single csv file.
The code processes it through a software serial port using UART communication protocol and uses a UBX library to simplify the code syntax and print to the csv file.
I have a more c++ version, but it imports arduino libraries, so not super robust, but I can try to work around that if it is more standard at GTPL.