🧠 Operating principle:
The prototype uses a Raspberry Pi Pico to run two BMI160 sensors mounted head-to-tail on a support driven by a NEMA-17 motor. By accumulating tens of thousands of measurements, It eliminates measurement bias through rapid reversal of the measurement direction. The use of dithering improves the resolution beyond the least significant bit (LSB). A five-state Kalman filter is applied at each position to estimate in real time the rotation rate along five directions in the horizontal plane. Finally, a cosine function is fitted to determine the latitude based on the amplitude, and the angle between the machine's reference frame and true north based on the phase shift.

🛠️ Hardware Architecture
The prototype is composed by the following components:
-
Microcontroller: Raspberry Pi Pico
-
Gyroscopes: Two BMI160 MEMS gyroscopes mounted in a head-to-tail configuration
-
Motion System: NEMA 17 stepper motor controlled by an A4988 driver
-
Indexing: Infrared endstop sensor for zero-position referencing
-
Display: 3.5″ SPI TFT screen for real-time data visualization
This setup enables precise measurement of Earth's rotation to determine true north and latitude without relying on magnetic fields

🎥 Project Demo
To see the system in action, check out the demonstration video below!
It shows how the device rotates through five directions, collects thousands of samples, and processes the data in real time to estimate true north and latitude — entirely without relying on any magnetic sensors.
The final result is displayed live on the onboard 3.5″ SPI screen (like a real compass).
Over longer periods (tens of minutes), the heading precision reaches about one degree.
However, what is truly impressive is that even after just a few complete cycles (a few thousand samples), the system already provides a remarkably good estimation of true north — as clearly visible in this video!
🔄 Measurement Cycle and Bias Cancellation
The system performs measurements according to the following cycle:
-
Stop at an azimuth θ and acquire 64 samples per gyroscope.
-
Rotate 180° (θ + π) and acquire a new set of samples.
-
Repeat this process for five azimuths, forming a complete cycle of about 12 seconds, followed by 2 seconds of processing.
🎯 Bias Suppression by Rapid Reversal
By measuring successively in two opposite directions, the system leverages the fact that gyroscope bias drifts slowly compared to the measurement time. Assuming Δt (≈ 0.5 s) is much shorter than the bias drift timescale (on the order of a minute), the horizontal component of Earth's rotation, ω_E,h, can be estimated as:
ω_E,h = 0.5 × (ω₁ − ω₂)
with
ω1 = +ω_E,h + b(t)
ω2 = -ω_E,h + b(t + Δt)
This technique, similar to the mode-reversal method used in certain MEMS gyroscopes, effectively cancels out the bias.
During the early tests, I applied exactly this method. However, in the approach developed here, a Kalman filter now fuses the measurements to estimate both the sensor bias and the rotation rate.
📈 Oversampling & Dithering: Beating the LSB
The BMI160 gyroscope has a resolution of 3.8 mdps per LSB at ±125 °/s full-scale range, whereas the Earth's rotation is 4,1667 mdps and horizontal component of Earth's rotation at 45° latitude is about 2,945 mdps. To detect such a faint signal, the system:
-
Leverages ambient noise (motor vibrations, electronic noise, quantization step) as a natural source of dithering.
-
Stacks tens of thousands of measurements over a few minutes.
With N = 10,000 samples, the quantization noise variance is reduced by a factor of 1 / sqrt(N)
🧮 Real-time Kalman Filtering (5-state EKF)
The raw data from the two BMI160 gyroscopes are noisy (≈ 3.8 mdps/LSB) and subject to slow bias and temperature drift.
After each 12-second acquisition cycle...