UncleRus / esp-idf-lib

Component library for ESP32-xx and ESP8266
https://esp-idf-lib.readthedocs.io/en/latest/
1.39k stars 432 forks source link

SR04 ultrasonic sonar issue #579

Open weiwi opened 1 year ago

weiwi commented 1 year ago

@UncleRus

The issue

I am using ESP32S3, and kept getting when trying to get sonar readings. I have tried both SR04 and AJ-SR04M sonar boards and have similar results:

  1. Sonar heads are sending signals (LED blinks on SR04M, and I can hear both heads sending signals from noise cancelling headphone)
  2. Both will get error: Error 513: Ping timeout (no device found)

Can anyone shed some light on this?

Thanks

W

Which SDK are you using?

esp-idf

Which version of SDK are you using?

master

Which build target have you used?

Component causing the issue

ultrasonic

Anything in the logs that might be useful for us?

No response

Additional information or context

No response

Confirmation

UncleRus commented 8 months ago

Hi! I'm sorry for the delay. Do you have the ability to connect an oscilloscope or logic analyzer to the trigger and echo GPIO? This would clarify whether the echo is actually coming.

hayschan commented 6 months ago

I recommend trying your code on a simulator, such as the Wokwi Simulator. This approach allows you to eliminate potential wiring and hardware issues by simulating your setup.

Wokwi offers an HC-SR04 ultrasonic sensor simulator which might be relevant for your needs.

Testing your code in a controlled environment like this can help you identify whether the issue is with the code, wiring, or the hardware components themselves.

Tarungtm commented 5 months ago

Hi @UncleRus, I am using ESP32 wrover ie and esp32 ce-3 mini. I have tried to fetch the distance using SR04M-2 but facing errors like.

  1. ping timeout(no device found).
  2. echo timeout (i.e. distance too big).

I tried to debug the program came to know that it is not fetching timer value in "ultrasonic_meaure_raw" function.

Can you help me with it.