Does ESPHome support HC-SR05 ultrasonic sensor in Single Pin mode?

Hi,

I realise that the answer to this question is probably “go and try” but the only HC-SR05 I have is currently deployed in a place I can’t get to very easily. I’ve ordered more, but, it’ll be a week or so.

Here’s the issue.

HC-SR05 is the revision of the HC-SR04 (which is supported very well). The two sensors are compatible, but the HC-SR05 includes a new pin which does Trig and Echo all on one pin, thus saving you a pin on whatever ESP board you’re using.

For my planned application (version 2 of my water flow meter thing on our reservoir) that’s huge because the physical location of that one device is in a spot where it can potentially monitor reservoir as well as two 5000L drinking water tanks. Using 3 GPIOs to do that instead of 6 would be wonderful.

Now, logically, I want to say that it will be as simple as specifying the same pin for trigger_pin and echo_pin, but I’m not in a position to test this in practicality. I will be in about a week, and I will of course update this thread. I’m excited, because right now configuring a yaml file in this way still validates just fine.

Has anyone had any experience with using HC-SR05 in single-pin configuration with ESPHome?

Hi,

I was curious after seeing your post, so I looked at the sources here:

...
void UltrasonicSensorComponent::setup() {
  ESP_LOGCONFIG(TAG, "Setting up Ultrasonic Sensor...");
  this->trigger_pin_->setup();
  this->trigger_pin_->digital_write(false);
  this->echo_pin_->setup();
}
...

I don’t think you can reuse the pin with existing code.

How sad. I guess I’ll look into GPIO extenders if it gets that far. Thanks for your feedback.

Looks like using the 3 wire version of the ultrasonic sensor is possible in esphome using a custom library. See here:

Am I correct in thinking that the only difference between the 4 wire and 3 wire sensor is that the transmit and receive pins are joined?