Multi task ESP32 reboot

ขอความรู้เรือง Multi Task บน Esp32 หน่อยครับ

พอรันงานไปประมาณนึงแล้ว บอร์ดมัน reboot อะครับ ทุกๅครั้งที่ 1679 มันเกิดจะอะไรหรอครับ



const TickType_t xDelay2000ms = pdMS_TO_TICKS(2000); 

// void Taskone( void *pvParam);

void setup() {
  Serial.begin(115200);  
  delay(2000);  

  xTaskCreatePinnedToCore(Taskone, "Taskone", 2000, NULL, 1, NULL, 0);
}

void loop() {

}


int read(){
    int i = 10;
    return i;
}

void Taskone(void *pvParam){
int sec = 0;
    while(1){
        if(read() == 10){
        Serial.println("Task1 Running");
        }
    Serial.println(String("time : cont >>") + sec);
    sec++;
    }

}

ลอง Code ชุดนี้ดูครับ

TaskHandle_t Task1;
TaskHandle_t Task2;
TaskHandle_t Task3;
TaskHandle_t Task4;
TaskHandle_t Task5;
TaskHandle_t Task6;
TaskHandle_t Task7;
TaskHandle_t Task8;
TaskHandle_t Task9;
TaskHandle_t Task10;
TaskHandle_t Task11;
TaskHandle_t Task12;



void setup() {


  Serial.begin(115200);
//create a task that will be executed in the Task1code() function, with priority 1 and executed on core 0
  xTaskCreatePinnedToCore(
    Task1code,   /* Task function. */
    "Task1",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task1,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
  delay(500);

  //create a task that will be executed in the Task2code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task2code,   /* Task function. */
    "Task2",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task2,      /* Task handle to keep track of created task */
    0);          /* pin task to core 1 */
  delay(500);


//create a task that will be executed in the Task3code() function, with priority 1 and executed on core 0
  xTaskCreatePinnedToCore(
    Task3code,   /* Task function. */
    "Task3",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task3,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
  delay(500);


//create a task that will be executed in the Task4code() function, with priority 1 and executed on core 0
  xTaskCreatePinnedToCore(
    Task4code,   /* Task function. */
    "Task4",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task4,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
  delay(500);

  //create a task that will be executed in the Task5code() function, with priority 1 and executed on core 0
  xTaskCreatePinnedToCore(
    Task5code,   /* Task function. */
    "Task5",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task5,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
  delay(500);

  //create a task that will be executed in the Task6code() function, with priority 1 and executed on core 0
  xTaskCreatePinnedToCore(
    Task6code,   /* Task function. */
    "Task6",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task6,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
  delay(500);


    //create a task that will be executed in the Task7code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task7code,   /* Task function. */
    "Task7",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task7,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);



    //create a task that will be executed in the Task8code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task8code,   /* Task function. */
    "Task8",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task8,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);



    //create a task that will be executed in the Task9code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task9code,   /* Task function. */
    "Task9",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task9,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);



    //create a task that will be executed in the Task10code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task10code,   /* Task function. */
    "Task10",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task10,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);



    //create a task that will be executed in the Task11code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task11code,   /* Task function. */
    "Task11",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task11,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);



    //create a task that will be executed in the Task12code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task12code,   /* Task function. */
    "Task12",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task12,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);


}


//Task1code: blinks an LED every 1000 ms
void Task1code( void * pvParameters ) {
  Serial.print("Task1 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(1000);
  }
}

//Task2code: blinks an LED every 700 ms
void Task2code( void * pvParameters ) {
  Serial.print("Task2 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(700);
  }
}



//Task3code: blinks an LED every 2000 ms
void Task3code( void * pvParameters ) {
  Serial.print("Task3 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}


//Task4code: blinks an LED every 2000 ms
void Task4code( void * pvParameters ) {
  Serial.print("Task4 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}


//Task5code: blinks an LED every 2000 ms
void Task5code( void * pvParameters ) {
  Serial.print("Task5 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}



//Task6code: blinks an LED every 2000 ms
void Task6code( void * pvParameters ) {
  Serial.print("Task6 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}


//Task7code: blinks an LED every 2000 ms
void Task7code( void * pvParameters ) {
  Serial.print("Task7 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}


//Task8code: blinks an LED every 2000 ms
void Task8code( void * pvParameters ) {
  Serial.print("Task8 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}



//Task9code: blinks an LED every 2000 ms
void Task9code( void * pvParameters ) {
  Serial.print("Task9 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}



//Task10code: blinks an LED every 2000 ms
void Task10code( void * pvParameters ) {
  Serial.print("Task10 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}


//Task11code: blinks an LED every 2000 ms
void Task11code( void * pvParameters ) {
  Serial.print("Task11 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}



//Task12code: blinks an LED every 2000 ms
void Task12code( void * pvParameters ) {
  Serial.print("Task12 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}



void loop() {

}




อันนี้ตัวเต็มที่ผมทดสอบอยู่ AP_WiFi_Manager_Multicore 15_01_2563
หมายเหตุให้ดูเป็นตัวอย่างในเรื่องของตำแหน่งการวางครับ

#include <FS.h>                   //this needs to be first, or it all crashes and burns...
#include <SPIFFS.h>//เพิ่ม

#include <WiFi.h>          //https://github.com/esp8266/Arduino
#include <WiFiClient.h>


//needed for library
#include <DNSServer.h>
#include <WebServer.h>
#include <WiFiManager.h>          //https://github.com/tzapu/WiFiManager
#include <ArduinoJson.h>       //Ver 5.13.4   //https://github.com/bblanchon/ArduinoJson


//----------------------------------  กำหนดหมายเลขของขาของ Node MCU ESP32  --------------------------------------------//

const int Ledblynk = 2;                     // ใช้ไฟ LED สีฟ้า ของบอร์ด MCU ESP32 ให้มีสัญญาณไฟกระพริบ ตาม Code ที่เขียน
const int AP_Config = 23;                // ใช้เป็นปุ่มกด เพื่อเข้า AP Config ได้ตามความต้องการของผู้ใช้
//------------------------------------------------------------------------------------------------------------------------//



bool shouldSaveConfig = false;

//callback notifying us of the need to save config
void saveConfigCallback () {
  Serial.println("Should save config");
  shouldSaveConfig = true;
}
//------------------------------------------------------------------------------------------------------------------------//


//-------------สำหรับ Server local ที่แจกให้ เพิ่ม **** แค่ 2 บรรทัดนี้--------------   (ถ้าเป็น Blynk Server ปกติไม่ต้องใส่)  ----------//
//char server[] = "oasiskit.com";
//int port = 8080;
//------------------------------------------------------------------------------------------------------------------------//

TaskHandle_t Task1;
TaskHandle_t Task2;
TaskHandle_t Task3;
TaskHandle_t Task4;
TaskHandle_t Task5;
TaskHandle_t Task6;
TaskHandle_t Task7;
TaskHandle_t Task8;
TaskHandle_t Task9;
TaskHandle_t Task10;
TaskHandle_t Task11;
TaskHandle_t Task12;




//------------------------------------------------------------------------------------------------------------------------//
//*********************************************       void setup        **************************************************//
//------------------------------------------------------------------------------------------------------------------------//

void setup() {

  //-------IO NODE MCU Esp32-------//
  pinMode(Ledblynk, OUTPUT);      //กำหนดโหมดใช้งานให้กับขา Ledblynk เป็นขา สัญญาณไฟ ในสภาวะต่างๆ
  pinMode(AP_Config, INPUT_PULLUP);//กำหนดโหมดใช้งานให้กับขา AP_Config เป็นขา กดปุ่ม ค้าง เพื่อตั้งค่า AP config


  // ให้ LED ทั้งหมดดับก่อน
  digitalWrite(Ledblynk, LOW);//ให้หลอด LED สีฟ้าดับก่อน

  //-------------------------------//


  Serial.begin(115200);
  //-------------------------------//





  //*************************    การ อ่าน  เขียนค่า WiFi + Password ]ลงใน Node MCU ESP32   ************//

  //read configuration from FS json
  Serial.println("mounting FS...");//แสดงข้อความใน Serial Monitor

  if (SPIFFS.begin(true)) {
    Serial.println("mounted file system");
    if (SPIFFS.exists("/config.json")) {
      //file exists, reading and loading
      Serial.println("reading config file");
      File configFile = SPIFFS.open("/config.json", "r");
      if (configFile) {
        Serial.println("opened config file");
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr<char[]> buf(new char[size]);

        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        json.printTo(Serial);
        if (json.success()) {
          Serial.println("\nparsed json");

        } else {
          Serial.println("failed to load json config");//แสดงข้อความใน Serial Monitor
        }
      }
    }
  } else {
    Serial.println("failed to mount FS");//แสดงข้อความใน Serial Monitor
  }
  //end read


  //*************************   จบการ อ่าน  เขียนค่า WiFi + Password ]ลงใน Node MCU ESP32   **********//









  //**************************        AP AUTO CONNECT   ********************************************//

  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  WiFiManager wifiManager;

  //set config save notify callback
  wifiManager.setSaveConfigCallback(saveConfigCallback);


  for (int i = 5; i > -1; i--) {  // นับเวลาถอยหลัง 5 วินาทีก่อนกดปุ่ม AP Config
    digitalWrite(Ledblynk, HIGH);
    delay(500);
    digitalWrite(Ledblynk, LOW);
    delay(500);
    Serial.print (String(i) + " ");//แสดงข้อความใน Serial Monitor
  }


  if (digitalRead(AP_Config) == LOW) {
    digitalWrite(Ledblynk, HIGH);
    Serial.println("Button Pressed");//แสดงข้อความใน Serial Monitor



    // wifiManager.resetSettings();//ให้ล้างค่า SSID และ Password ที่เคยบันทึกไว้
    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); //load the flash-saved configs
    esp_wifi_init(&cfg); //initiate and allocate wifi resources (does not matter if connection fails)
    delay(2000); //wait a bit
    if (esp_wifi_restore() != ESP_OK)

    {
      Serial.println("WiFi is not initialized by esp_wifi_init ");
    } else {
      Serial.println("WiFi Configurations Cleared!");
    }

  }



  if (!wifiManager.autoConnect("PUYIOT ESP32 AP CONFIG")) {
    Serial.println("failed to connect and hit timeout");//แสดงข้อความใน Serial Monitor
    delay(3000);
    //reset and try again, or maybe put it to deep sleep
    ESP.restart();//แก้ เดิม ESP.reset(); ใน Esp8266
    delay(5000);

  }

  Serial.println("Connected.......OK!)");//แสดงข้อความใน Serial Monitor
  //strcpy(blynk_token, custom_blynk_token.getValue());


  //save the custom parameters to FS
  if (shouldSaveConfig) {
    Serial.println("saving config");
    DynamicJsonBuffer jsonBuffer;
    JsonObject& json = jsonBuffer.createObject();
    
    File configFile = SPIFFS.open("/config.json", "w");

    if (!configFile) {
      Serial.println("failed to open config file for writing");//แสดงข้อความใน Serial Monitor

    }
    json.printTo(Serial);
    json.printTo(configFile);
    configFile.close();
    //end save
  }

  //**************************    จบ    AP AUTO CONNECT   *****************************************//




  Serial.println("local ip"); //แสดงข้อความใน Serial Monitor
  delay(100);
  Serial.println(WiFi.localIP());//แสดงข้อความใน Serial Monitor
  Serial.println("gateway");
  delay(100);
  Serial.println(WiFi.gatewayIP());
  Serial.println("subnetMask");
  delay(100);
  Serial.println(WiFi.subnetMask());
  Serial.println("SSID");
  delay(100);
  Serial.println(WiFi.SSID());
  Serial.println("Password");
  delay(100);
  Serial.println(WiFi.psk());



//create a task that will be executed in the Task1code() function, with priority 1 and executed on core 0
  xTaskCreatePinnedToCore(
    Task1code,   /* Task function. */
    "Task1",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task1,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
  delay(500);

  //create a task that will be executed in the Task2code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task2code,   /* Task function. */
    "Task2",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task2,      /* Task handle to keep track of created task */
    0);          /* pin task to core 1 */
  delay(500);


//create a task that will be executed in the Task3code() function, with priority 1 and executed on core 0
  xTaskCreatePinnedToCore(
    Task3code,   /* Task function. */
    "Task3",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task3,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
  delay(500);


//create a task that will be executed in the Task4code() function, with priority 1 and executed on core 0
  xTaskCreatePinnedToCore(
    Task4code,   /* Task function. */
    "Task4",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task4,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
  delay(500);

  //create a task that will be executed in the Task5code() function, with priority 1 and executed on core 0
  xTaskCreatePinnedToCore(
    Task5code,   /* Task function. */
    "Task5",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task5,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
  delay(500);

  //create a task that will be executed in the Task6code() function, with priority 1 and executed on core 0
  xTaskCreatePinnedToCore(
    Task6code,   /* Task function. */
    "Task6",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task6,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
  delay(500);


    //create a task that will be executed in the Task7code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task7code,   /* Task function. */
    "Task7",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task7,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);



    //create a task that will be executed in the Task8code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task8code,   /* Task function. */
    "Task8",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task8,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);



    //create a task that will be executed in the Task9code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task9code,   /* Task function. */
    "Task9",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task9,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);



    //create a task that will be executed in the Task10code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task10code,   /* Task function. */
    "Task10",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task10,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);



    //create a task that will be executed in the Task11code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task11code,   /* Task function. */
    "Task11",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task11,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);



    //create a task that will be executed in the Task12code() function, with priority 1 and executed on core 1
  xTaskCreatePinnedToCore(
    Task12code,   /* Task function. */
    "Task12",     /* name of task. */
    10000,       /* Stack size of task */
    NULL,        /* parameter of the task */
    1,           /* priority of the task */
    &Task12,      /* Task handle to keep track of created task */
    1);          /* pin task to core 0 */
  delay(500);















}


//------------------------------------------------------------------------------------------------------------------------//
//*********************************************   จบ  void setup        **************************************************//
//------------------------------------------------------------------------------------------------------------------------//



//Task1code: blinks an LED every 1000 ms
void Task1code( void * pvParameters ) {
  Serial.print("Task1 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(1000);
  }
}

//Task2code: blinks an LED every 700 ms
void Task2code( void * pvParameters ) {
  Serial.print("Task2 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(700);
  }
}



//Task3code: blinks an LED every 2000 ms
void Task3code( void * pvParameters ) {
  Serial.print("Task3 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}


//Task4code: blinks an LED every 2000 ms
void Task4code( void * pvParameters ) {
  Serial.print("Task4 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}


//Task5code: blinks an LED every 2000 ms
void Task5code( void * pvParameters ) {
  Serial.print("Task5 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}



//Task6code: blinks an LED every 2000 ms
void Task6code( void * pvParameters ) {
  Serial.print("Task6 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}


//Task7code: blinks an LED every 2000 ms
void Task7code( void * pvParameters ) {
  Serial.print("Task7 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}


//Task8code: blinks an LED every 2000 ms
void Task8code( void * pvParameters ) {
  Serial.print("Task8 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}



//Task9code: blinks an LED every 2000 ms
void Task9code( void * pvParameters ) {
  Serial.print("Task9 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}



//Task10code: blinks an LED every 2000 ms
void Task10code( void * pvParameters ) {
  Serial.print("Task10 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}


//Task11code: blinks an LED every 2000 ms
void Task11code( void * pvParameters ) {
  Serial.print("Task11 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}



//Task12code: blinks an LED every 2000 ms
void Task12code( void * pvParameters ) {
  Serial.print("Task12 running on core ");
  Serial.println(xPortGetCoreID());

  for (;;) {

    delay(2000);
  }
}









//------------------------------------------------------------------------------------------------------------------------//
//*********************************************       void Loop        ***************************************************//
//------------------------------------------------------------------------------------------------------------------------//


void loop() {


 

}

//------------------------------------------------------------------------------------------------------------------------//
//*********************************************      จบ void Loop       **************************************************//
//------------------------------------------------------------------------------------------------------------------------//
2 Likes

สาเหตุ เกิดจากการวางตำแหน่งของ Code หรอครับ

ลองดูโค้ดที่ให้ไปหรือยังครับ

1 Likes

ครับ ผมพอจะเข้าใจแล้วครับ
CPU core 0 หมาะสำหรับโปรแกรมที่รันงานครั้งเดียว
CPU core 1 เหมาะสำหรับโปรแกรมที่รันงานซ้ำๆ loop

ใช่หรือป้าวครับ ถ้ามีมากกว่านี้บอกเพิ่มเติมได้เลยครับ แฮ่กๆ :sweat_smile:

ขึ้นอยู่กับเงื่อนไขต่างๆว่าเงื่อนไขเหล่านั้นเป็นต้องรันบน Core 1 หรือเปล่า แต่ถ้าอุปกรณ์ตัวไหนไม่ได้เกี่ยวข้องกับ Core 1 ก็สามารถใช้ของCore 0ได้ครับ อีกไม่นานผมจะลงบทความเกี่ยวกับการใช้อุปกรณ์ต่างๆ ร่วมกับ ESP32 ครับ จาก code ที่ให้ไป ผมแสดงให้เห็นถึงการแบ่ง Core เท่านั้นครับ ส่วน เงื่อนไขที่เกี่ยวของของอุปกรณ์ต่าง ที่อยู่ใน

 for (;;) {
    delay(1000);
  }

ก็ขึ้นอยู่กับเราและความเหมาะสมในการใช้งานครับ

1 Likes

โอเครครับ ขอบคุณครับ เดี๋ยวจะ รออ่านนะครับ :grin: :grin:

ถ้ามีปัญหาอีกผมจะมาต่อกระทู้นี้นะครับ