You encounter orientation sensing every day, even when you do not notice it. A phone rotates its display when you turn it. A drone changes motor speeds to remain level. A rocket corrects its course, while a VR headset updates your view as you move your head.
These machines do very different jobs, but each needs an answer to the same question: which way am I facing? That answer is its orientation—its rotation relative to a useful reference such as gravity and the world around it.
Knowing its orientation allows a machine to react rather than simply move. This is a common job for an What is embedded system?A small computer built into a larger product or machine to perform a particular job. Unlike a laptop, it is usually designed around one system and interacts directly with sensors or hardware..
Many embedded systems operate as a repeating loop:
The control loop
Disturbance → Measure → Calculate → Correct → Measure again
A disturbance changes the system. Sensors measure what happened. Software calculates the system’s new state, and a controller decides how to respond. The cycle then begins again with another measurement.
This Lab concentrates on the first essential part of that loop: measurement. Before a drone can keep itself level, it needs a trustworthy description of how it is moving.
Reveal possible answers
Several measurements can help a machine estimate its orientation or movement:
- What is Accelerometer?A sensor that measures acceleration along one or more axes. Very roughly, a tiny suspended structure inside the chip moves when the sensor accelerates, and the electronics measure that movement.
- What is Gyroscope?A sensor that measures how quickly something is rotating. Very roughly, microscopic moving structures inside the chip respond to rotation and turn it into an electrical measurement.
- What is Magnetometer?A sensor that measures the strength and direction of a magnetic field. It can use Earth’s magnetic field as a compass reference.
- What is GPS?A positioning system that estimates location by comparing precisely timed radio signals from several satellites.
Real systems often combine several sensors because each one answers a different part of the question.
You will not build an entire drone. Instead, you will build the sensing system that lets one begin to answer: what is happening to me in the physical world?
The system you are about to build
PHYSICAL WORLD → MPU6050 → ESP32 → USB → COMPUTER
The What is MPU6050?A compact motion-sensing chip containing a three-axis accelerometer and a three-axis gyroscope. It produces the raw measurements used throughout this Lab. measures acceleration and rotation. The What is ESP32?A programmable microcontroller: a small computer on a board that reads the sensor, performs calculations, and communicates with your laptop. reads those measurements and calculates an estimate of orientation. It then sends the result over USB so your computer can reproduce the movement as a live 3D model.
The MPU6050 contains two sensors: an What is accelerometer?A sensor that measures acceleration along the X, Y, and Z axes. Very roughly, it detects how a tiny internal structure moves as the chip accelerates. and a What is gyroscope?A sensor that measures angular velocity—how quickly the chip rotates around the X, Y, and Z axes.. Each sees a different part of the motion. You will learn how to read both measurements and combine them into an orientation estimate.
What you will learn
By working through the investigation, you will learn how to:
- communicate with a sensor over I²C;
- turn raw register values into physical measurements;
- use gravity to calculate tilt;
- measure and correct gyroscope bias;
- integrate angular velocity over time; and
- fuse imperfect measurements into a more useful orientation estimate.
You do not need to understand every term yet. Each one will be introduced when the system needs it. For now, the goal is simple: connect a physical movement in your hand to a measurement you can see, question, and improve.