I use SparkFun GPS NEO-M9N at 25Hz frequency with ESP32-S2 Thing Plus on I2C.
The GPS module is configure at 25 Hz and I poll it with respect to that frequency.
Then I use the I2C bus to poll other items. But the latency time of the GPS module is so long that the poll frequency of these items is seriously limited.
For the moment, I see that the awaiting time for a GPS polling answer is about 20ms.
Could anyone be able to help me to find some ublox configuration optimization to reduce it, typically to 10ms ?
You are disabling all output on UART1. That is good.
You are only outputting UBX on I2C. That will help.
Ground speed, Hour, Minute, Second, Millisecond all come from the NAV-PVT message. That is good. Only that single message needs to be polled.
My advice is to make the NAV-PVT message periodic, instead of polling. That way, the getPVT will return - quickly - when no new PVT data is available. Please structure your code like Example1_AutoPVT: in setup call myGNSS.setAutoPVT(true); in loop call myGNSS.getPVT(); when myGNSS.getPVT() returns true then read the ground speed/hour/minute etc..
Thanks Paul,
We are going to test that with hope that we will not need too long waiting time for such message periodic in order to get them all in successive opened windows.
Anyway, could you tell me if this 20ms latency time looks normal ?
It looks as if the GPS item is loosing time to prepare a lot of different messages for different protocols ?
By default the library requests (polls) each individual message from the GNSS. At 25Hz this can take up to 40ms to complete. This is normal. getPVT will take up to 40ms to return the data.
If you make the messages periodic (“auto”), they are generated by the GNSS every 40ms and placed in the I2C buffer. At 100kHz I2C clock speed, it takes approximately 0.5ms to check how much data is waiting in the I2C buffer. When the 100-byte PVT message is available, it takes approximately 10ms to read all 100 bytes. To summarise, getPVT will return false after 0.5ms if no data is available, and true after 10ms when data is available. You can speed this up by using 400kHz clock speed. The methods like getGroundSpeed will return almost instantly because the data is read from the library.
If the NAV-PVT message is periodic (“auto”) and if I2C is running at 400kHz then:
A NAV-PVT message will be added to the I2C buffer every 40ms (25Hz) getPVT will take approximately 0.2ms to read the buffer length
If the PVT message is in the buffer, it will take approximately 2.5ms to read all 100 bytes
But only if the PVT message is periodic.
If you have not called myGNSS.setAutoPVT(true);, the library will assume PVT is not periodic and so will: poll (request) the message; and wait for it to arrive. This will take up to 40ms.