Section 9: Dual Core Setup

You are viewing Section 9 of 13

Before we go further into FastAccelStepper, let’s set up the dual core capability of the ESP32, because it may confuse you in the sketch.

I’m not going to cover this in too much detail, but here is the basic overview.

The ESP32 has 2 cores. We want the motor functions to run on one core, and the WiFi to run on the other core.

When the motor runs, it uses all of the resources of the core and Wi-Fi sometimes drops and disconnects. To fix this, we place them on separate cores.

By default, all Arduino code runs on Core 0. So we will create Core 1.

To create Core 1, we do it on line 26 in setup:

MotorTask //Motor Task
, "MotorTask" // A name just for humans
, 1024 * 4 // This stack size can be checked & adjusted by reading the Stack Highwater
, 3 // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
, 1);


Next, let’s create the function to run on this core, is needs to be named MotorTask like we named it above, but you can name it any function name you want.

On line 171 we have our function running in a loop on core 1 only. This is where the motor will run, ensuring it only runs on Core 1:

void MotorTask()




Course Sections:

Leave a comment