ESP32 wont compile with Mobatools library

Hello

I am having an issue compiling Mobotools library with an ESP32. I am currently using an Arduino Mega and everything works fine using this library, however I wanted to consider using an ESP32 because it is faster and would enable me to run multiple stepper motors at a high speed and also use multiple timers to avoid code blocking.

I've installed the CP210 VCP_Windows driver, installed espressif board manager, added board manager url (https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json), selected ESP32 dev module in the Arduino IDE boards menu. The board works as I tested it using a buzzer and blink test, however I had to link a 10uf capacitor from EN pin to ground pin to force it into boot mode.

Windows 11
MobaTools library version 2.4.3
Arduino IDE version 1.8.19
Espressif board manager version 2.0.7
CP210 VCP_Windows driver v6.7
Board - AZDelivery ESP32-DevKitC NodeMCU WiFi WLAN CP2102 WROOM-32D

Additionally, if don't comment out MoToTimer pause, it also throws a compilation error saying "'MoToTimer pause' redeclared as different kind of symbol". This compiles and works perfectly fine on an Arduino Mega.

Thanks in advance for any advice.

#include <MobaTools.h>

const byte stepPin =  2;
const byte dirPin  = 5; 

const int stepsPerRev = 300;
 long  targetPos =  0;
long nextPos = 300;



MoToStepper myStepper ( stepsPerRev, STEPDIR );
MoToTimer pause;                  
bool stepperRunning;

int MotorDirection =1;
int StartMotor =0;
int RUNONCE = 0;
String    command;
const int enaPin = 51; // 8; 

void setup() {
   Serial.begin(9600);
 // pause.setTime( 100 );

     delay(1000);
  stepperRunning = false; 

     Serial.println("ready to go!!!!");  
  myStepper.attach( stepPin, dirPin );
    myStepper.setSpeed( 2500 );  
 pinMode(enaPin, OUTPUT);
 digitalWrite(enaPin, HIGH);

}

void loop() {

if (Serial.available()){
   if (RUNONCE == 0){
  RUNONCE = 1;
   digitalWrite(enaPin, LOW);
 }

command = Serial.readStringUntil('\n');
command.trim();

if (command.equals("1"))
{
  Serial.println("command 1 forward");
 motor_cw() ; 
stepperRunning = true; 
}

else if  (command.equals("2")){
    Serial.println("command 2  backward");
    motor_ccw() ; 
    stepperRunning = true; 
}
  
else if  (command.equals("d")){ 
  myStepper.stop( );

  }
 
}
 
}

void motor_cw() {
 Serial.println("clock wise");
 Serial.print(targetPos);
 targetPos = targetPos - nextPos; //700;
   myStepper.moveTo( targetPos );

// MotorDirection =1;

     StartMotor =1; 
}

void motor_ccw() {

  Serial.println("counter clock wise");
   Serial.print(targetPos);
  targetPos = targetPos + nextPos;
  myStepper.moveTo( targetPos ); 

    StartMotor =1; 
}


esp mobotools error.txt (692.7 KB)

Apparently there is an incompatibility between V2.x of the ESP32 board software and MobaTools. There is already an issue on Github about this problem. With V1.0.6 of ESP32 your Sketch compiles fine.
Unfortunately I don't have time to investigate this problem at the moment, so you will have to go back to 1.0.6 if you want to use MobaTools on ESP32.
I hope to take care of this problem in the summer.

N.B. 'pause' is a very generic name that is obviously used for another software component of the Arduino software. You should choose a different name.

1 Like

But we're going to winter :innocent: :smiley:

Hi MicroBahner

I installed ESP32 V1.0.6 and it now works :tada:, the only thing I have to play around with is the stepper speed & steps per revolution because the timing and speed seem different from when I used an Arduino mega (but that's a minor issue I can sort out).

How would I know once a solution is found for MobaTools to work with V2x of the ESP32 board software? I would greatly appreciate if you could message me once it's been resolved because I would like to use the latest ESP32 board software eventually.

Thank you once again for helping me and providing a solution.

There will of course be a new version in the Library Manager. But I will also set a flag for me and inform you directly. But it will surely take a while...

Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.