ESP32_Receiver-Direct-MPU6050-v3.0
Direct drive receiver that combines ESP-NOW command input, dual motor PWM control, and MPU6050-based orientation estimation.
System architecture
This project is organized into modular components: MotorController for output drive, MpuEstimator for IMU fusion updates, and DriveModes for behavior-level control decisions from joystick commands.
Command intake and safety timeout
The receiver stores the latest ESP-NOW payload in a critical section and applies a timeout guard. If no fresh packet arrives within the configured window, the loop switches to a neutral command to prevent runaway motion.
const uint32_t COMMAND_TIMEOUT_MS = 500;
if (!freshSnapshot || (now - lastCommandSnapshotMs > COMMAND_TIMEOUT_MS)) {
commandSnapshot = neutralCommand();
}
Motor output mapping
Left and right channels are mapped to independent RPWM/LPWM and enable pins. The control layer writes target speeds and updates output each loop with ramp support.
LEFT: RPWM=18 LPWM=19 LEN=21 REN=22
RIGHT: RPWM=25 LPWM=26 LEN=27 REN=14
IMU integration
MPU6050 is configured over I2C using custom SDA/SCL pins and updated with loop delta-time. The resulting yaw/pitch/roll state is provided to drive logic for mode-aware control.
const int I2C_SDA_PIN = 32;
const int I2C_SCL_PIN = 33;
imuEstimator.update(dt, imuState);
Use case
Use this variant for motion-aware receivers where orientation should influence direction control and stabilization behavior, while still accepting the standard remote payload format.
Build / Flash
cd firmware/receiver/direct-bts-mpu6050/v3.0
pio run
pio run --target upload