Orientation Sensor

Orientation Sensor

Inertial measurement unit that detects rotation and movement

An inertial measurement unit that detects rotation and movement in all directions. It picks up tilting, spinning and acceleration, for game controllers, gestures or logging motion.

For ages 14 and up. Not a toy. Contains small parts: choking hazard. Keep away from children under 3. Adult supervision recommended.

Made by Atech ApS, Lille Strandstræde 6A, st. th., 1254 København K, Denmark.

Technical specifications

Part
6-Axis IMU (ICM-40608 or LSM6DSOX)
Interface
I2C (0x68)
Ports
1 port
Current
~4 mA
Size
19.5 x 19.5 x 9.5 mm
Chip
LSM6DSOX (STMicroelectronics)

Pins

3.3V
supply
GND
ground
Data A
I²C SDA
Data B
I²C SCL

Key features

  • 3-axis accelerometer
  • 3-axis gyroscope
  • Detects tilt, rotation, and acceleration
  • Instant motion readings

Common applications

Game controllers
Tilt detection
Gesture control
Motion data collection
+ Use in Project

Technical

Sensor

Orientation Sensor

6-Axis IMU (ICM-40608 or LSM6DSOX)
Interfacei2c @ 0x68
PortsTakes 1 port; needs a port carrying i2c
Current4 mA
Size19.5 × 9.54 × 19.5 mm (CAD bounding box)
DriverICM40608

6-axis inertial measurement unit with 3-axis accelerometer (±2g), 3-axis gyroscope (±250°/s), and on-die temperature. The driver auto-detects which chip is attached at boot (ICM-40608 at 0x68 or LSM6DSOX at 0x6A), so generated user code is identical either way. Background RTOS task polls at 100Hz, readings are instant.

What it can do
  • read_accel_x Read X-axis acceleration in gfloat g
  • read_accel_y Read Y-axis acceleration in gfloat g
  • read_accel_z Read Z-axis acceleration in gfloat g
  • read_gyro_x Read X-axis rotation rate in degrees/secondfloat deg/s
  • read_gyro_y Read Y-axis rotation rate in degrees/secondfloat deg/s
  • read_gyro_z Read Z-axis rotation rate in degrees/secondfloat deg/s
  • read_temperature Read sensor die temperaturefloat C
  • get_pitch Pitch angle (nose up/down) in degrees, -90..+90, from accelerometerfloat deg
  • get_roll Roll angle (left/right tilt) in degrees, -180..+180, from accelerometerfloat deg
  • get_tilt_angle Total tilt from upright in degrees (0 = flat face-up, 180 = flat face-down)float deg
  • get_orientation Coarse 6-way orientation: face_up, face_down, edge_right, edge_left, edge_front, edge_back, unknownstring
  • was_shaken Edge-triggered shake/tap detector (returns true once per spike >1.8g, then resets)bool
How it works
6-AXIS IMU (ORIENTATION SENSOR):
- Background RTOS task polls the chip at 100Hz. All getters return cached
  values instantly, never blocking, safe to call every loop iteration.
- PREFER DERIVED HELPERS over raw axes. Users almost always want "tilt",
  "shake", or "which way is up", not three raw float streams. Reach for
  raw axes only when the user explicitly asks for gyro/accel values, a
  custom fusion algorithm, or scientific logging.

DERIVED API (use these first):
- getPitch()  -> degrees, -90..+90 (nose up positive). Accel-based, so it's
                 accurate when the board is roughly still but noisy under
                 acceleration. Good for tilt-to-control UIs.
- getRoll()   -> degrees, -180..+180 (left/right). Same caveat as pitch.
- getTiltAngle() -> degrees from upright. 0 = flat face-up, 90 = on its
                    side, 180 = flat face-down. Best single value for
                    "is the board tilted" questions.
- getOrientation() -> ICM40608::Orientation enum (ORI_FACE_UP, ORI_FACE_DOWN,
                      ORI_EDGE_RIGHT, ORI_EDGE_LEFT, ORI_EDGE_FRONT,
                      ORI_EDGE_BACK, ORI_UNKNOWN). Switches when one axis
                      clearly dominates (>0.7g), with natural hysteresis
                      between faces.
- getOrientationName() -> const char* "face_up" / "face_down" / "edge_*" /
                          "unknown". Convenient for printing/events.
- wasShaken() -> true ONCE per shake/tap (>1.8g spike). Edge-triggered:
                 reading it clears the flag. Poll it once per loop:
                   if (imu.wasShaken()) { trigger_thing(); }
                 For a "real shake gesture" (vs. a single tap), require
                 2-3 wasShaken() events within ~500ms before reacting.
- setShakeThreshold(g) -> tune sensitivity. Default 1.8g. Drop to ~1.4 for
                          light taps, raise to ~2.5 for vigorous shakes.

RAW API (only when needed):
- readAccelX/Y/Z()  -> float g, ±2g full-scale.
- readGyroX/Y/Z()   -> float deg/s, ±250°/s full-scale.
- At rest with the module flat face-up, readAccelZ() ≈ +1.0 and X/Y ≈ 0.
- Gyro has small zero-offset bias. If you read raw gyro, call
  calibrateGyro() ONCE in setup() with the board stationary. It averages
  100 samples and subtracts the bias from every subsequent read.

PATTERNS:
- Tilt → output mapping (LEDs, screens, motors): scale pitch/roll directly.
  Example: int hue = (int)((getRoll() + 180.0f) * 255.0f / 360.0f);
- Detect "face down" gesture: if (imu.getOrientationName() == "face_down").
  To avoid flapping, require it to stay there for ~200ms (track last
  orientation + a millis() timestamp).
- Shake-to-trigger: just `if (imu.wasShaken()) { ... }`. Don't try to roll
  your own threshold from raw accel; the driver already does it.
- "Is the board moving?": use total gyro magnitude:
    float w = sqrtf(gx*gx + gy*gy + gz*gz);  // deg/s
    bool moving = w > 30.0f;

AXES & ORIENTATION:
- The IMU's axes are the chip's axes, in the module's PCB frame: +Y points
  outward from the connector toward the module's free end, +X is one
  quarter-turn clockwise of +Y seen from above, +Z up out of the face.
  setMountRotation(deg) turns X-Y into the board frame (+X right edge, +Y
  top edge); the server's setup_order gives the degrees for the port
  (p2p/phases/firmware.py MOUNT_ROTATION_BY_EDGE). pitch/roll/orientation
  assume the board lies flat; mounted vertically, their meaning rotates
  with it. Tell the user this if their layout depends on orientation.
Suggested control

Three live linear gauges (X / Y / Z) for accelerometer or gyro values that update from incoming sensor events. Add a small 3D orientation indicator (rotating cube or plane) that reflects the live pose, and a 60-second sparkline per axis below.

Pinout V1.x · V2.x
Pinout
PinLineDirFunction
1HV–not connected
25V–not connected
33.3Vinputsupply
4GND–ground
5Data AbidirectionalI²C SDA
6Data BinputI²C SCL

from p2p/ground_truth/hardware/prototyping_line/modules/orientation_sensor.md

Chip
LSM6DSOXSTMicroelectronicsdatasheet ↗