This page has moved into the new guide: IMU 9-Axis Gyro › mBlock › mBlock 5

IMU Gyro Sensor × mBlock 5 (Makeblock edition)

Back to IMU Gyro Sensor

The Makeblock edition of the IMU Gyro Sensor plugs into an RJ25 port on mBot, Ranger, Orion or MegaPi and is read with the MBC Pro Sensors extension v2 blocks. Installation and usable ports per board: Makeblock extension.

SPIKEEV3Arduino I2CmBlockMATRIXmicro:bit

Wiring

IMU Gyro Sensor × mBot

Sensor → mBot adapter → RJ25 port on the board (S1 = host TX, S2 = host RX). UART 38400 8N1.

Reporter blocks

Block Returns Id Meaning
IMU Gyro port [port] gyro 3D heading -32768~32767 ° 01 heading from the 3D quaternion, degrees, 0 at boot/zero, accumulates past 360 (wraps at ±32767, ~91 turns)
IMU Gyro port [port] fused heading -32768~32767 ° 02 3D gyro heading slowly corrected by the magnetometer, degrees, relative to the zero point; may exceed 360
IMU Gyro port [port] gyro 1D heading -32768~32767 ° 03 heading integrated about the yaw axis only, degrees, 0 at boot/zero; may exceed 360
IMU Gyro port [port] magnetic heading -32768~32767 ° 04 tilt-compensated magnetometer heading, degrees, relative to the zero point
IMU Gyro port [port] yaw rate -32768~32767 0.1 dps 05 angular rate about the yaw axis (getYawAxis()), 0.1 deg/s, same sign as the heading
IMU Gyro port [port] pitch angle -90~+90 ° 06 elevation of the board's printed X axis above horizontal: +90 pointing up, −90 pointing down, 0 level (from the gravity vector)
IMU Gyro port [port] pitch rate -32768~32767 0.1 dps 07 angular rate about the board's printed X axis, 0.1 °/s (right-hand rule, CCW seen from +X is positive); this is gyro X, not the derivative of 06
IMU Gyro port [port] magnetometer trust 0~255 08 how much the fusion trusts the magnetometer, 0255 (= 01 × 255)
IMU Gyro port [port] magnetic disturbance 0~255 0.01° 09 magnetic disturbance level 0~255 (degrees × 100, capped at 255)
IMU Gyro port [port] face up 0~5 0A which axis points up: 0 +X, 1 +Y, 2 +Z, 3 −X, 4 −Y, 5 −Z (physical axes)
IMU Gyro port [port] gyro [axis] -32768~32767 0.1 dps 10~12 10 X, 11 Y, 12 Z angular rate, 0.1 deg/s (physical axes, sign-corrected)
IMU Gyro port [port] accel [axis] -32768~32767 mg 13~15 13 X, 14 Y, 15 Z acceleration, mg (1000 = 1 g)
IMU Gyro port [port] mag [axis] -32768~32767 mG 16~18 16 X, 17 Y, 18 Z magnetic field, mG (milligauss)

Command blocks

Block Id Meaning
IMU Gyro port [port] zero heading E0 zero all four headings (zeroHeadings()); EV3 also accepts the stock gyro-reset WRITE 0x11
IMU Gyro port [port] start accelerometer calibration E1 start accelerometer calibration (= v1 0x20=0x01); F3 b4 = 1 meanwhile; ignored during magnetometer calibration (0B state 3 rejected)(F3 bit4 = 1 while running)
IMU Gyro port [port] end accelerometer calibration E2 finish accelerometer calibration and save to EEPROM (= v1 0x20=0x02); on success the mount axis is re-captured and headings are zeroed once the sensor is level and still (not immediately); rejected if not calibrating (0B state 3); failed check → 0B state 2
IMU Gyro port [port] start magnetometer calibration E3 start magnetometer calibration (= v1 0x20=0x03); F3 b5 = 1 meanwhile; ignored if the magnetometer has failed (0B state 3)(F3 bit5 = 1 while running)
IMU Gyro port [port] end magnetometer calibration E4 finish magnetometer calibration and save to EEPROM (= v1 0x20=0x04); headings zeroed right away on success; rejected if not calibrating (0B state 3); failed check → 0B state 2
IMU Gyro port [port] update all values FD reads the whole value table into a cache (FD pack-all); reporter blocks within the next 10 ms use the cache instead of asking one by one

Status blocks

The extension exposes each F3 bit as a boolean block:

bit Name Meaning
b0 ready (ready) always 1
b1 stationary (still) 1 = sensor is stationary
b2 mount axis captured (axisCaptured) 1 = mounting orientation determined (headings zeroed once after first capture)
b3 mount too tilted (mountTilted) 1 = mounted too far from level
b4 accel calibrating (accelCalibrating) 1 between E1 and E2
b5 mag calibrating (magCalibrating) 1 between E3 and E4
b6 fusion initialised (fusionInit) 1 = fused heading is valid
b7 mag auto-cal converged (magAutoCalDone) 1 = magnetometer auto-calibration offsets have converged

Packet format (for your own decoder)

mBlock 3-byte packet
Action Format
Read one value 主機送 [編號] → 回 [值低][值高][編號^值低^值高]
Write command 寫入命令 E0~EE:收齊參數後回 [00][00][編號] 再執行;20 ms 內沒收齊就丟棄
Unknown id [00][80][編號^0x80](= -32768)
Pack all (FD) Send [FD] → reply [AA][14][20 × int16 LE][xor], xor = AA ^ N ^ all data bytes; content = this value table in ascending id order (shared ids and commands excluded). The extension fetches it once and serves blocks from a 10 ms cache.
Shared ids F0 device ID, F1 protocol version, F2 firmware version, F3 status flags
FD pack-all packet

Sources and assumptions

Generated by _build/gen-reference.mjs from _build/protocol/imu.json (single source of truth, transcribed from the 2026-10-21 protocol decisions).

  • hw0 = 1(共識 #6);EV3 模式 4 = [0x6A | 1<<8, 韌體主×100+次, 0, 0](格式 B 再補 2 個 0),模式 5 改送俯仰角速度(取代 #65 放的 ID)。
  • EV3 鎖住模式 0/1/3 照盤點程式碼:0 = 陀螺 3D、1 = 融合航向、3 = [陀螺 1D, 磁力航向](INO:213 註解寫反,以程式為準)。
  • 0x22 照 R4 版(出貨版)鎖住:命令 49 = 三個航向 +32768 的「低 byte 在前、高 byte 在後」;盤點檔分析的是主韌體(高在前),主韌體 #67 改成跟 R4 版逐 byte 相同。命令 1012 = 0;0x01、0x0A、0x0F、F1~F4 都觸發航向歸零(刻意,不動)。
  • B-13:E1~E4 加速度計/磁力計校準開始/結束補回(v1 的 0x20 = 01/02/03/04),I2C 定案 §3 只列 E0。busyFlag:E1 → b4、E3 → b5。
  • 俯仰角範圍定案沒寫(韌體尚無現成值,#67 用 atan2 新算),range 先填「°」不給 min/max,韌體做好後再補。
  • 磁力信任度 08 = round(trust×255),磁場干擾度 09 = round(disturbance×100) 上限 255,朝上的面 0A = 軸號 + 3×負向:公式照盤點 I2C v1 0x34~0x36。
  • 角速度 1012 = round(dps×SIGN×10)、加速度 1315 = mm/s²×1000/9806.65、磁力 1618 = raw×SIGN×4/15:公式照盤點 I2C v1 0x220x24;mBlock 一併有(I2C 定案 §4 共用值表)。
  • 主對話 2026-10-22:06 俯仰角範圍 −90~+90、07 = gyro X(照字面),取自 F5 韌體實作。
  • Block wording follows the v2.0.0 extension generator build_mext.js; this page is generated from the same JSON.
Email for a quoteBuying Guide