8inch to 157inch) with an accuracy of 0. Currently, the largest value that will produce an accurate delay is 16383. class Timer – control hardware timers. esp_timer set of APIs provides one-shot and periodic timers, microsecond time resolution, and 64-bit range. filo_gr Posts: 109 Joined: Wed Jul 28, 2021 12:25 pm Location: Italy [SOLVED] My function for microseconds delay doesn't work properly. Instead of using incremental calls to delayMicroseconds(), accuracy is now dictated by the internal micros() clock. Some Arduino libraries require it even for sending. You then need to attach the Servo object to a pin: myservo. There are a thousand microseconds in a millisecond, and a million microseconds in a second. As ESP-01 has only 2 GPIOs, only 2 loads can be controlled, here my necessity is to control one AC load in timer delay off mode. The value should be treated as opaque, suitable for use only with ticks_diff(). int outPin = 8; // digital pin 8 void setup() { pinMode(outPin, OUTPUT); // sets the digital pin as output } void loop() { digitalWrite(outPin, HIGH); // sets the pin on delayMicroseconds(50); // pauses for 50 microseconds digitalWrite(outPin, LOW); // sets the pin off delayMicroseconds(50); // pauses for 50 microseconds } Reference ¶ Interrupts ¶ Interrupts can be used on the ESP8266, but they must be used with care and have several limitations: Interrupt callback functions must be in IRAM, because the flash may be in the middle of other operations when they occur. ESP32 had a total of 4 hardware timers (Timer0, Timer1, Timer2, Timer3) which are all 64 bit based on 16-bit pre-scalers. As long as you don't need interrupts from the involved timer, there are no complications using interrupts and delay() . However it seems that setting the timer with. Then, re-open your Arduino IDE. In this guide, we will show you how to use FreeRTOS timers and delays using ESP32 and ESP-IDF. I've also tried adding delays between each function to no avail. Unzip the package from point 1. one micro second at a time. STM32 HAL; ESP32 Arduino; ESP8266 Arduino; AVR Arduino; PICim trying for days to implement 2 channel dimmer using ESP8266 but i cannot find any usable timer to achieve that. For example, a SW delay can easily be tuned using a static variable, you run the SW delay with biggest number within a Systick 1 msec which enables you to calculate the right unit for 2 us. A single shot delay is one that only runs once and then stops. According to an article: Code: Select all Timing and delays. Procedure. There is almost no delay (app. Servo. Connect the VCC pin of the ultrasonic sensor to the VIN pin of the nodemcu. Returns the length of the pulse in microseconds or gives up and returns 0 if no complete pulse was received within the timeout. In addition, this particular module comes with ultrasonic transmitter and receiver modules. สวัสดีครับ ท่านที่พึ่งหัดเขียนโปรแกรมแรกๆ มักจะได้เรียนรู้ delay กันไปแล้วแน่นอน อย่างน้อยก็ Example blink แหละนะ ฟังก์ชัน delay เป็นการหยุดรอเท่าจำนว. tmr. You also need to change the TriState values. tmr. Since usleep generally means you want to delay execution for x microseconds, you must divide the seconds value by 1000000. to delay output in cpp for fixed time, you can use the Sleep () function by including windows. Updating TZ. Fork 13. ) to perform the delay. Return : number of microseconds since esp_timer_init was called (this normally happens early during application startup). Most of the time, the measurement shows 14us (1170 cpu cycles at 80mhz). THE TICK is a new Netflix show. Control home appliances with manual switches or push buttons. Sets how quickly the timer counter is “ticking”. When you are making delay(10000) esp8266 is just hanging on some loop (as a delay implementation) - any other code is not executed due this time. {"payload":{"allShortcutsEnabled":false,"fileTree":{"src":{"items":[{"name":"LightweightServo. deepSleep (0). 4k. Thanks. Your new topic does not fit any of the above??? Check first. The value of the resistor in series with the LED may be of a different value than 200 ohm; the LED will lit up also with values up to 1K ohm. ESP8266 Platforms; ESP8266 Arduino; General Discussions; ESP8266 how to scatter out the delays() properly. Blocking functions prevent a program from doing anything else until that particular task has completed. 8 degree step can be divided up to 256 times, providing a step angle of 0. If voltage is supplied it generates beep sound. Sent 122389760, Got response 0, Round-trip delay 116644 microseconds Now sending Sent 123508764, Got response 0, Round-trip delay 18640 microseconds Now sending Sent 124529728, Got response 0, Round-trip delay 18308 microseconds Now sending Sent 125550348, Got response 0, Round-trip delay 18424 microseconds so this code executes 50 times a second. On the ESP8266 the time between edges on the input and output pins is about 140us and very consistent. h> #include <AceTime. There is almost no delay (app. Or to describe it another way: An mDNS Client or Bonjour Client library for the esp8266. Thanks. import time usleep = lambda x: time. 3V microcontrollers like ESP8266. ticks_ms () # get millisecond counter delta = time . Environment Development Kit: ESP8266 Wemos D1 mini Development Env: Make/Eclipse Operating System: Ubuntu Power Supply: USB Problem Description Hi, I need to create a NanoSecond delay. Here are two basic delay and timer sketches and their millisDelay library equivalents. If 0 is passed as the argument, the delay will equal the time spent executing the interrupt service routine. ~0. Example run (the last value is delay in usec, which should be 14, but it's more): I (4895) main: 7:2304(28) I (7472) main: 35:2221(27) Hi all, I'm solving issue with light sleep on ESP8266 (ESP-01). Note: the AM312 PIR. delay(ms)pauses the sketch for a given number of milliseconds and allows WiFi and TCP/IP tasks to run. Remember that there is a lot of code that needs to run on the chip besides the sketch when WiFi is connected. Code: Select all delayMicroseconds (7000); // Off cycle. This tutorial covers how to develop an ESP8266 MQTT client to publish and subscribe to MQTT topics using Pubsubclient. tmr. Version 1. Instead of programming delays inside of an infinite loop, a periodic timer with a callback can achieve the same outcome while also allowing other processes to run. Go to Tools > Board and choose your ESP8266 board. Low uS delays will not be easy in software because another task/ISR might cut across you. write () function like so:Dimming Neopixels, Delays<Microseconds. See the corresponding section of the tutorial: Getting started with MicroPython on the ESP8266. The chip in an Uno or a Nano is an atmega328. 1. Moderator: igrr 7 posts; Page 1 of 2; 1, 2;Arduino15packagesesp8266hardwareesp82663. digitalWrite (pin_no4, LOW); // triac Off. ESP8266 how to scatter out the delays () properly #90952. sleep (x/1000000. Video demonstration . 2) Blink multiple LED with different interval. I measured the following delays in CPU ticks (80 MHz): delayMicroseconds (1) : 130 ticks, 50 ticks too much delayMicroseconds (2) : 202 ticks, 42 ticks too much delayMicroseconds (3) : 286 ticks, 46 ticks too much delayMicroseconds (4) : 370 ticks, 50 ticks too much delayMicroseconds. I want to run some code only each +-30min. time. The only complicated bits are working out the delays to create the pulse cycle/ wave. txt and change main. This is the documentation for the latest development branch of MicroPython and may refer to features that are not available in released versions. Use sleep_us() for more precise delays. Problem-relevant YAML-configuration entries: switch : - platform: gpio pin: 16 id: buzzer binary_sensor : - platform: pn532 uid: 06-8C-21-EC id: 'tag068C21EC' on_press : -. timer = Timer (period=5000, mode=Timer. romkey. A delay should be there so lightning or high-beam of a car doesn’t trigger to open the chicken-door. Hello community, I made a function that should be able to create a delay for a certain number of microseconds, here the code. Moderator: igrr 7 posts;ESP8266 Platforms; ESP8266 Arduino; General Discussions; ESP8266 how to scatter out the delays() properly. begin (). First of all, set the clock source as internal clock. ticks_ms ¶Then I assumed it's too fast so I added delay(1) in the loop and no crash occured anymore (code#2). ticks_ms (), start) # compute time difference. 9 posts • Page 1 of 1. Currently, the largest value that will produce an accurate delay is 16383. h in the main file by using #include “dwt_stm32_delay. 25 nanoseconds) software overhead to acquire the count. Problem is, when ESP wake up, it is blocked for delay duration before it can make. an AVR with the Arduino IDE. PWM interval can be very long (uint32_t millisecs). delay(ms) pauses the sketch for a given number of milliseconds and allows WiFi and TCP/IP tasks to run. Connection Table. 2 Components Required. 0 Kudos. PERIODIC, callback=lambda t:print. h> #include <ESP8266WiFi. digitalWrite (pin_no4, LOW); // triac Off. Thanks. time. b) 3 Microseconds. Make the oscillator clock frequency as high as possible and you can use Delay_Cyc () in MikroC which creates delay based in clock cycle. ESP8266 Ticker Example. any thoughts or suggestions would be very much appreciated. 3V!) RESET: Reset pin (pull down to reset) CH_PD: Chip enable and power down pin. Hello community,delay() in main loop should be avoided on esp8266/arduino. Bestimmte Dinge laufen jedoch weiter, während die delay () -Funktion den Atmega-Chip steuert, da die delay () -Funktion Interrupts nicht. Follow answered Feb 24, 2021 at 8:02. If so what can I do to get a 10 microsecond delay between two tasks? Thanks for the help in advance, emre_mutlu April 25, 2020, 8:40pm 2. Your new topic does not fit any of the above??? Check first. pin: the number of the pin that the servo is attached to. Timers' interval is very long (ulong millisecs). So, when you call ESP. บทความ ESP8266 NodeMCU #1 สอนใช้งาน NodeMCU ESP8266 v2 ติดตั้ง NodeMCU ESP8266 ลงบน Arduino IDE #2 สอนใช้งาน NodeMCU ESP8266 v3 ติดตั้ง NodeMCU ESP8266 ลงบน Arduino IDEHere are two basic delay and timer sketches and their millisDelay library equivalents. 106V. g. This code takes the distance measurement and if the measured distance value is less than 10cm, LED will turn on. Timestamp of the nearest timer event, in microseconds. When this occurs the new user is usually. pdf (146 KB) with delay BMP180 ok. Initializing Timer Interrupt in Raspberry Pi Pico. If the pad is not configured for input (or input and output) the returned value is always 0. Timing and delays¶. #include <Arduino. 0 #8081. // Initializing the variable with the time BEFORE the count. Use sleep_us() for more precise delays. Here comes the point, both functions pause the program for the amount of time passed in delay function. Arduino Code for Ultrasonic Sensor with LED. delay(us) Parameters¶ us microseconds to busyloop for. MicroPython Timer API supports allf four hardware timers. When ı create a task using xTaskCreate() function and adding some delay in the task function. Hello, I've found ticker. You start the delay and then. I ran your code and the results matched mine. In pseudocode it will look like this:By default, the baud rate of esp8266 is 115200. Blynk should not have any impact on the built-in delay () function. For this example, we will use timer 0. On Linux/Mac computers, see the instructions at the top of the ESP8266 TZ. above code will print Apple and wait for 3 seconds before printing Mango. cpp did the trick! Steps: 1) Add #define USE_US_TIMER at the beginning of osapi. However, even a perfect millis() will not be good for anything faster than 1 kHz. esp8266; delay; home-automation;Timing and delays. Problem is, when ESP wake. For microseconds based delay, DWT cycle counter is used to get maximal optimized delay. Made a back up of C:UsersjohnDocumentsArduinoDatapackagesesp8266hardwareesp82662. 6. 28 µs) after firs addressing the BMP180. are boards using an Atmega chip. 9. Delay for given number of microseconds, should be positive or 0. On standard servos a parameter value of 1000 is fully counter-clockwise, 2000 is fully clockwise, and 1500 is in the middle. 1,514 8 10. The discussion is here; the heatmaps are what convinced me that for these style of questions it pays to emphasize the operating. Now press the upload button in the Arduino IDE. @Juraj udp. Post by filo_gr » Thu Sep 09, 2021 6:57 am . 5-947-g39819f0). Shorting the pins with a wire does not work. ESP8266 Platforms; ESP8266 Arduino; General Discussions; ESP8266 how to scatter out the delays() properly. Return. We will use this object to configure the timer interrupts. - Simplify delay approach and improve delay_microseconds_accurate() · esphome/esphome@064c2b9There is a modification to be made – both in hardware and software – to get current consumption low. GPIO 1: GPIO pin (unused in this project) GND: Connection to Ground. In a more advanced system that is using a real-time operating system (RTOS), developers can leverage built in RTOS API calls for yielding a task to create a delay. Dimming Neopixels, Delays<Microseconds. Currently, the largest value that will produce an accurate delay is 16383. And counting microseconds turns out to be a far less demanding. (Max value for unsigned long) divided by (number of microseconds in one second) divided by (number of seconds in one minute). Day 6- Millis concept & Denounce Button. With a normal LEDs you can show the state of a system (blue= too cold, red= too hot). . mktime() This is inverse function of localtime. On a standard servo, this will set the angle of the shaft. Announcement: esp8266. h","contentType":"file"},{"name. {"payload":{"allShortcutsEnabled":false,"fileTree":{"libraries/Servo/src":{"items":[{"name":"Servo. AlfonsMittelmeyer commented on Apr 10, 2018 •edited. 1 Answer. Dynamic tasks activation and deactivation. I tried to set the PWM frequency, this works, but I want to count something at. Using delay () causes ESP to reset #33067. Then, click the “ OK ” button. สอนใช้งาน Arduino วัดค่าอุณหภูมิด้วย Sensor DS18B20. nikki-m July 13, 2021, 5:31pm 6. There was a lot of discussion about this, and Jeff agreed in some cases that it was a good way of asking. sleep (seconds): This blocking method provides a delay in seconds. When the IDE opens, notice that it automatically opens the "Timer2_Counter. c) To find the up-time. #20 สอนใช้. Float is faster than 64-bit. delay specifies the number of microseconds after setting the pin values to wait until moving to the next state. The mode chosen is periodic and the callback function is the print command so this timer will print ‘Welcome to Microcontrollerslab’ after every 5 seconds. Why? Because it just calls setTimeout. Note: PR awaiting Remove. It now supports 16 ISR-based synchronized PWM channels, while consuming only 1 Hardware Timer. Hello community, I made a function that should be able to create a delay for a certain number of microseconds, here the code. สวัสดีครับ ท่านที่พึ่งหัดเขียนโปรแกรมแรกๆ มักจะได้เรียนรู้ delay กันไปแล้วแน่นอน อย่างน้อยก็ Example blink แหละนะ ฟังก์ชัน delay เป็นการหยุดรอเท่าจำนว. pdf (159 KB) See full list on randomnerdtutorials. Everything works fine but in order to arm the ESC optimally I need a sleep/delay function that works on microseconds (nanoseconds would be a plus). Post by HelWeb » Wed May 01, 2019 4:32 pm . If everything went ok then you should see the LED connected to GPIO4 blinking with delay of 500 microseconds. Certain things do go on while the delay () function is controlling the Atmega chip, however, because the delay function does not disable interrupts. Neopixels have great possibilties. Serial communication that appears. For advanced users, there is the esp-open-sdk toolchain which allows us to progam the ESP8266 directly (more info at the esp8266. min (optional): the pulse width, in microseconds, corresponding to the minimum (0-degree) angle on the servo (defaults to 544) max (optional): the pulse width, in microseconds, corresponding to the maximum (180-degree) angle on the servo (defaults to 2400)Overview. begin () is for listening, but I did try it and see no difference. Use delay(500) to make the program sleep for 500 milliseconds, or 0. After that, you can use vTaskDelay (. This sensor reads from 2cm to 400cm (0. Did you try this: edit yes you tried it. I added the yield(); function to. Moderator: igrr 7 posts; Page 1 of 2; 1, 2;The PWM frequency on Arduino pins are 976 cycles per seconds (Herz), for the ESP8266 up to 1 kHz and for the ESP32 up to 40 MHz. // Initializing the variable with the time BEFORE the count. For that purpose, lib has been changes. Notifications. 4k. 5. pdf (146 KB) With ticker delayMicroseconds AM2321 ok. Currently, the largest value that will produce an accurate delay is 16383. Discussions. h” and build the project. These examples are for a once off (single-shot) delay and a repeating delay/timer. You may also try creating your own delay function like the following (following code is not calibrated for microsecond). println (sensorValue); vTaskDelay ( 1 ); // one tick delay (15ms) in. Welcome to B4X forum! B4X is a set of simple and powerful cross platform RAD tools: B4A (free) - Android development; B4J (free) - Desktop and Server development; B4i - iOS development; B4R (free) - Arduino, ESP8266 and ESP32 development; All developers, with any skill level, are welcome to join the B4X community. I'm sorry to have added unnecessary confusion. Copy link. ESPNtpClient do not have any external dependency. sleep_us (us) ¶ Delay for given number of microseconds, should be positive or 0. Led’s Binary counter with 8051 (89c51,89c52) microcontroller. For ESP-IDF, you can use this: Code: Select all. Your code in loop () will never run. Only if the time was set by SNTP, we will also update the date/time of the RTC. 6. This of course is resource free and has limitations. 0. When I first tied this it didn't work and it appears that before you can use the microseconds calls, the system timer has to be reset in the right at the start of usercode. At this stage, you should see new examples appear under the file menu, and the following code should compile. cpp should be formatted like any other sketch. com wiki) without having to use the Arduino IDE for uploading the. Timing and delays millis()and micros()return the number of milliseconds and microseconds elapsed after reset, respectively. VCC: Connection to 3. romkey. millis() and micros() return the number of milliseconds and microseconds elapsed after reset, respectively. For example, if value is HIGH, pulseIn () waits for the pin to go from LOW to HIGH, starts timing, then waits for the pin to go LOW and stops timing. XPD_DCDC should be connected to EXT_RSTB through 0 ohm resistor in order to support deep-sleep wakeup. 026339 seconds, which bears out the first example executing in less than 1 second. I put this project on github: Github: my esp32 disassembly. The device will automatically wake up after the deep-sleep time set by the users. Postby PeterR » Fri Jun 12, 2020 1:02 am. cpp you need to implement app_main () and call initArduino (); in it. 7. The respective interrupt gets fired even if you don't use delays. ESP8266 Report Bugs Showcase; Chinese Forum 中文社区 活动区 乐鑫活动专区 讨论区 ESP-IDF 中文讨论版 《ESP32-C3 物联网工程开发实战》书籍讨论版 ESP-AT 中文讨论版 ESP-BOX 中文讨论版 ESP IoT Solution 中文讨论版 ESP-ADF 中文讨论版 Description. Sent 122389760, Got response 0, Round-trip delay 116644 microseconds Now sending Sent 123508764, Got response 0, Round-trip delay 18640 microseconds Now sending Sent 124529728, Got response 0, Round-trip delay 18308 microseconds Now sending Sent 125550348, Got response 0, Round-trip delay 18424 microsecondsso this code executes 50 times a second. 0. 2 (depending on compiler settings)ESP8266 - NodeMCU - CPU Speed Test: Simply put, faster CPUs complete more calculations, more lines of code and more house keeping tasks in a given period of time. Serial: serial port object. Functions. It may well be better than the AVR version. I’ve updated my delay library to support milliseconds and microseconds delays. Looking for advice - very confused with delay AM2321 ok. I am trying the run stepper motor with the tmc2208 driver and ı want to delay in microseconds like 5uS or 10 uS. More knowledgeable programmers usually avoid the use of delay () for timing of events longer than 10’s of milliseconds unless the Arduino sketch is very simple. {"payload":{"allShortcutsEnabled":false,"fileTree":{"tasmota":{"items":[{"name":"berry","path":"tasmota/berry","contentType":"directory"},{"name":"displaydesc","path. I dont get any delay even if I add some different delays. The two hardware timers are: RTC timer: This timer allows time keeping in various sleep modes, and can also persist time keeping across any resets (with the exception of power-on resets. pin GPIO16, gpio_num should be GPIO_NUM_16 (16);Suggested change -- change "microseconds" to "milliseconds" because vTaskDelay is based on FreeRTOS time tic which is in multiple milliseconds. ticks_us ¶ Just like ticks_ms above, but in microseconds. A well known Arduino function is delay() which pauses the program for an amount of milliseconds specified as parameter. Currently, the largest value that will produce an accurate delay is 16383. 0. Repeat. an unsigned char would extend time by 256 * 50 days. Viewed 651 times. A single shot delay is one that only runs once and then stops. I dont get any delay even if I add some different delays. Thanks. ESP32 had a total of 4 hardware timers (Timer0, Timer1, Timer2, Timer3) which are all 64 bit based on 16-bit pre-scalers. 6. If you need better resolution, micros () may be the way to go. Reads a pulse (either HIGH or LOW) on a pin. Just like delay () has a microsecond-version called delayMicroseconds (), millis () has micros (). The timer speed can be determined by the following formula-. Description. To put the ESP8266 in deep sleep mode, use ESP. This Blynk ESP8266 control smart relay has the following features: Control home appliances with WiFi (Blynk IoT App). Raising the level, the interrupt handler can reduce the timer processing delay. delay(ms) pauses the sketch for a given number of milliseconds and allows WiFi and TCP/IP tasks to run. Looking for advice - very confused with delay AM2321 ok. h header file syntax for Sleep () function is Sleep (time_in_ms) as. The measure of delay is the same between the two functions. Which worked out to 213-160 = 53 counts (53 x 6. The supported way to use WebREPL is by connecting to ESP8266 access point, but. This could change in future Arduino releases. After making necessary connection with ESP32 and ESP8266 board , let’s create simple program script’s to blink the LED using Timer Interrupt using MicroPython. 6 minutes. begin (9600); // open a serial port } void loop () { beginTime = micros ();. I encountered the following problem when using it: if I use a value such as delay_us(20), it doesn't work! Driving a pin (from high to low and vice. 3cm (0. HermannSW October 29, 2020, 4:00am 1. The seconds parameter is defined as a uint16_t. 本指南展示了如何使用Arduino IDE与ESP8266(NodeMCU)一起使用深度睡眠。我们将使用定时器唤醒来唤醒深度睡眠,并使用复位(RST)引脚来唤醒外部唤醒。引入深度睡眠模式如果您使用电池供电的ESP8266板制作了一个项目,或者只是将ESP8266 NodeMCU板连接到了移动电源。1. When ı create a task using xTaskCreate() function and adding some delay in the task function. Works like a "thread", where a secondary function will run when necessary. Each time a person taps a card to the MFRC522 reader module, it will send the UID for. 1) Blink without Delay. Ticker is called every 500ms, but only lights the LED on every 20th call. delay function does not return any values. : read a DHT. The Time1. This code works fine, however I want to improve it to get to better time scales, by using the ESP. My ESP8266 is also connected with a stable WiFi and I have also included the required. If the handler takes more than 10 μs, you will have already passed the 20. The ESP8266EX microcontroller integrates a Tensilica L106 32-bit RISC processor, which achieves extra-low power consumption and reaches a maximum clock speed of 160 MHz. Milliseconds based delay is done using systick timer which makes interrupts every 1ms generated by HAL library. send (200, "text/plain", "Color Wipe Function Done"); //Response to the HTTP request. delay() – Busyloops the processor for a specified number of microseconds. delay(x) pauses x milliseconds (should be as short as possible) beep. so they do not have round trip delay into account. In the diagram below we show a NodeMCU that has D1 as the LED_BUILTIN value. – mark-hahn. delay(ms) pauses the sketch for a given number of milliseconds and allows WiFi and TCP/IP tasks to run. We have set the period as 5000ms which means 5 seconds. 5. time. So that points at the ESP32's RTOS (namely FreeRTOS) and for some reason it introduces. The code below is an example of a timer initialization. time. According to the features used by an application, there are some sub sleep modes. Calling yield from the loop context saves the current stack and then executes the 'other' context, which will be the 'system' context, it then returns to the saved (loop) context when it has finished any pending work. begin (). I also used portTICK_RATE_MS but the speed didnt change . time. The LED should turn on for 20 seconds when motion is detected, and a message should be printed in the Shell. Thanks. It will have the granularity of the CPU clock. . Use a resistor between GPIO16 and RST. Open Arduino IDE, select the right board and port. TaskScheduler. 2coresesp8266TZ. So I changed delayMicroseconds(100) to delayMicroseconds(1000) which should be the same as delay(1) which didnt crash. time. #include <FirebaseArduino. 1000 microseconds is one milliseconds and 1000 milliseconds is one second (the. Go to Tools and select “Generic ESP8266 Module”. . servo: a variable of type Servo. begin () is for listening, but I did try it and see no difference. os_timer_arm (&some_timer, 5000, 1); is still done in microseconds. For a full example, refer to PlatformIO ESP-IDF ESP32 blink. This could change in future Arduino releases. Both ESP8266-12E and ESP8266-07 have one ADC pin that is accessible. You can change the number of repeats of the callbacks, if repeats is 0 the ticker runs in endless mode. I haven't tested with more lamps yet. delayMicroseconds(us) pauses for a given number of microseconds. Connect the TRIG and ECHO pins of the. Subtracting 53 from every count gives me a count accurate to within a few tens of picoseconds, for periods from 30 microseconds to about 500 microseconds. The part of interest is this: startTime = micros (); while (digitalRead (capPos) == HIGH) { delayMicroseconds (1); } endTime = micros (); The while loop I want to. The timebase is the same as for the values returned by esp_timer_get.