Example 41: MPU6050 Gyroscope
About 1 min
Example 41: MPU6050 Gyroscope
Experiment Overview
MPU6050 is a 6-axis motion sensor (3-axis accelerometer + 3-axis gyroscope) that communicates via I2C. It can detect tilt angle, motion direction, vibration, and more. FastBee includes built-in MPU6050 driver in Standard / Full firmware.
Note: This feature requires
FASTBEE_ENABLE_I2C_SENSORS=1; disabled by default in Lite firmware.
Hardware Wiring
| Board Label | GPIO Pin | Connected Device |
|---|---|---|
| SDA | GPIO21 | MPU6050 SDA |
| SCL | GPIO22 | MPU6050 SCL |
MPU6050 I2C address: AD0 to GND = 0x68, AD0 to VCC = 0x69.
JSON Configuration Example
{
"peripherals": [
{
"id": "mpu6050_01",
"name": "MPU6050 Gyroscope",
"type": 38,
"enabled": false,
"pins": [21, 22],
"params": {
"category": "mpu6050",
"i2cAddress": "0x68"
}
}
]
}Data Channels
| Channel | Field Name | Unit | Description |
|---|---|---|---|
| 0 | accelX | m/s² | X-axis acceleration |
| 1 | accelY | m/s² | Y-axis acceleration |
| 2 | accelZ | m/s² | Z-axis acceleration |
| 3 | temperature | °C | Chip 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
- Click Peripheral Config in the left menu → Switch to Peripheral Execution tab
- Click New Rule button
- Fill in basic configuration:
- Rule Name:
Tilt Detection - Report Data: ✅ Enabled
- Enable: ✅ Enabled
- Rule Name:
Step 2: Configure Trigger (Timer Trigger)
Click Add Trigger button
Fill in trigger configuration:
Field Value Description Trigger Type Select Timer Trigger Periodic collection Timer Mode Select Fixed Interval Millisecond interval Interval 500500ms
Step 3: Configure Action (Sensor Read)
Click Add Action button
Fill in:
- Action Type: Select Sensor Read
- Target Peripheral: Select
mpu6050_01 - Data Field:
accelX(X-axis acceleration)
Click Save button
MPU6050 Data Channels
| Channel | Field Name | Unit | Description |
|---|---|---|---|
| 0 | accelX | m/s² | X-axis acceleration |
| 1 | accelY | m/s² | Y-axis acceleration |
| 2 | accelZ | m/s² | Z-axis acceleration |
| 3 | temperature | °C | Chip temperature |
Notes
- Firmware Version: Use Standard / Full firmware, or enable
FASTBEE_ENABLE_I2C_SENSORSin custom build - Calibration: Place the sensor at rest for zero-point calibration on first use
- Mounting Direction: Sensor mounting orientation determines axis correspondence
- Sampling Rate: 100-500ms sampling interval recommended for motion detection
- I2C Sharing: Can share the same I2C bus with BMP280 and other devices
