🛠 First Setup of the Encoder Motor Driver

M5Stack Encoder Motor Driver Unit (DRV8837DSGR) · intermediaire · Apprenez à brancher, alimenter et initialiser l'unité DRV8837DSGR pour un premier test fonctionnel.

Objectives

This tutorial aims to perform the first physical connection and power-up of the M5Stack Encoder Motor Driver Unit (DRV8837DSGR). You will learn to identify connectors, provide correct power, and verify initial I2C communication. By the end, you will know if your unit is functional and ready for motor control.

Required Materials

Steps

  1. Component Check : Ensure the unit has no visible damage. The default I2C address is 0x2F. If you change the address, note it immediately.
  2. Motor Connection : Connect the motor to the motor terminals on the unit. For a 6-wire motor, follow the standard pinout (Phase A/B and Encoder A/B). For a TT motor, connect the two power wires.
  3. External Power : Connect your DC source (6-12V) to the external power terminals (GND and VCC). The unit will convert this to internal 5V for the motor (max 1.2A).
  4. I2C Link : Connect the unit to your master board via the Grove port. Ensure SDA and SCL lines are correctly connected. Do not connect motor power before verifying the logical link.
  5. Software Initialization : Open Arduino IDE. Install the M5Stack library. Create a new project. Include M5Unified.h or the specific driver library if available.
  6. Test Code : Write a minimal code to initialize I2C and scan the bus. Basic command example:
#include <Wire.h>
void setup() {
  Serial.begin(115200);
  Wire.begin();
  Serial.println("Scanning I2C...");
  for (byte i = 8; i < 120; i++) {
    Wire.beginTransmission(i);
    if (Wire.endTransmission() == 0) {
      Serial.print("Found address: ");
      Serial.println(i, HEX);
    }
  }
}
void loop() {}
  1. Upload : Compile and upload the code to your master board.

Verification

Open the serial monitor at 115200 bauds. You should see the address 0x2F displayed in the I2C scanner. If the address appears, communication is established. The WS2812C RGB LED may light up briefly at startup, indicating correct power. If no address is found, check SDA/SCL connections and power supply.

Further Steps

Once communication is confirmed, explore closed-loop control modes. Test encoder reading to measure actual motor speed. You can then implement a simple PID to maintain constant speed despite variable loads.

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials