Skip to content

What is an IMU?

An IMU (Inertial Measurement Unit) is a sensor that measures motion and orientation. Your tinyCore has one built in — the LSM6DSOX — sitting right at the center of the board. It combines an accelerometer and a gyroscope into a single chip, giving you the ability to detect tilt, shake, rotation, freefall, steps, and gestures with no external wiring.

The IMU is one of the most powerful features on the tinyCore. It’s what lets you build motion-activated wearables, game controllers, activity trackers, gesture-controlled devices, and balancing robots. Every time your phone auto-rotates its screen or a fitness tracker counts your steps, an IMU is doing the work. Yours is already on the board, ready to go.

A physical object can move in exactly six independent ways. Three are translational — forward/backward, left/right, and up/down along the X, Y, and Z axes. Three are rotational — pitch (tilting nose up/down), roll (tilting side to side), and yaw (turning left/right).

The LSM6DSOX is a 6-DOF (6 Degrees of Freedom) sensor because it measures all six: the accelerometer handles the three translational axes, and the gyroscope handles the three rotational axes.

The accelerometer measures linear acceleration along three perpendicular axes (X, Y, Z). Its output is in m/s² (meters per second squared).

Here’s the thing that surprises most people: an accelerometer sitting still on a table does not read zero. It reads approximately 9.8 m/s² on the Z axis, because it always detects Earth’s gravity pulling downward. Only during freefall (where the sensor and gravity are moving together) would it read zero on all axes.

This constant gravity reading is actually very useful — since gravity always points down, you can calculate the angle of the board relative to the ground from the X, Y, Z values. That’s how tilt detection works.

What you can build with accelerometer data:

  • Tilt detection — calculate the board’s angle using the gravity vector
  • Shake detection — sudden spikes in acceleration on any axis
  • Freefall detection — all three axes reading near zero simultaneously
  • Step counting — the repeating acceleration pattern of walking
  • Tap/double-tap detection — the LSM6DSOX can detect these in hardware

The gyroscope measures angular velocity — how fast the sensor is rotating around each axis. Output is in degrees per second (dps). If you hold the board still, the gyroscope reads approximately zero. When you rotate the board, the axis of rotation shows a value proportional to how fast you’re turning.

What you can build with gyroscope data:

  • Rotation tracking — integrate angular velocity over time to calculate total rotation
  • Twist and gesture detection — detect wrist flicks, turns, and rotational movements
  • Stabilization — the gyroscope responds instantly to rotation, essential for smooth real-time control in drones, gimbals, and camera stabilizers

The accelerometer and gyroscope compensate for each other’s weaknesses.

The accelerometer can’t tell the difference between tilt and lateral movement. Tilting the board 30° and holding it still produces the same readings as accelerating sideways. It also can’t detect rotation around the vertical axis (yaw), because gravity provides no reference for that direction.

The gyroscope can’t give you an absolute reference. It tells you how fast you’re rotating, but not which direction you’re actually facing. Worse, gyroscope readings accumulate small errors over time — a problem called drift. After a few seconds, the calculated angle wanders away from reality.

By combining both sensors, you get the best of each. The accelerometer provides a stable long-term reference (it always knows which way is down). The gyroscope provides fast, responsive short-term rotation tracking. Algorithms called sensor fusion (like complementary filters or Kalman filters) blend the two into orientation estimates that are both responsive and accurate.

The LSM6DSOX is made by STMicroelectronics, and it’s not a basic IMU. Here’s what makes it stand out:

FeatureValue
Accelerometer range±2g, ±4g, ±8g, or ±16g (selectable)
Gyroscope range±125 to ±2000 dps (selectable)
Resolution16-bit per axis
Max output rate6.7 kHz
I2C address0x6A
Power (accel + gyro active)~0.55 mA
Size2.5 × 3.0 × 0.83 mm

The LSM6DSOX can detect these events directly in hardware — no code on the ESP32-S3 needed:

FeatureWhat It Does
Tap / double-tapRecognizes single and double tap events
Step counterCounts steps using a built-in pedometer algorithm
Free-fall detectionTriggers when the device is in freefall
6D orientationReports which of the board’s 6 faces is pointing up
Significant motionDetects when the user changes location
Wake-up detectionDetects motion from a stationary state
Tilt detectionDetects orientation changes

The LSM6DSOX has a dedicated Machine Learning Core (MLC) — a hardware engine that runs decision-tree classifiers directly on the sensor chip. It can classify activities (walking vs running vs biking) and detect gestures while the ESP32-S3 stays asleep. The MLC uses roughly 1–15 µA of power — about 1,000× less than running the same algorithm on the main processor. This is a big deal for battery-powered wearable projects.

The tinyCore reads the LSM6DSOX via I2C using the Adafruit LSM6DS Arduino library. Install it through the Arduino Library Manager (search “Adafruit LSM6DS”).

#include <Adafruit_LSM6DSOX.h>
#include <Wire.h>
Adafruit_LSM6DSOX lsm6dsox;
void setup() {
Serial.begin(115200);
// Power on and init I2C
pinMode(6, OUTPUT);
digitalWrite(6, HIGH);
delay(100);
Wire.begin(3, 4);
if (!lsm6dsox.begin_I2C()) {
Serial.println("Failed to find LSM6DSOX!");
while (1) delay(10);
}
Serial.println("LSM6DSOX found!");
}
void loop() {
sensors_event_t accel, gyro, temp;
lsm6dsox.getEvent(&accel, &gyro, &temp);
Serial.print("Accel X: "); Serial.print(accel.acceleration.x);
Serial.print(" Y: "); Serial.print(accel.acceleration.y);
Serial.print(" Z: "); Serial.println(accel.acceleration.z);
delay(100);
}

The IMU opens up a ton of possibilities:

  • Motion-activated wearables — detect a wrist raise to wake a display, or trigger feedback on specific gestures. tinyCore’s small form factor and battery management make it wearable-ready.
  • Game controllers — send tilt and rotation data over BLE or ESP-NOW to control a game character, steer a vehicle, or aim a cursor.
  • Activity tracking — use the built-in pedometer to count steps and stream data to a phone app via Bluetooth.
  • Gesture recognition — train the on-chip MLC to distinguish between gestures (wave, flick, double-tap) and trigger different actions.
  • Robot balancing — the 6.7 kHz output rate and low latency make the LSM6DSOX fast enough for real-time balance control loops.

Video: How Accelerometers and Gyroscopes Work

Section titled “Video: How Accelerometers and Gyroscopes Work”

engineerguy (Bill Hammack) — takes apart a real accelerometer chip and uses 3D animations to show how the MEMS silicon structures inside detect motion. About 5 minutes, no fluff.

HowToMechatronics — covers how accelerometers and gyroscopes work internally with 3D animations, then demonstrates reading IMU data with Arduino code.