Hi
I would like to use an HC-SR04 to measure distances. The way that device works is to return a pulse whose length is proportional to the distance being measured (ultrasonic reflection). I saw that there is a way to do this on Arduino (pulseIn - see http://www.instructables.com/id/Distanc ... a-NodeMCU/), but I am not using Arduino software, rather the native ESP IDF. How can I code this in C?. Please bear with me as I am new to this chip and its environment.
Many thanks
David
How to measure pulse width on an HC-SR04
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to measure pulse width on an HC-SR04
I'm pretty sure you can use the RMT peripheral for that. The MCPWM block may also have a capture mode that allows you to capture pulse lengths, but I'm not 100% sure on that.
Re: How to measure pulse width on an HC-SR04
Be careful. The ESP32 allows approx max 3.3V DC on its input pins. But the operating voltage of that unit is 5V DC; I asssume it also emits max 5V DC on the output pin(s).
--
Paul.
Paul.
Re: How to measure pulse width on an HC-SR04
Hi,
Did you try with PCNT Interface to get exact accuracy about pulse width which you want to achieve?
We have also same requirement for one of our product based on ESP32
Did you try with PCNT Interface to get exact accuracy about pulse width which you want to achieve?
We have also same requirement for one of our product based on ESP32
Regards,
Ritesh Prajapati
Ritesh Prajapati
Who is online
Users browsing this forum: No registered users and 81 guests