Skip to content

Potential Issue: Using GPIO 34 / 35 for Ultrasonic Trigger/Echo Causes Unstable Behavior on ESP32 #71

@greenhand0403

Description

@greenhand0403

Hi, I'd like to share a recent issue I encountered while using this library on an ESP32 board that may help others avoid the same pitfall.

I initially set the TRIG and ECHO pins to GPIO 34 and 35 on the ESP32. After uploading the sketch, the board behaved abnormally:

It sent corrupted signals over USB, causing my mouse to move and click randomly on my PC.

The behavior persisted until I unplugged the board.

Even after resetting the board, I had to reflash it on a different PC to regain control.

Upon further testing, I changed the TRIG and ECHO pins to GPIO 17 and 25, and everything started working normally.

🔍 Diagnosis:
GPIO 34 and 35 on the ESP32 are input-only pins. Using them with Ultrasonic (which needs output on the TRIG pin) seems to lead to undefined or unstable behavior. This is not a fault of the library, but it's something that may not be obvious to new users.

✅ Recommendation:
Avoid using GPIO 34–39 for ultrasonic sensors, especially for the TRIG pin. Stick to GPIOs that support both input and output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions