HC-SR04 Isn’t The Same As Parallax PING))) But It Can Pretend To Be!

“It’s only software!” A sentence that strikes terror in the heart of an embedded systems software developer. That sentence is often uttered when the software person finds a bug in the hardware and others assume it’s going to be easier for fix in software rather than spin a new hardware revision. No wonder software is always late.

[Clint Stevenson] is his own hardware and software guy, as are most of us. He wanted to use the less expensive HC-SR04 ultrasonic rangefinder in a prototype. Longer term he wanted to have the choice of either a Parallax PING or MaxBotix ultrasonic sensor for their better performance outdoors. His hardware hack of the SR04 made this a software problem which he also managed to solve!

[Clint] was working with the Arduino library, based on the Parallax PING, which uses a single pin for trigger and echo. The HC-SR04 uses separate pins. Originally he modified the Arduino library to accept the two pin approach. But with his long term goal in mind, he also modified the HC-SR04 sensor by removing the on-board pull-up resistor and adding a new one on the connector side to combine the signals. That gave him an SR04 that worked with the single-pin based library.

We’ve seen Parallax PING projects for sensing water depth and to generate music. These could be hacked to use the HC-SR04 using [Clint’s] techniques.

[Arduino and HC-SR04 photo from Blax Lab]

8 thoughts on “HC-SR04 Isn’t The Same As Parallax PING))) But It Can Pretend To Be!

  1. You can choose between the one or two pin approach with the HY-SRF05 Ultrasonic sensors which cost roughly the same as the HC-SR04, so it seems a little odd to hack the SR04 instead of picking up the SRF05. I’m going to guess this was someone who already had a stack of SR04’s laying around.

  2. Last time I used an HC-SR04 with a Teensy, I just wired the TRIG and ECHO pins together and told the NewPing Arduino library to use the same pin for both functions. I’m not sure where I read about that trick, but it worked for me.

Leave a Reply to Mike Lu Cancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.