Estimate Velocity with GPS + MPU6050 + ESP32 Dead Reckoning
Estimate Velocity with ATGM336H GPS module, MPU6050 Gyroscope Accelerometer with ESP32 Dead Reckoning & C++ Speedometer Code
- Suitable forB.Tech/Diploma ESP32/IoT students
- Build time1-2 weeks
- LevelBeginner
- Available atAjvika Labs, Kakinada
About this project
Overview
In this project, we will build an
ESP32 GPS + MPU6050 velocity estimation and dead-reckoning system
using an
ESP32
ATGM336H GPS module
MPU6050 accelerometer/gyroscope
, and a 0.96-inch
SSD1306 OLED display
. The GPS provides absolute speed, position, satellite status, and course data, while the MPU6050 measures high-rate acceleration and angular motion. Earlier we made simple
GPS Speedometer with Arduino
, which was not too good.
Instead of depending only on GPS speed, the ESP32 combines the GPS measurement with the MPU6050 inertial data. A lightweight
Kalman-based velocity filter
is used to integrate the IMU acceleration between GPS updates and then correct the estimate whenever a new GPS speed measurement is available. A stationary detector and
zero-velocity update (ZUPT)
are also used to reduce the velocity drift that normally occurs when acceleration is integrated over time.
The OLED is used as a compact speed and navigation display. The large value at the top shows the estimated velocity in
km/h
, while the lower part shows GPS fix status, number of satellites, raw GPS speed, heading, HDOP, and North/East velocity components. On power-up, the MPU6050 performs an automatic still calibration for a few seconds, so there is no manual +X/+Y/+Z calibration procedure.
Components Required
Following are the main components required for the ESP32 GPS + MPU6050 velocity tracker.
S.N.
Components Name
Quantity
Purchase Link
1
ESP32 Board
1
Amazon
AliExpress
2
ATGM336H GPS Module
1
Amazon
AliExpress
3
MPU6050 Gyro/Accelerometer
1
Amazon
AliExpress
4
OLED Display 0.96\"
1
Amazon
AliExpress
5
10uF Electrolytic Capacitor
2
Amazon
AliExpress
6
0.1uF Ceramic Capacitor
4
Amazon
AliExpress
7
Jumper Wires
4
Amazon
AliExpress
Block Diagram of ESP32 GPS + MPU6050 Dead Reckoning
The block diagram below represents the data flow of the velocity estimation system. The
ATGM336H GPS
communicates with the ESP32 through UART, while both the
MPU6050
and
SSD1306 OLED
share the same I2C bus.
The MPU6050 is sampled at a much higher rate than the GPS. Its acceleration is gravity-compensated using the estimated roll and pitch, rotated into the navigation frame, filtered, and integrated into velocity. GPS speed and course are then used to correct the inertial estimate so that long-term drift remains under control.
ATGM336H GPS Module
The
ATGM336H
is used as the absolute navigation reference in this project. The module sends standard NMEA data to the ESP32 over UART. From these messages, the program reads the GPS fix, latitude/longitude, speed over ground, course over ground, satellite count, and HDOP.
For velocity estimation, the most important GPS values are
speed
and
course
. GPS speed provides the long-term velocity reference, while course is used to initialize and periodically correct the yaw/heading estimate when the device is moving fast enough for GPS course to be reliable.
MPU6050 Accelerometer & Gyroscope
The
MPU6050
contains a 3-axis accelerometer and a 3-axis gyroscope. The accelerometer measures the combination of gravity and vehicle motion, while the gyroscope measures angular rotation. The ESP32 uses these measurements to estimate roll, pitch, yaw change, and horizontal acceleration.
At startup, the device is kept still for a few seconds. The program automatically averages the gyroscope to estimate its zero-rate bias, normalizes the accelerometer magnitude, and initializes roll and pitch from the gravity direction. The startup orientation itself does not need to be +X up or +Z up. For dead-reckoning operation, however, the MPU6050 should be mounted rigidly so its
+X axis points forward
, +Y points left, and +Z points upward.
Working Principle of GPS + IMU Sensor Fusion
The GPS and MPU6050 have different strengths. GPS gives an absolute velocity reference but updates relatively slowly. The MPU6050 updates rapidly and reacts immediately to acceleration, but small sensor offsets cause integrated velocity to drift. The program combines both measurements instead of relying on either sensor alone.
The main processing steps are:
Automatic startup calibration:
while the unit is stationary, the ESP32 estimates gyroscope bias and initializes tilt from gravity.
Attitude estimation:
gyroscope integration is combined with accelerometer-based roll and pitch using an adaptive complementary filter.
Gravity compensation:
the measured acceleration is rotated into North/East/Down coordinates and gravity is removed.
Kalman prediction:
horizontal acceleration is integrated at approximately 100 Hz to predict North and East velocity.
GPS correction:
GPS speed and course are converted into North/East velocity and used to correct the Kalman estimate.
Stationary detection and ZUPT:
when GPS speed, gyroscope motion, and acceleration magnitude all indicate that the device is stationary, the velocity estimate is pulled back toward zero and residual bias is reduced.
This is a
GPS-aided dead-reckoning
system rather than a pure inertial navigation system. The GPS prevents the MPU6050 integration error from growing without limit, while the IMU provides a faster response between GPS measurements.
Circuit Diagram
The
ESP32
is the main controller of the velocity tracker. The
ATGM336H GPS module
communicates through UART2, while the
MPU6050
and
SSD1306 OLED display
share the I2C bus.
The GPS
TX
pin is connected to ESP32
GPIO16
and the GPS
RX
pin is connected to
GPIO17
. The MPU6050 and OLED use
GPIO21 for SDA
and
GPIO22 for SCL
. The MPU6050 normally uses I2C address
0x68
, while the SSD1306 OLED used in this project uses address
0x3C
. All modules share a common ground and are powered from the appropriate board supply.
PCB Designing & Gerber Files
The schematic of the
ESP32 GPS + MPU6050 Velocity Tracker
was created in
EasyEDA
and converted into a compact PCB layout. The PCB provides connections for the ESP32, OLED display, ATGM336H GPS module, MPU6050, power-supply filtering components, and the required UART and I2C signal lines.
The board is designed with mostly
through-hole components
to make assembly easier. You can view the 3D view of the PCB below.
All of the critical components, including the ESP32 module, are placed on the
front side of the PCB
, which makes assembly easier and more reliable.
Here are the links of files that you can download for PCB manufacturing and PCB assembly services.
Download:
Schematic PDF
Download:
Gerber File
PCB Ordering Online & Assembly
The
Gerber file
for this
ESP32 GPS + MPU6050 Velocity Tracker
is provided above. You can download the Gerber file and place an order with a PCB manufacturer like
AIVON
for as low as $1 for a PCB Prototype.
To order the PCB, visit the
AIVON Official Website
and upload the Gerber file using the
Quote Now
option. You can then choose your required parameters, such as
Material Type, Dimensions, Quantity, Thickness, and Solder Mask Color.
AIVON
is making PCB prototyping and assembly more affordable for new users by offering
$1 PCB Prototype
and
$35 PCB Assembly
with Shipping fee
$30 OFF
on your first PCB order. With this promotion, you can enjoy
free shipping
on your first order and affordable assembly service for your project.
Here is the promotion link
:
AIVON PCB/PCBA Promotion Offer
Once all the details are filled in, select your country and shipping method. After confirming everything, you can place the order and wait for your boards to arrive.
Assembly of the ESP32 GPS + MPU6050 Velocity Tracker
After I ordered the custom PCB, I received it within just
3 days
. The PCB quality was very good, and it looked clean and professional. It is a
double-sided PCB
, which makes the circuit compact and neat.
Then I started soldering and assembling the components on the board. Female header pins can be used for the
ESP32
and
OLED display
so the modules remain removable. The
ATGM336H GPS
connects to the UART pins, while the
MPU6050
connects to the sam
In this project, we will build an
ESP32 GPS + MPU6050 velocity estimation and dead-reckoning system
using an
ESP32
ATGM336H GPS module
MPU6050 accelerometer/gyroscope
, and a 0.96-inch
SSD1306 OLED display
. The GPS provides absolute speed, position, satellite status, and course data, while the MPU6050 measures high-rate acceleration and angular motion. Earlier we made simple
GPS Speedometer with Arduino
, which was not too good.
Instead of depending only on GPS speed, the ESP32 combines the GPS measurement with the MPU6050 inertial data. A lightweight
Kalman-based velocity filter
is used to integrate the IMU acceleration between GPS updates and then correct the estimate whenever a new GPS speed measurement is available. A stationary detector and
zero-velocity update (ZUPT)
are also used to reduce the velocity drift that normally occurs when acceleration is integrated over time.
The OLED is used as a compact speed and navigation display. The large value at the top shows the estimated velocity in
km/h
, while the lower part shows GPS fix status, number of satellites, raw GPS speed, heading, HDOP, and North/East velocity components. On power-up, the MPU6050 performs an automatic still calibration for a few seconds, so there is no manual +X/+Y/+Z calibration procedure.
Components Required
Following are the main components required for the ESP32 GPS + MPU6050 velocity tracker.
S.N.
Components Name
Quantity
Purchase Link
1
ESP32 Board
1
Amazon
AliExpress
2
ATGM336H GPS Module
1
Amazon
AliExpress
3
MPU6050 Gyro/Accelerometer
1
Amazon
AliExpress
4
OLED Display 0.96\"
1
Amazon
AliExpress
5
10uF Electrolytic Capacitor
2
Amazon
AliExpress
6
0.1uF Ceramic Capacitor
4
Amazon
AliExpress
7
Jumper Wires
4
Amazon
AliExpress
Block Diagram of ESP32 GPS + MPU6050 Dead Reckoning
The block diagram below represents the data flow of the velocity estimation system. The
ATGM336H GPS
communicates with the ESP32 through UART, while both the
MPU6050
and
SSD1306 OLED
share the same I2C bus.
The MPU6050 is sampled at a much higher rate than the GPS. Its acceleration is gravity-compensated using the estimated roll and pitch, rotated into the navigation frame, filtered, and integrated into velocity. GPS speed and course are then used to correct the inertial estimate so that long-term drift remains under control.
ATGM336H GPS Module
The
ATGM336H
is used as the absolute navigation reference in this project. The module sends standard NMEA data to the ESP32 over UART. From these messages, the program reads the GPS fix, latitude/longitude, speed over ground, course over ground, satellite count, and HDOP.
For velocity estimation, the most important GPS values are
speed
and
course
. GPS speed provides the long-term velocity reference, while course is used to initialize and periodically correct the yaw/heading estimate when the device is moving fast enough for GPS course to be reliable.
MPU6050 Accelerometer & Gyroscope
The
MPU6050
contains a 3-axis accelerometer and a 3-axis gyroscope. The accelerometer measures the combination of gravity and vehicle motion, while the gyroscope measures angular rotation. The ESP32 uses these measurements to estimate roll, pitch, yaw change, and horizontal acceleration.
At startup, the device is kept still for a few seconds. The program automatically averages the gyroscope to estimate its zero-rate bias, normalizes the accelerometer magnitude, and initializes roll and pitch from the gravity direction. The startup orientation itself does not need to be +X up or +Z up. For dead-reckoning operation, however, the MPU6050 should be mounted rigidly so its
+X axis points forward
, +Y points left, and +Z points upward.
Working Principle of GPS + IMU Sensor Fusion
The GPS and MPU6050 have different strengths. GPS gives an absolute velocity reference but updates relatively slowly. The MPU6050 updates rapidly and reacts immediately to acceleration, but small sensor offsets cause integrated velocity to drift. The program combines both measurements instead of relying on either sensor alone.
The main processing steps are:
Automatic startup calibration:
while the unit is stationary, the ESP32 estimates gyroscope bias and initializes tilt from gravity.
Attitude estimation:
gyroscope integration is combined with accelerometer-based roll and pitch using an adaptive complementary filter.
Gravity compensation:
the measured acceleration is rotated into North/East/Down coordinates and gravity is removed.
Kalman prediction:
horizontal acceleration is integrated at approximately 100 Hz to predict North and East velocity.
GPS correction:
GPS speed and course are converted into North/East velocity and used to correct the Kalman estimate.
Stationary detection and ZUPT:
when GPS speed, gyroscope motion, and acceleration magnitude all indicate that the device is stationary, the velocity estimate is pulled back toward zero and residual bias is reduced.
This is a
GPS-aided dead-reckoning
system rather than a pure inertial navigation system. The GPS prevents the MPU6050 integration error from growing without limit, while the IMU provides a faster response between GPS measurements.
Circuit Diagram
The
ESP32
is the main controller of the velocity tracker. The
ATGM336H GPS module
communicates through UART2, while the
MPU6050
and
SSD1306 OLED display
share the I2C bus.
The GPS
TX
pin is connected to ESP32
GPIO16
and the GPS
RX
pin is connected to
GPIO17
. The MPU6050 and OLED use
GPIO21 for SDA
and
GPIO22 for SCL
. The MPU6050 normally uses I2C address
0x68
, while the SSD1306 OLED used in this project uses address
0x3C
. All modules share a common ground and are powered from the appropriate board supply.
PCB Designing & Gerber Files
The schematic of the
ESP32 GPS + MPU6050 Velocity Tracker
was created in
EasyEDA
and converted into a compact PCB layout. The PCB provides connections for the ESP32, OLED display, ATGM336H GPS module, MPU6050, power-supply filtering components, and the required UART and I2C signal lines.
The board is designed with mostly
through-hole components
to make assembly easier. You can view the 3D view of the PCB below.
All of the critical components, including the ESP32 module, are placed on the
front side of the PCB
, which makes assembly easier and more reliable.
Here are the links of files that you can download for PCB manufacturing and PCB assembly services.
Download:
Schematic PDF
Download:
Gerber File
PCB Ordering Online & Assembly
The
Gerber file
for this
ESP32 GPS + MPU6050 Velocity Tracker
is provided above. You can download the Gerber file and place an order with a PCB manufacturer like
AIVON
for as low as $1 for a PCB Prototype.
To order the PCB, visit the
AIVON Official Website
and upload the Gerber file using the
Quote Now
option. You can then choose your required parameters, such as
Material Type, Dimensions, Quantity, Thickness, and Solder Mask Color.
AIVON
is making PCB prototyping and assembly more affordable for new users by offering
$1 PCB Prototype
and
$35 PCB Assembly
with Shipping fee
$30 OFF
on your first PCB order. With this promotion, you can enjoy
free shipping
on your first order and affordable assembly service for your project.
Here is the promotion link
:
AIVON PCB/PCBA Promotion Offer
Once all the details are filled in, select your country and shipping method. After confirming everything, you can place the order and wait for your boards to arrive.
Assembly of the ESP32 GPS + MPU6050 Velocity Tracker
After I ordered the custom PCB, I received it within just
3 days
. The PCB quality was very good, and it looked clean and professional. It is a
double-sided PCB
, which makes the circuit compact and neat.
Then I started soldering and assembling the components on the board. Female header pins can be used for the
ESP32
and
OLED display
so the modules remain removable. The
ATGM336H GPS
connects to the UART pins, while the
MPU6050
connects to the sam
Technologies used
Hardware components
- ESP32
- Arduino
- SSD1306
- OLED
- GPS
- MPU6050
Software & tools
- EasyEDA
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.