🛠 First Connection and Startup of the 4-Encoder Motor Driver

Unit 4-Encoder Motor Driver (DRV8837DSGR) · debutant · Apprenez à alimenter, connecter et vérifier la communication I2C de votre module DRV8837 pour la première fois.

Objectifs

This tutorial guides you through the initial setup of the M5Stack Unit 4-Encoder Motor Driver (DRV8837DSGR). The goal is to successfully power the module, connect it to an host controller (such as an M5StickC or I2C-compatible Arduino), and confirm that I2C communication is established. We will not drive the motors yet, but we will verify the module's presence on the bus.

Matériel nécessaire

Étapes

  1. Hardware Preparation: Ensure the host controller is powered off. Locate the two Grove HY2.0-4P ports on the DRV8837 module. One is the input (IN) and the other the output (OUT) for I2C daisy-chaining.
  1. I2C Connection: Connect a Grove cable between the host controller's Grove port and the DRV8837 module's Grove IN port. I2C communication uses SDA and SCL lines. By default, the module's I2C address is 0x24.
  1. Power Supply:
  1. Software Configuration: Open the Arduino IDE. Install the M5Stack library or a standard I2C library. Upload the following test code to your controller:
#include <Wire.h>

void setup() {
  Serial.begin(115200);
  Wire.begin(); // Initialize I2C bus

  Serial.println("Searching for DRV8837 module...");
  
  // Default module address
  byte address = 0x24;
  
  Wire.beginTransmission(address);
  byte error = Wire.endTransmission();

  if (error == 0) {
    Serial.println("Module found at address 0x24!");
  } else {
    Serial.print("Module not found. I2C Error: ");
    Serial.println(error);
  }
}

void loop() {
  // Nothing to do in loop for this test
  delay(1000);
}
  1. Physical Verification: Once the code is uploaded, open the Serial Monitor at 115200 bauds. If everything is correct, the message "Module found" will appear. The integrated WS2812C RGB LED may light up depending on the module's initial firmware state.

Vérification

Pour aller plus loin

Once communication is established, you can explore basic commands to configure control modes (open loop vs closed loop) and test the soft-start of a gear motor connected to one of the four PH2.0-6P connectors.

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials