Skip to content

nopnop2002/esp-idf-ultrasonic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp-idf-ultrasonic

Ultrasonic distance sensor for ESP-IDF.

I forked from here.

Hardware requirements

  • Ultrasonic ranging module like US-015/US-025/US-026/US-100/HC-SR04/HY-SRF05.

HY-SRF05-3

  • M5Stack project is for M5Stack

  • M5Stick project is for M5Stick

  • M5StickC project is for M5StickC

  • M5StickC-Plus project is for M5StickC-Plus

  • M5StickC-Plus2 project is for M5StickC-Plus2

  • WebSocket project is for generic ESP32

Software requirement

ESP-IDF V5.2 or later.
Because this project uses the new I2C driver.

Speed of sound

The speed of sound is affected by temperature and can be calculated with 331.5+0.61*temperature[m/sec].
If the temperature is 20 degrees, it will be 331.5+0.61*20=343.7[m/sec].
343.7[m/sec]=34370[cm/sec]=34.37[cm/millisec]=0.03437[cm/microsec]
Counting backwards, the time required for 1 cm is 29.0951 microseconds.
In other words, the desired distance [cm] when the temperature is 20 degrees can be calculated by dividing the round trip time [microseconds] from the time the sound wave is emitted until it returns by 29.0951*2 (approximately 58.2).
This example uses 58 as an approximation.
If you want more accuracy, you should measure the temperature at the same time and use the measured temperature to calculate the distance.

About

Ultrasonic distance sensor for ESP-IDF

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages