user73370: Can I program my ESP32 to send a string MQTT data while also blinking the InBuilt LED?
If yes, then how to do so
Thanks in advance

user77742: The ESP32 have two core, each core can do diferents tasks. Then, you can send data with one core and blink the LED with another core.
To do this, you need to use a multicore programming. I recommend to use the FreeRTOS (ESP32 support this). See more.
Look the example "Let's multitask: Blink with Hello" here, is that what  you want.
Read the documentation about the FreeRTOS in ESP32.
Example in Arduino IDE:
#include <Arduino_FreeRTOS.h>

// define two tasks for Blink & AnalogRead
void TaskBlink( void *pvParameters );
void TaskAnalogRead( void *pvParameters );

// the setup function runs once when you press reset or power the board
void setup() {

  // Now set up two tasks to run independently.
  xTaskCreate(
    TaskBlink
    ,  (const portCHAR *)"Blink"   // A name just for humans
    ,  128  // Stack size
    ,  NULL
    ,  2  // priority
    ,  NULL );

  xTaskCreate(
    TaskAnalogRead
    ,  (const portCHAR *) "AnalogRead"
    ,  128 // This stack size can be checked & adjusted by reading Highwater
    ,  NULL
    ,  1  // priority
    ,  NULL );

  // Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.
}

void loop()
{
  // Empty. Things are done in Tasks.
}

/*--------------------------------------------------*/
/*---------------------- Tasks ---------------------*/
/*--------------------------------------------------*/

void TaskBlink(void *pvParameters)  // This is a task.
{
  (void) pvParameters;

  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);

  for (;;) // A Task shall never return or exit.
  {
    digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
    digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
  }
}

void TaskAnalogRead(void *pvParameters)  // This is a task.
{
  (void) pvParameters;
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

  for (;;)
  {
    // read the input on analog pin 0:
    int sensorValue = analogRead(A0);
    // print out the value you read:
    Serial.println(sensorValue);
    vTaskDelay(1);  // one tick delay (15ms) in between reads for stability
  }
}

Reference.

73370: <p>Can I program my ESP32 to send a string MQTT data while also blinking the InBuilt LED?</p>
<p>If yes, then how to do so</p>
<p>Thanks in advance</p>
 77742: <p>The ESP32 have two core, each core can do diferents tasks. Then, you can send data with one core and blink the LED with another core.</p>
<p>To do this, you need to use a multicore programming. I recommend to use the <code>FreeRTOS</code> (ESP32 support this). <a href="https://www.freertos.org/" rel="nofollow noreferrer">See more</a>.</p>
<p>Look the example &quot;Let's multitask: Blink with Hello&quot; <a href="https://exploreembedded.com/wiki/Hello_World_with_ESP32_Explained" rel="nofollow noreferrer">here</a>, is that what  you want.</p>
<p>Read the <a href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html" rel="nofollow noreferrer">documentation</a> about the <code>FreeRTOS</code> in ESP32.</p>
<p>Example in Arduino IDE:</p>
<pre><code>#include &lt;Arduino_FreeRTOS.h&gt;

// define two tasks for Blink &amp; AnalogRead
void TaskBlink( void *pvParameters );
void TaskAnalogRead( void *pvParameters );

// the setup function runs once when you press reset or power the board
void setup() {

  // Now set up two tasks to run independently.
  xTaskCreate(
    TaskBlink
    ,  (const portCHAR *)&quot;Blink&quot;   // A name just for humans
    ,  128  // Stack size
    ,  NULL
    ,  2  // priority
    ,  NULL );

  xTaskCreate(
    TaskAnalogRead
    ,  (const portCHAR *) &quot;AnalogRead&quot;
    ,  128 // This stack size can be checked &amp; adjusted by reading Highwater
    ,  NULL
    ,  1  // priority
    ,  NULL );

  // Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.
}

void loop()
{
  // Empty. Things are done in Tasks.
}

/*--------------------------------------------------*/
/*---------------------- Tasks ---------------------*/
/*--------------------------------------------------*/

void TaskBlink(void *pvParameters)  // This is a task.
{
  (void) pvParameters;

  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);

  for (;;) // A Task shall never return or exit.
  {
    digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
    digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
  }
}

void TaskAnalogRead(void *pvParameters)  // This is a task.
{
  (void) pvParameters;
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

  for (;;)
  {
    // read the input on analog pin 0:
    int sensorValue = analogRead(A0);
    // print out the value you read:
    Serial.println(sensorValue);
    vTaskDelay(1);  // one tick delay (15ms) in between reads for stability
  }
}
</code></pre>
<p><a href="https://create.arduino.cc/projecthub/feilipu/using-freertos-multi-tasking-in-arduino-ebc3cc" rel="nofollow noreferrer">Reference</a>.</p>
