Neo-6m GPS data slow update - Page 1
Forum section: electronics / general

author: Flump
author_rank: Frequent Contributor
timestamp: November 02, 2020, 10:06:15 am
content: I have just started to mess around with microcontrollers and GPS modules so don't know much about thembut one problem I am having is slow updates.With the following code I would have expected the GPS module to send new data to the arduino every 1 secondbut it isn't, could anyone tell me why please and how I can correct it as I want to make a GPS based speedometerwhich needs to update at least every 1 second or preferably every 500 millisecond.I have tried 3 different GPS modules from different suppliers and also tried them onArduino Uno, Nano and ESP32 and nothing changes.Code:#include <TinyGPS++.h>#include <SoftwareSerial.h>#include <SPI.h>TinyGPSPlus gps;#define S_RX 4#define S_TX 3SoftwareSerial SoftSerial(S_RX, S_TX);void setup() {Serial.begin(9600);SoftSerial.begin(9600);}void loop() {while (SoftSerial.available() > 0) {if (gps.encode(SoftSerial.read())) {Serial.print("Time ");Serial.print(gps.time.hour());Serial.print(":");Serial.print(gps.time.minute());Serial.print(":");Serial.print(gps.time.second());Serial.print(" Sats");Serial.println(gps.satellites.value());delay(1000);}}}The following code is the data received on the Serial Monitor.Code:09:47:00.982 -> Time 9:47:0 Sats909:47:02.011 -> Time 9:47:0 Sats909:47:03.124 -> Time 9:47:2 Sats909:47:04.157 -> Time 9:47:2 Sats909:47:05.229 -> Time 9:47:2 Sats909:47:06.398 -> Time 9:47:2 Sats909:47:07.430 -> Time 9:47:2 Sats909:47:08.478 -> Time 9:47:2 Sats909:47:09.978 -> Time 9:47:9 Sats909:47:11.043 -> Time 9:47:9 Sats909:47:12.122 -> Time 9:47:11 Sats909:47:13.134 -> Time 9:47:11 Sats909:47:14.259 -> Time 9:47:11 Sats909:47:15.396 -> Time 9:47:11 Sats909:47:16.432 -> Time 9:47:11 Sats909:47:17.484 -> Time 9:47:11 Sats909:47:19.021 -> Time 9:47:18 Sats909:47:20.005 -> Time 9:47:18 Sats909:47:21.126 -> Time 9:47:20 Sats909:47:22.146 -> Time 9:47:20 Sats909:47:23.246 -> Time 9:47:20 Sats909:47:24.406 -> Time 9:47:20 Sats909:47:25.421 -> Time 9:47:20 Sats909:47:26.452 -> Time 9:47:20 Sats909:47:27.974 -> Time 9:47:27 Sats909:47:29.037 -> Time 9:47:27 Sats909:47:30.115 -> Time 9:47:29 Sats909:47:31.130 -> Time 9:47:29 Sats909:47:32.256 -> Time 9:47:29 Sats909:47:33.394 -> Time 9:47:29 Sats909:47:34.425 -> Time 9:47:29 Sats909:47:35.458 -> Time 9:47:29 Sats909:47:37.011 -> Time 9:47:36 Sats909:47:38.032 -> Time 9:47:36 Sats909:47:39.111 -> Time 9:47:38 Sats909:47:40.148 -> Time 9:47:38 Sats909:47:41.228 -> Time 9:47:38 Sats909:47:42.408 -> Time 9:47:38 Sats9

author: MosherIV
author_rank: Super Contributor
timestamp: November 02, 2020, 10:11:48 am
content: First, you need to check the output from the GPS module is coming at the rate you want.You will need a usb to serial converter, connect this to the GPS module.Connect the serial converter to your PC and check with a terminal program what is coming from the GPS module and how fast.The GPS module may be working and it is your program that is not.

author: Flump
author_rank: Frequent Contributor
timestamp: November 02, 2020, 08:44:53 pm
content: Hello Mosher, thanks for the adviceI have done what you suggested but used the Ublox C-Center software to display the data as I don't know how to do it the terminal way.Here is the time info straight from the GPS Module.QuoteAnd here it is plugged back in to the Arduino Uno and reading the data from the Arduino IDE Serial MonitorCode:20:35:31.302 -> Time 20:35:29 Sats820:35:32.333 -> Time 20:35:29 Sats820:35:33.413 -> Time 20:35:29 Sats820:35:34.497 -> Time 20:35:29 Sats820:35:35.528 -> Time 20:35:29 Sats820:35:36.614 -> Time 20:35:29 Sats820:35:38.162 -> Time 20:35:36 Sats820:35:39.206 -> Time 20:35:36 Sats820:35:40.331 -> Time 20:35:36 Sats820:35:41.485 -> Time 20:35:36 Sats820:35:42.516 -> Time 20:35:36 Sats820:35:43.627 -> Time 20:35:36 Sats820:35:45.166 -> Time 20:35:43 Sats820:35:46.197 -> Time 20:35:43 Sats820:35:47.254 -> Time 20:35:43 Sats120:35:48.379 -> Time 20:35:43 Sats120:35:49.516 -> Time 20:35:43 Sats120:35:50.547 -> Time 20:35:43 Sats120:35:51.613 -> Time 20:35:43 Sats120:35:53.162 -> Time 20:35:51 Sats120:35:54.193 -> Time 20:35:51 Sats120:35:55.309 -> Time 20:35:53 Sats720:35:57.735 -> Time 20:35:53 Sats720:35:57.735 -> Time 20:35:53 Sats720:35:58.485 -> Time 20:35:53 Sats720:35:59.536 -> Time 20:35:53 Sats720:36:00.615 -> Time 20:35:53 Sats7This time I plugged the GPS Module into the TX RX pins on the Arduino but it did not make any differenceWhen I had the same program running on the ESP32 I streamed the data over bluetooth and it was doing the same whichbypass the computer and software all together.I am really at a loss with this.

author: MosherIV
author_rank: Super Contributor
timestamp: November 02, 2020, 10:41:46 pm
content: So, from the test, you know that the gps module is outputing data at a fast enough rate.The problem must be the code.A quick inpection of your code........What do you think "Delay(1000)" is going to do in your main loop?

author: Flump
author_rank: Frequent Contributor
timestamp: November 02, 2020, 10:54:16 pm
content: Delay(1000) is a 1 second delay so that the GPS data the microcontroller receives is sent to the Serial Monitor every second.I did remove this delay but it did not fix the problem,I will do back to back tests tomorrow (late here now) and post the data.

author: MosherIV
author_rank: Super Contributor
timestamp: November 02, 2020, 11:20:57 pm
content: Then your problem is with the way Arduino handles serial.You are trying to 'poll' the uart and not expecting anyhting to get in the way of your loop while polling.The problem is that Arduino does a fair bit of stuff or the serial library routines you are using just go off and loose (a lot of) characters.It is not your code (or it is partly your code), it is the Arduino code.

author: mikerj
author_rank: Super Contributor
timestamp: November 03, 2020, 12:50:37 pm
content: Quote from: Flump on November 02, 2020, 08:44:53 pmThat looks pretty messed up. Why are there a bunch of fields that just contain checksum characters and no checksum on the first line, and no checksum character or checksum on any of the others?AFAIK the checksum field is mandatory for a GPRMC sentence.

author: HB9EVI
author_rank: Frequent Contributor
timestamp: November 03, 2020, 01:20:42 pm
content: imho the best practice is to trigger the main() with a flag variable set by the usart interrupt at the end of one whole data acquisition; on the NEO7M and NEO8 the last field ist the GPGLL field.so when the end of the GPGLL field is reached, you set a variable to 1 which triggers the data analyze within the main loop and reset it to 0 after you're donelike that you can entirely work non-blocking with interrupts; soft uart is not really the way to go for with the gps hw; you can use the soft uart for the computer connection