
GPS Accuracy Survey with NEO-7M on Raspberry Pi 5 - Proteus Simulation

Hello friends, I hope you all are doing great. Today, I am going to share the GPS Accuracy Survey with NEO-7M on Raspberry Pi 5 - Proteus Simulation, the seventy-fourth project of our IoT Projects series. If you have searched for how accurate a GPS module really is, what CEP50, CEP95 and 2DRMS mean, how to send UBX commands to a u-blox receiver from Python, or a Proteus simulation of a GPS module on a Raspberry Pi, here is a complete one. A GPS receiver never reports exactly the same position twice, even when it stands perfectly still. This Raspberry Pi 5 puts a u-blox NEO-7M on a point whose position is known, collects its fixes, and measures how far they wander, exactly the way surveyors and GNSS engineers judge a receiver.
Two words are at the heart of it, and they are easy to mix up. Accuracy is how close the average position is to the truth; precision is how tightly the fixes cluster, wherever that cluster is. A receiver can be precise but wrong, or right on average but scattered. In this tutorial, we will go through the circuit, the NMEA sentences and the u-blox UBX binary protocol, the conversion of latitude and longitude into metres, CEP50, CEP95, DRMS and 2DRMS, the dilution of precision and the user equivalent range error, the time to first fix and the PPS pulse. Then we run the survey in the simulation: GPS under an open sky, a cold start, GLONASS, and GPS again in a city street. At the end, you can download the project with the program and every library file.
NOTICE: Our team has put a lot of effort into this project: the circuit, the code and every part in the simulation are our own work, and you get them all free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below. And if our free projects help you, you can buy us a coffee. So, let's get started with the GPS accuracy survey with NEO-7M on Raspberry Pi 5 in Proteus simulation:
What Does This GPS Survey Do?
- Reads the receiver: the NEO-7M's NMEA sentences on the Pi's UART, every checksum checked: the fix, the satellites, the dilution of precision, the position.
- Talks UBX: it sends the u-blox binary commands itself, a cold start (CFG-RST) and the choice of GPS or GLONASS (CFG-GNSS), and reads the ACK or NAK back.
- Times the first fix: from the cold start or the switch to the first position, the time to first fix.
- Turns degrees into metres: every fix as metres east, north and up from a known benchmark.
- Measures accuracy and precision: over the last 30 fixes, the bias, the scatter, CEP50, CEP95, DRMS and 2DRMS, and the vertical error.
- Separates the receiver from the sky: the user equivalent range error, the error per unit of HDOP.
- Watches the clock: the PPS pulse at the top of each second against the moment the GGA sentence arrives.
- Shows it all: a 0.96" OLED and a dashboard with a scatter plot of the fixes and the CEP circles, on a laptop or a phone.
It is a great project for learning serial protocols, binary framing and checksums, map geometry and a little statistics in one go. In the simulation, the NEO-7M's pop-up shows the sky plot with every satellite, the signal strengths, the dilution of precision and the time of the first fix, and buttons for the sky (open, city, indoor), so every number the Pi works out has an independent judge.
Components Used in the Proteus Simulation
All the parts come from our Proteus libraries, each with its own tutorial. The project zip at the end includes every LIB and DLL file and the TEP Pi runtime.
| Part | Proteus device | Library post | Connection |
|---|---|---|---|
| Raspberry Pi 5 | RASPBERRY PI 5 | Raspberry Pi 5 Library for Proteus | PI1, gnss_survey.py, Ethernet 192.168.1.51 |
| u-blox NEO-7M GPS module | NEO7MADVTEP | NEO-7M GPS Library for Proteus | U1 on the UART, PPS GPIO18, VCC from the 5V pin |
| SSD1306 OLED 0.96" 128x64 | OLED12864WHITEADVTEP | OLED SSD1306 Library for Proteus | OLED1, I2C1 at 0x3C |
| Laptop WiFi Monitor | LAPTOP WIFI MONITOR | Laptop WiFi Monitor | PC1 |
| Mobile WiFi Monitor | MOBILE WIFI MONITOR | Mobile WiFi Monitor | MOB1 |
Proteus Simulation of the GPS Survey: the Circuit
| NEO-7M pin | Raspberry Pi 5 | Signal |
|---|---|---|
| TXD | GPIO15 RXD (pin 10) | NMEA and UBX from the receiver, 9600 baud |
| RXD | GPIO14 TXD (pin 8) | UBX commands to the receiver |
| PPS | GPIO18 (pin 12) | one pulse a second with a fix |
| VCC / GND | 5V (pin 2) / GND | the module's regulator makes its 3.3 V |
The receiver talks to the Pi over a plain UART: its TXD to the Pi's RXD and the other way round, 9600 baud. The NEO-7M boards carry a regulator, so VCC comes from the Pi's 5 V pin, while the signals are 3.3 V, right for the Pi. PPS, the pulse-per-second output, goes to a GPIO pin. The OLED shares the Pi's I2C bus. In the simulation the module's home position, the properties GPSLAT, GPSLON and GPSALT, is the benchmark: 51.47788 N, 0.00148 W, 46 m, the Royal Observatory at Greenwich. GPSTTFF = 10 sets the cold-start time to first fix to 10 seconds; a real NEO-7M needs about 30, so the simulation runs three times faster on that point.
How the GPS Survey Works
NMEA: What the Receiver Says
Once a second the NEO-7M sends a burst of NMEA sentences, plain text lines that all start with $ and end with a checksum: two hex digits that are the XOR of every character between them. The program checks it on every line and drops any line that fails. Three sentences carry what the survey needs. GGA gives the fix quality, the number of satellites used, the HDOP, the latitude and longitude in degrees and minutes, and the altitude. GSA says whether the fix is 2D or 3D and gives PDOP, HDOP and VDOP. GSV lists the satellites in view with their signal strength. The two letters after the $ say which system made the fix: GP for GPS, GL for GLONASS.
UBX: Talking Back to the Receiver
NMEA only goes one way. To control a u-blox receiver, you send UBX, its binary protocol: two sync bytes B5 62, a class and an id, the payload length as two bytes, little-endian, the payload, and a two-byte checksum, the 8-bit Fletcher sum of everything from the class to the end of the payload. Worked example: the cold start is CFG-RST, class 06 and id 04, with the payload FF FF 02 00 (clear all saved navigation data, then restart the GNSS part). The checksum comes out as 0E 61, so the whole frame is B5 62 06 04 04 00 FF FF 02 00 0E 61. The receiver answers most CFG commands with ACK-ACK (class 05, id 01) or ACK-NAK (05 00). The NEO-7M has a single radio path, so it tracks GPS or GLONASS, never both at once; CFG-GNSS with both enabled is refused with a NAK.
From Degrees to Metres
Latitude and longitude are angles; accuracy is a distance. Near one point, the Earth can be treated as flat, a local tangent plane with east, north and up axes. One degree of latitude is the Earth's radius times pi / 180, 111,195 m, so 0.00001 degree north is 1.11 m. A degree of longitude shrinks with the cosine of the latitude: at Greenwich, 51.48 degrees north, 0.00001 degree east is only 0.69 m. The program converts every fix this way into metres east, north and up from the benchmark.
Accuracy, Precision, CEP and 2DRMS
From the last 30 fixes the program works out the mean position. Its distance from the benchmark is the bias, the accuracy; the spread of the fixes around the mean, their standard deviation east and north, is the precision. Engineers sum up a horizontal scatter with circles around the true point: CEP50, the circular error probable, holds half of the fixes; CEP95 holds 95 %. DRMS is the root mean square of the radial errors, and 2DRMS, twice that, holds about 95 to 98 % of the fixes; datasheets often quote it. For a round, unbiased scatter with a standard deviation s on each axis, CEP50 = 1.18 s, CEP95 = 2.45 s and 2DRMS = 2.83 s. Worked example: s = 0.75 m gives CEP50 0.88 m, CEP95 1.84 m and 2DRMS 2.12 m. The program measures them directly: the median and the 95th percentile of the radial errors, and the root mean square.
Dilution of Precision and UERE
The position error has two causes. One is the error in each satellite range: the clocks, the orbits, the ionosphere and the troposphere, the receiver's noise, summed up as the user equivalent range error, UERE. The other is geometry: satellites spread over the whole sky pin the position down well, satellites bunched together do not. The dilution of precision, HDOP for the horizontal, measures the geometry, and the rule of thumb is horizontal error = HDOP x UERE. So the program divides its DRMS by the mean HDOP to get the UERE. This separates the receiver and the signals from the sky above it: in a city street the buildings hide the low satellites, the HDOP grows and the errors with it, while the UERE should stay about the same.
Time to First Fix and PPS
A receiver needs each satellite's orbit, the ephemeris, to compute a position, and it has to read it from the satellite's own slow 50 bit-per-second message. After a cold start, with nothing saved, that takes about 30 seconds for the NEO-7M, the time to first fix. A hot start, with a recent ephemeris still in memory, takes about a second. The program times the first fix from the moment it sends the cold start. Once the receiver has a fix, PPS gives a pulse at the top of every second, much more exact than the serial data. The NMEA sentences describing that second come afterwards, at 9600 baud about a millisecond a character, so the program measures the delay from the PPS edge to the GGA sentence as well.
The Python Program Explained
The program is gnss_survey.py, a Python program for the Raspberry Pi 5 that uses serial for the UART, lgpio for PPS and the OLED, and threading and http.server for the dashboard. Every UBX frame gets its 8-bit Fletcher checksum:
for x in body:
a = (a + x) & 0xFF
b = (b + a) & 0xFF
The cold start, and the CFG-GNSS frame with its two configuration blocks:
COLD = ubx(0x06, 0x04, struct.pack('<HBB', 0xFFFF, 0x02, 0)) # CFG-RST: clear all saved navigation data, restart the GNSS
return ubx(0x06, 0x3E, bytes([0, 22, 22, 2]) + gps + glo)
UBX replies come in the same byte stream as the NMEA text, so the reader tells them apart by their first byte:
what = 'ACK' if frame[3] == 0x01 else 'NAK'
The NMEA checksum, an XOR of every character:
x ^= ord(ch)
Degrees into metres east, with the cosine of the latitude:
e = math.radians(lon - TRUE_LON) * R_EARTH * math.cos(math.radians(TRUE_LAT))
The time to first fix, from the command to the first position:
ttff = now() - t_wait
The radial error of each fix, the DRMS and the CEP circles:
r_true = [math.hypot(f[0], f[1]) for f in fixes] # the radial error of each fix
drms = math.sqrt(sum(r * r for r in r_true) / n) # (about the true point: the bias included)
cep50=percentile(r_true, 0.5), cep95=percentile(r_true, 0.95), cep50_mean=percentile(r_mean, 0.5),
And the UERE, the error per unit of HDOP:
u_mean=mu, u_sd=sd_u, hdop_mean=hdop, uere=drms / hdop if hdop > 0 else 0.0)
PPS arrives through an lgpio callback on GPIO18, and each GGA sentence notes how long after the last pulse it came. The OLED shows the system and fix, the satellites, HDOP and PDOP, CEP50, CEP95, 2DRMS, the bias and the vertical error, the UERE and the TTFF. Every 10 fixes a full report line goes to the terminal. The pages are / (the dashboard, with the links Cold start, GPS, GLONASS and Clear), /scatter.bmp (the fixes around the benchmark with the CEP50 and CEP95 circles) and /data (JSON).
How to Run the Proteus Simulation
- Download the project zip below and install the library files (the steps are under the download button).
- Open Pi-5-GNSS-Survey.pdsprj from the Proteus Simulation folder. Keep gnss_survey.py and the DLL files next to it.
- Press Play. The receiver starts cold; the first fix comes after about 10 seconds, then the statistics fill up.
- Open the Laptop or the Mobile WiFi Monitor and press Go. Click Cold start, then GLONASS, then GPS.
- On the GPS module's pop-up (U1), set the sky to City or Indoor and watch the satellites and the statistics.
Simulation Results: the GPS Survey in Proteus
We ran the whole survey in one simulation: GPS under an open sky, a cold start, GLONASS, and GPS again in a city street. The receiver started cold at power-up, and the Pi timed it:
9.7 s FIRST FIX after power-up: 9.7 s - GPS, 12 satellites, HDOP 0.69
Twelve satellites spread over the whole sky give an HDOP of 0.69, very good geometry. After 30 fixes the Pi printed its first full report:
39.2 s GPS 30 fixes: HDOP 0.69, bias 0.41 m (E -0.33 N -0.24), sd E 0.49 N 0.56 m, CEP50 0.77 m (about the mean 0.65), CEP95 1.15 m, 2DRMS 1.68 m, up +0.66 sd 0.83 m, UERE 1.22 m; PPS to GGA 224 ms
Read it like a surveyor. The average of the 30 fixes lies 0.41 m from the benchmark: that is the accuracy, the bias. The fixes scatter about 0.5 m on each axis around their own mean: that is the precision, and its CEP50 about the mean is 0.65 m. Around the true point, half of the fixes fall within 0.77 m and 95 % within 1.15 m, and 2DRMS is 1.68 m. These are close to the worked example: s about 0.53 m predicts CEP50 0.62 m and 2DRMS 1.5 m, and the small bias adds the rest. The vertical error, with a standard deviation of 0.83 m, is wider than either horizontal axis, as it always is for GPS: all the satellites are above the antenna, so the geometry is weaker upwards. And the GGA sentence arrived 224 ms after its PPS pulse.
Then we clicked Cold start on the dashboard, at 48.1 seconds. The Pi sent the CFG-RST frame, the statistics started again, and the dashboard showed the wait:
58.7 s FIRST FIX after a cold start (CFG-RST): 10.6 s - GPS, 12 satellites, HDOP 0.69
The Pi measured 10.6 seconds from its command to the first fix; the receiver's own pop-up says 10.4 seconds after the restart. The difference is the time the command took to arrive and the wait for the next one-second output. In our first test run the Pi measured 0.0 seconds here: the GGA sentence right after the command still carried the old fix. That is why the program now waits for the fix to drop before it starts counting.
Next we clicked GLONASS, at 62.9 seconds. The receiver acknowledged the CFG-GNSS frame, dropped GPS and had to find the GLONASS satellites from scratch:
63.1 s UBX ACK for class 06 id 3E
73.7 s FIRST FIX after the switch to GLONASS (CFG-GNSS): 10.8 s - GLONASS, 8 satellites, HDOP 1.05
GLONASS took 10.8 seconds, a little longer than GPS, as on the real chip (the datasheet: 32 s against 30 s). With 8 satellites the HDOP was 1.05, and after 30 fixes:
103.0 s GLONASS 30 fixes: HDOP 1.05, bias 0.31 m (E +0.31 N -0.01), sd E 0.92 N 0.94 m, CEP50 1.21 m (about the mean 1.12), CEP95 2.00 m, 2DRMS 2.66 m, up +1.21 sd 0.63 m, UERE 1.27 m; PPS to GGA 276 ms
Every circle grew, CEP50 from 0.77 to 1.21 m and 2DRMS from 1.68 to 2.66 m, but look at the UERE: 1.27 m against 1.22 m. The ranges were just as good; it was the geometry, fewer satellites and an HDOP of 1.05 instead of 0.69, that spread the fixes. Finally we set the sky to City on the module's pop-up and clicked GPS, at 113.1 seconds:
123.7 s FIRST FIX after the switch to GPS (CFG-GNSS): 10.6 s - GPS, 6 satellites, HDOP 1.29
153.3 s GPS 30 fixes: HDOP 1.29, bias 0.85 m (E +0.57 N -0.63), sd E 0.93 N 0.94 m, CEP50 1.65 m (about the mean 1.23), CEP95 2.05 m, 2DRMS 3.11 m, up +0.51 sd 2.29 m, UERE 1.21 m; PPS to GGA 283 ms
The same GPS constellation as at the start, but the buildings hide every satellite below 25 degrees: 12 in view, only 6 used. The HDOP rose from 0.69 to 1.29, CEP50 more than doubled to 1.65 m, 2DRMS to 3.11 m, and the vertical error grew most of all, a standard deviation of 2.29 m, because the satellites left are all high overhead. And again the UERE stayed at 1.21 m. Across all three conditions it held between 1.2 and 1.3 m while the errors changed by a factor of two: horizontal error = HDOP x UERE, measured.
The run covered 167 seconds of simulation in 619 seconds on our PC, with the receiver's own pop-up as an independent judge of every number: the satellites, the HDOP and the time to first fix.
Download the Project Files
Click the button below to download GPS-Accuracy-Survey-NEO-7M-Raspberry-Pi-5-Proteus-Simulation-v1.0.zip (about 13.6 MB, without the source code of the models):
GPS Accuracy Survey with NEO-7M on Raspberry Pi 5 - Proteus Simulation V1.0- Proteus Simulation: Pi-5-GNSS-Survey.pdsprj, gnss_survey.py and copies of the models.
- Python Code: gnss_survey.py, the program.
- Proteus Library Files: the LIB files of the Raspberry Pi 5, the NEO-7M, the OLED and the two WiFi Monitors.
- Proteus Model Files: the DLL models and the TEPPi folder, the Python runtime of the Raspberry Pi 5.
- README.txt: the installation steps, the properties, the test results and the links to every library post.
No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.
How to Install the Project Files
- Close Proteus and extract the whole zip file, for example to your Desktop.
- Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
- Copy everything in Proteus Model Files, the DLL files and the TEPPi folder, into the MODELS folder.
- Start Proteus and open the project from the Proteus Simulation folder.
Changing the Code
The program is plain Python: edit gnss_survey.py next to the project and press Play again. The benchmark, the window of 30 fixes and the port are at the top. To survey another point, set the module's GPSLAT, GPSLON and GPSALT and the same three numbers in the program; GPSTTFF = 30 gives the real cold-start time.
Ideas to Extend the Project
- Survey for hours instead of 30 fixes, and watch how the bias wanders as the satellites move.
- Raise the rate with UBX CFG-RATE to 5 fixes a second and compare the statistics.
- Read the binary NAV-POSLLH message instead of NMEA: more digits, no text parsing.
- Add a second receiver and compare them side by side, or average them.
- Log the fixes to a CSV file and plot them on a map.
- Use the PPS pulse to set the Pi's clock, and measure how it drifts without it.
From Simulation to Real Hardware
- Free the UART: on Raspberry Pi OS, turn off the serial login console in raspi-config and enable the serial hardware, then use /dev/serial0.
- Give it the sky: the patch antenna wants a clear view upwards; indoors a real NEO-7M usually gets no fix at all, like the simulation's Indoor sky.
- Wait for the first fix: the first start of a new module can take minutes; keep its backup battery so later starts are warm or hot.
- Survey a real benchmark: survey marks with published coordinates exist in most countries; or average a fix for a day to make your own reference.
- Expect worse than the datasheet: trees, walls and multipath reflections spread the errors far more than an open field.
Troubleshooting
- The pop-up says NO POWER: VCC must come from a real supply; here it is the Pi's 5 V pin.
- No fix and no numbers: the module's TXD goes to the Pi's RXD (pin 10) and its RXD to the Pi's TXD (pin 8).
- GLONASS gives a NAK: the NEO-7M takes one system at a time; a CFG-GNSS frame with both on is refused.
- The statistics start again: the window clears after every cold start and every switch, on purpose.
- The terminal cannot start Python: the TEPPi folder is not in MODELS.
Limitations of the Simulation
- The receiver is the NEO-7M library's model: simplified GPS and GLONASS skies, not the real satellites of the day, and position errors of about a metre per unit of HDOP.
- The cold-start time to first fix is 10 seconds here (GPSTTFF), a third of the real NEO-7M's 30.
- Thirty fixes are a small sample for CEP95; a real survey collects thousands.
- The network to the laptop and the phone is simulated inside Proteus.
- Raspberry Pi is a trademark of Raspberry Pi Ltd and u-blox a trademark of u-blox AG; this project is not made or endorsed by them or by Labcenter.
So, that was all about the GPS Accuracy Survey with NEO-7M on Raspberry Pi 5 - Proteus Simulation. I hope it helps you understand how a receiver is read through NMEA and controlled through UBX, the difference between accuracy and precision, what CEP50, CEP95 and 2DRMS mean, how geometry and range errors combine through the dilution of precision, and what a cold start costs, all tested in a simulation before you put a receiver on a real survey mark. More IoT projects with the ESP32 and the Raspberry Pi 5 are coming in this series. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!






















Comments
0