Kind of an old thread but I wanted to respond since it may help others who are trying to get this module to work, not much out there on the Arduino coding side.
I believe the issue might be the pin assignment for step and dir, it's actually printed on the PCB. For the Core2 X, Y, Z step = 13, 27, 2 and dir = 14, 19, 0 respectively. So I'm not sure why STEP_PIN is set to 15, maybe this is the legacy Core?
I used the same referenced Stepmotor code (https://github.com/m5stack/M5Module-Stepmotor) and did get it working eventually. Here is some very basic example code that may help:
#include <M5Unified.h> #include "Module_Stepmotor.h" // change to CORE2 if using Core2 #define CORE_S3 #ifdef CORE_S3 static const int X_STEP_PIN = 18; static const int X_DIR_PIN = 17; static const int Y_STEP_PIN = 6; static const int Y_DIR_PIN = 7; static const int Z_STEP_PIN = 13; static const int Z_DIR_PIN = 0; static const int SDA_PIN = 12; static const int SCL_PIN = 11; #elif defined CORE2 static const int X_STEP_PIN = 13; static const int X_DIR_PIN = 14; static const int Y_STEP_PIN = 27; static const int Y_DIR_PIN = 19; static const int Z_STEP_PIN = 2; // Not sure about this one static const int Z_DIR_PIN = 0; static const int SDA_PIN = 21; static const int SCL_PIN = 22; #endif static Module_Stepmotor driver; void setup() { Wire.begin(SDA_PIN, SCL_PIN, 400000UL); driver.init(Wire, 0x27); driver.resetMotor(0, 0); driver.resetMotor(1, 0); driver.resetMotor(2, 0); driver.enableMotor(1); // PWM, sets the speed of the stepper motor, adjust accordingly ledcSetup(0, 500, 8); // XYZ step ledcAttachPin(X_STEP_PIN, 0); ledcAttachPin(Y_STEP_PIN, 0); ledcAttachPin(Z_STEP_PIN, 0); ledcWrite(0, 127); // XYZ dir pinMode(X_DIR_PIN, OUTPUT); digitalWrite(X_DIR_PIN, 1); pinMode(Y_DIR_PIN, OUTPUT); digitalWrite(Y_DIR_PIN, 1); pinMode(Z_DIR_PIN, OUTPUT); digitalWrite(Z_DIR_PIN, 1); } void loop() { digitalWrite(X_DIR_PIN, 0); delay(2000); digitalWrite(X_DIR_PIN, 1); delay(2000); }