Skip to content

Example 41: MPU6050 Gyroscope ​

Experiment Overview ​

MPU6050 is a 6-axis I2C motion sensor. FastBee includes the driver in the release baseline.

Note: This feature requires FASTBEE_ENABLE_I2C_SENSORS=1 and active i2cSensors.

Hardware Wiring ​

Board LabelGPIO PinConnected Device
SDAGPIO21MPU6050 SDA
SCLGPIO22MPU6050 SCL

MPU6050 I2C address: AD0 to GND = 0x68, AD0 to VCC = 0x69.

JSON Configuration Example ​

json
{
  "peripherals": [
    {
      "id": "mpu6050_01",
      "name": "MPU6050 Gyroscope",
      "type": 38,
      "enabled": false,
      "pins": [21, 22],
      "params": {
        "category": "mpu6050",
        "i2cAddress": "0x68"
      }
    }
  ]
}

Data Channels ​

ChannelField NameUnitDescription
0accelXm/s²X-axis acceleration
1accelYm/s²Y-axis acceleration
2accelZm/s²Z-axis acceleration
3temperature°CChip temperature

Peripheral Execution Linkage ​

Scenario: Tilt Detection (Timer Trigger) ​

Feature: Periodically read MPU6050 acceleration data to detect device tilt

Web UI Configuration Steps ​

Step 1: Create Rule

  1. Click Peripheral Execution in the left menu
  2. Click New Rule button
  3. Fill in basic configuration:
    • Rule Name: Tilt Detection
    • Report Data: ✅ Enabled
    • Enable: ✅ Enabled

Step 2: Configure Trigger (Timer Trigger)

  1. Click Add Trigger button

  2. Fill in trigger configuration:

    FieldValueDescription
    Trigger TypeSelect Timer TriggerPeriodic collection
    Timer ModeSelect Fixed IntervalMillisecond interval
    Interval500500ms

Step 3: Configure Action (Sensor Read)

  1. Click Add Action button

  2. Fill in:

    • Action Type: Select Sensor Read
    • Target Peripheral: Select mpu6050_01
    • Data Field: accelX (X-axis acceleration)
  3. Click Save button

MPU6050 Data Channels ​

ChannelField NameUnitDescription
0accelXm/s²X-axis acceleration
1accelYm/s²Y-axis acceleration
2accelZm/s²Z-axis acceleration
3temperature°CChip temperature

Notes ​

  1. Firmware State: Confirm i2cSensors is compiled and active
  2. Calibration: Place the sensor at rest for zero-point calibration on first use
  3. Mounting Direction: Sensor mounting orientation determines axis correspondence
  4. Sampling Rate: 100-500ms sampling interval recommended for motion detection
  5. I2C Sharing: Can share the same I2C bus with BMP280 and other devices

FastBee | fastbee.cn