vTaskDelay is basically the same as Arduino delay() But if I remember correctly you have to divide it by the ticks per millisecond See the ESP documentation you can search for vTaskDelay and you'll see a number of results Answer from Mountain-Ad-5639 on reddit.com
🌐
ESP32 ESP-IDF
esp32tutorials.com › home › esp32 esp-idf freertos timer and delay using esp-idf
ESP32 ESP-IDF FreeRTOS Timer and Delay using ESP-IDF
August 15, 2022 - In the function vTaskDelay(), the delay that we obtain is that of the particular task in the number of ticks. ... In the following program we will measure the timer before and after a delay of 1 tick.
Discussions

vTaskDelay inaccurate (IDFGH-6964)
I would like to understand how does vTaskDelay work exactly. I am having issues with time sensitive tasks. For my project, I need to create a task that would repeat itself precisely every 2 seconds. +-1ms is acceptable but not more than ... More on github.com
🌐 github.com
4
March 16, 2022
c - ESP IDF: Task never leaves vTaskDelay() - Stack Overflow
I am building a system that creates a WLAN AP over which the end user can Connect/disconnect the ESP to another AP ( For example a router) by posting a JSON String to a URL. In APSTA mode. When thi... More on stackoverflow.com
🌐 stackoverflow.com
Task watchdog got triggered - it is fixed with a vTaskDelay of 10ms but is this a bug? (IDFGH-5818)
Task watchdog got triggered - it is fixed with a vTaskDelay of 10ms but is this a bug? (IDFGH-5818)#1646 More on github.com
🌐 github.com
4
February 21, 2018
Better Explanation for vTaskDelay (FreeRTOS) ?

vTaskDelay is basically the same as Arduino delay() But if I remember correctly you have to divide it by the ticks per millisecond See the ESP documentation you can search for vTaskDelay and you'll see a number of results

More on reddit.com
🌐 r/esp32
20
6
September 15, 2021
🌐
Medium
aliafshar.medium.com › esp-idf-tutorials-part-2-delay-75a6c29e05e4
ESP-IDF for Arduino Users, Tutorials Part 2: Delay | by Ali Afshar | Medium
January 6, 2021 - Anyway, the IDF has you covered. You can delay, but amazingly it appears that once you multi-task (which you will with Free RTOS), the delay doesn’t block the other tasks from running. ... Delay doesn’t have to block like Arduino. ... Since vTaskDelay accepts ticks, the pdMS_TO_TICKS macro will convert for you.
🌐
GitHub
github.com › espressif › esp-idf › issues › 8584
vTaskDelay inaccurate (IDFGH-6964) · Issue #8584 · espressif/esp-idf
March 16, 2022 - I would like to understand how does vTaskDelay work exactly. I am having issues with time sensitive tasks. For my project, I need to create a task that would repeat itself precisely every 2 seconds. +-1ms is acceptable but not more than that. The tick rate is configured to default 100hz value. ... static void TIMER_TEST_TASK(void* parameters) { static int counter = 0; for(;;) { counter++; int64_t task_execution_start = esp_timer_get_time()/1000; // get current time required for the task delay ESP_LOGW("TEST","time in miliseconds=%lli",task_execution_start); ESP_LOGW("TEST","PRINT STATEMENT FOR
Author   espressif
🌐
Espressif
docs.espressif.com › projects › esp-idf › en › stable › esp32 › api-reference › system › freertos_idf.html
FreeRTOS (IDF) - ESP32 - — ESP-IDF Programming Guide v6.0.2 documentation
Whereas vTaskDelay () specifies a wake time relative to the time at which the function is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to unblock.
🌐
Stack Overflow
stackoverflow.com › questions › 74702362 › esp-idf-task-never-leaves-vtaskdelay
c - ESP IDF: Task never leaves vTaskDelay() - Stack Overflow
romkez Those comments are not from me, rather the official esp idf website "docs.espressif.com/projects/esp-idf/en/latest/esp32/…". I solved the issue, I will post an answer soon. And zou are right depending on the prioritz of the task it sometimes ran just once or not at all. The issue was the lines commented "// Use the handle to delete the task." Emre Mutlu – Emre Mutlu · 2022-12-07 08:50:07 +00:00 Commented Dec 7, 2022 at 8:50 · Add a comment | Related questions · 3 · FreeRTOS vTaskDelayUntil() finishes immediately ·
🌐
GitHub
github.com › espressif › esp-idf › issues › 1646
Task watchdog got triggered - it is fixed with a vTaskDelay of 10ms but is this a bug? (IDFGH-5818) · Issue #1646 · espressif/esp-idf
February 21, 2018 - espressif / esp-idf Public · Notifications · You must be signed in to change notification settings · Fork 8.3k · Star 18.4k · New issueCopy link · New issueCopy link · Closed · Closed · Task watchdog got triggered - it is fixed with a vTaskDelay of 10ms but is this a bug?
Author   espressif
🌐
ESP32 Forum
esp32.com › viewtopic.php
vTaskDelay() Doubt - ESP32 Forum
July 8, 2017 - 10ms, but can be changed https://github.com/espressif/esp-idf/bl ... config#L38 · Top · cherenkov11 · Posts: 5 · Joined: Fri Jul 07, 2017 5:59 am · Quote · Postby cherenkov11 » Sat Jul 08, 2017 4:47 am · Thanks for answering so fast, so if I understand correctly, changing the value to 1000 hz (which is the max), will I get a 1ms delay? Another question, in this line of code vTaskDelay(1000 / portTICK_PERIOD_MS); means that 1000*10 ms = 10s, but I know that it is a second delay so, the portTICK does something that i don't understand.
Find elsewhere
🌐
ESP32 Forum
esp32.com › viewtopic.php
vTaskDelay - ESP32 Forum
October 31, 2018 - If your application doesn't call vTaskSuspendAll(), I see two possibilities that can cause this issue. 1) Bug with IDF functions that internally call vTaskSuspendAll() The assert in vTaskDelay() checks to see if the uxSchedulerSuspended of the current core is set.
🌐
Reddit
reddit.com › r/esp32 › better explanation for vtaskdelay (freertos) ?
r/esp32 on Reddit: Better Explanation for vTaskDelay (FreeRTOS) ?
September 15, 2021 -

Hello,

I am currently working on a project that uses FreeRTOS to create a bunch of tasks to do things. The code was written be a former student and I have to implement some stuff and make it run a bit smoother but I can't really understand the FreeRTOS part especially when it comes to Delays and TaskDelays or someone also told me about yields.

As an example I have 2 Tasks:

  xTaskCreatePinnedToCore(
    Task1code, /* Function to implement the task */
    "Pubblish", /* Name of the task */
    8192,  /* Stack size in words */
    NULL,  /* Task input parameter */
    1,  /* Priority of the task */
    &Task1,  /* Task handle. */
    1);
    
  delay(100);
  xTaskCreatePinnedToCore(
    Task2Code, /* Function to implement the task */
    "Sensors", /* Name of the task */
    4096,  /* Stack size in words */
    NULL,  /* Task input parameter */
    2,  /* Priority of the task */
    &Task2,  /* Task handle. */
    1);

and the following functions :

void Task1code( void * parameter) {
  
  for (;;) {
    if (client.connected()) { 
      String temp = getData();
      vTaskDelay(800);
  
      if (!client.publish("topic", temp ())) {
        log_e("Couldnt publish to 'Topic' ");
        vTaskDelay(200);
      } 
    }
    delay(3000);
  }
}

void Task2code( void * parameter) {
  for (;;){
    getTempValue(); // reads some DS81B0 temperaturesensors over 1-wire
    delay(750);
  }
}

I am kind of unsure what vTaskDelay does in the first code as I cant really understand this page here https://www.freertos.org/a00127.html - Also, can I use normal delays in a extra task or is it bad ?

I would love if someone could explains me the vTaskDelay a bit more noob-friendly and maybe has some ideas on how to make that code run better ?

Edit:

Also I question would be is how to use vTaskDelayUntil()

Thanks !

🌐
TechOverflow
techoverflow.net › 2020 › 04 › 09 › esp-idf-equivalent-to-arduino-delay
ESP-IDF equivalent to Arduino delay() | TechOverflow
May 6, 2026 - You can use the FreeRTOS API to provide a delay similar to the Arduino delay() function in the ESP-IDF framework. FreeRTOS is included in the PlatformIO ESP-IDF default configuration. ... After that, you can use vTaskDelay(...) to perform the delay.
🌐
Starling API
exploreembedded.com › wiki › Hello_World_with_ESP32_Explained
Hello World with ESP32 Explained - Tutorials
For now, simply assume that these are two infinite (while) loops. Whenever one enters delay state (vTaskDelay function), the other runs and vice-versa. Since we are slow and ESP32 is fast, it switches between the tasks numerous times and we see both the tasks happening simultaneously.
🌐
GitHub
github.com › espressif › esp-idf › issues › 4743
vTaskDelay multicore bug (forever loop in vTaskDelay) (IDFGH-2669) · Issue #4743 · espressif/esp-idf
February 10, 2020 - Using debug printouts via a task with higher priority, I have found that my timer task does not return from vTaskDelay. I also get the following prinouts: E (56667) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: E (56667) task_wdt: - IDLE1 (CPU 1) E (56667) task_wdt: Tasks currently running: E (56667) task_wdt: CPU 0: IDLE0 E (56667) task_wdt: CPU 1: timer · I am porting another application to ESP, which already has a timer implementation and the timer internally uses vTaskDelay with variable timeouts.
Author   espressif
🌐
ESP32 Forum
esp32.com › viewtopic.php
Understanding the vTaskDelay help - ESP32 Forum
If you're using the default settings of ESP-IDF, the tick rate (=minimum granularity to schedule things) is 100Hz, so your 10ms matches exactly a situation where the time to wait would be e.g.
🌐
ControllersTech®
controllerstech.com › home › esp32 › freertos tutorials › introduction to freertos on esp32
FreeRTOS ESP32 Tutorial: Tasks, Scheduler & xTaskCreate
April 26, 2026 - When one task calls vTaskDelay(), it moves to the blocked state, and the scheduler immediately switches to the other task. This rapid switching gives the impression of parallel execution — a hallmark of real-time multitasking on the ESP32.
🌐
ESP32 Forum
esp32.com › viewtopic.php
How to compensate for the time it takes to run the task in VtaskDelay - ESP32 Forum
// Perform an action every 10 ticks. void vTaskFunction( void * pvParameters ) { TickType_t xLastWakeTime; const TickType_t xFrequency = 10; // Initialise the xLastWakeTime variable with the current time. xLastWakeTime = xTaskGetTickCount(); for( ;; ) { // Wait for the next cycle. vTaskDelayUntil( &xLastWakeTime, xFrequency ); // Perform action here. } } Top · Post Reply · Print view · 5 posts • Page 1 of 1 · Return to “General Discussion” · Jump to · English Forum · Explore · News · General Discussion · FAQ · Documentation · Documentation · Sample Code · Discussion Forum · Hardware · ESP-IDF ·
🌐
GitHub
github.com › espressif › esp-idf › issues › 1400
[TW#17088] vTaskDelay accuracy · Issue #1400 · espressif/esp-idf
December 18, 2017 - I understand that is not accurate and sometimes delay set by vTaskDelay() can be longer than required, but how to explain delays shorter than we setup. Piece of code and logs: while(1){ // do some stuff here vTaskDelay(2000); } D (207877...
Author   espressif
🌐
Espressif
docs.espressif.com › projects › esp-idf › en › stable › esp32 › api-reference › system › freertos_idf.html
FreeRTOS (IDF) - ESP32 - — ESP-IDF Programming Guide v5.5.1 documentation
Whereas vTaskDelay () specifies a wake time relative to the time at which the function is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to unblock.