I'm trying to connect five ultrasonic sensors (HC-SR04, to be exact) to an Arduino board to detect obstacles in five directions (four cardinal + one Z-axis). I read the datasheet on the HC-SR04s and the Arduino Uno as well, and found that the ultrasonic sensor draws 15mA when active, and the Uno can supply a max of 40mA through each pin and a total of 200mA from all pins.

Now since I don't have ten PWM I/O pins, I've thought that since I'll be firing the sensors all at once, one trigger pin is enough. The ECHO pins will go to a separate PWM pin for each module.

I have two concerns here (I'm just a beginner in electronics :)):

  1. I'm going to supply power to each sensor off a 5V/2A BEC. So will this cause current overdraw from the Arduino PWM pins? If so, is there a workaround? Maybe a transistor-driven solution? (I've done a basic electronics course in college, but never had a chance to design one on my own.)

  2. The second concern is regarding my trigger pin design. Will one pin be able to pulse five of the sensors, or will the current drop not let them fire (since they're all in parallel)? My guess is that it's only the voltage that's firing them up (assumption) and in parallel it would all be the same so it should work, right?

I searched around, but I only found information on connecting one sensor to the Arduino. I read something about running high-amp motors with Arduino by supplying the current through a battery so I think my first concern should be fine? But I'm not sure, and so I thought I'd ask here. Thanks!

  • \$\begingroup\$ This sounds sensible: separate power supply for all the sensors. I wouldn't expect there to be significant current draw from the trigger. However, I would be concerned about the sensors detecting one another's echoes. Do you need PWM from the return pins, given that you're just trying to detect pulse width? \$\endgroup\$
    – pjc50
    Oct 26, 2012 at 8:51
  • \$\begingroup\$ Okay, so the power supply concern is clear. I have four BECs anyway, but one should work, right? It's rated 5V and 2A max current. And yes, I need PWM for the return pins as well. Each sensor's return goes to a separate pin on the Arduino. \$\endgroup\$
    – mohdjas
    Oct 26, 2012 at 9:31
  • \$\begingroup\$ Yes, one BEC for all of them, not one each. \$\endgroup\$
    – pjc50
    Oct 26, 2012 at 9:33
  • \$\begingroup\$ Okay, thanks! That helped. :) And I just did some more reading - PWM is not essential. I have much to learn. :) \$\endgroup\$
    – mohdjas
    Oct 26, 2012 at 9:53
  • \$\begingroup\$ What about triggering 2 sensors from one port? they will consume 20 mA so they should work properly..I hope so! \$\endgroup\$
    – user18480
    Jan 31, 2013 at 0:05

2 Answers 2


The problem with hobby related solutions is documentation is limited and not spec'd like commercial components or modules.

It is possible that it may work but make a block wiring diagram and consult with the OEM is advised. Mind you I don't know if they have adequate support for your question as these are built in China.

Hobby Services 3002 N. Apollo Dr. Suite 1 Champaign, IL 61822 (217) 398-0007 E-Mail: [email protected] Internet Address: www.supertigre.com

It appears that your ultrasonic load is TTL so there is no problem switching 5 at the same time with a BEC, but I wonder if you have considered the effects of crosstalk on firing all at the same time. They indicate a 15deg detection angle but this would depend on the reflection angle of objects you wish to detect. There may be phasing issues with reflection cancellations like having 5 tweeters directed in a room. Reading the response of each echo in parallel with a time interval count won't be a simple textbook result with non-smooth objects with 5 senders. enter image description here

YOu can test your orthogonal array design with any signal pulse generator and look at the signal on a parallel port logic analyzer or scope to ensure what you are design will work.

Power drive is the least of your concerns from these low power devices. Noise avoidance from conducted and radiated sources will be paramount and design of the transponder array must come first. I would spend some time on testing this part 1st to identify all the electrical, physical, acoustic, EMI, thermal, vibration both conducted and radiated sources of interference and how each affects your SONAR expectations with different objects. Will it be microphonic with vibration or loud pulse noises. How well does it reject other ultrasound sources of noise? Will the TTL Echo output change in pulse width with signal strength or just the delay time.

Will you get echos from the wrong sender due to corner refection effects.

  • \$\begingroup\$ Yeah these are cheap Chinese ones. But for a low-cost project that I'm just beginning, these are a steal because they won't break bank if they don't work or if I don't find use for them (not now anyway). I'm just going by the specs I read somewhere - I don't know how much current they actually draw, but for now I'm just holding on to these values. \$\endgroup\$
    – mohdjas
    Oct 26, 2012 at 9:55
  • \$\begingroup\$ They are MOSFET switches rated for that value but do not indicate the drive current. YOu can measure the drive voltage connecting one at a time to see if there is any significant loading. A scope would help to see any noise. But in any case I would email them for advice. \$\endgroup\$ Oct 26, 2012 at 16:01
  • \$\begingroup\$ The BEC meaans Battery Eliminator circuit, so it is intended to replace a 2nd battery for a radio from the main servo battery and it is already a transistor (MOSFET) switch with V and A limits to the load. \$\endgroup\$ Oct 26, 2012 at 16:09
  • \$\begingroup\$ Hmmm, okay, that's a lot of stuff to consider, but yes, I have thought about cross-talk as well, but not the other issues you've highlighted. For the cross-talk issue I was thinking about firing the sensors in a pattern that doesn't interfere with the other sensors (maybe opposite sensors or, in the worst case, one at a time). I haven't actually gotten them yet, but I've done some reading on them. They don't seem to be very accurate, but right now I'm just looking to see how it all works. It's just a simple robotics module for object detection and avoidance in college. \$\endgroup\$
    – mohdjas
    Oct 26, 2012 at 17:12
  • \$\begingroup\$ However, I will have to check on the other noise sources like you've mentioned. I didn't think about effects of vibration on these sensors until I read your post (and since it's going to be on a moving bot...). I'm planning on individually testing each module and calibrating them (I don't know how, but I'll find a way. :D) and then setting it all up on a breadboard before it goes onto the bot. \$\endgroup\$
    – mohdjas
    Oct 26, 2012 at 17:15

I realise this is a bit of an old thread, but ... I've got a couple of these, and the issue is that in order to "read" the result you use a pulseIn, which "ties up" the Arduino for the time of the echo.

So, first, you need to put a timeout on the pulseIn, like unsigned long pulse_length = pulseIn( iEchoPin , HIGH , 9000 ) ; where 9000 is 9000 microseconds or 9 milliseconds, which works out to about 150cm or 5feet (speed of sound, travels distance twice, lots of maths). The reason for having a timeout is that the default timeout is a full second, so you could be waiting for 1,000 milliseconds or 1,000,000 microseconds for a result, (and get back 0 because it timed out). So I put in 9000us, that gives me 150cm which is plenty for obstacle location.

And, secondly, I can't figure out how to read both sensors at the same time, since my Arduino will only do one pulseIn at a time, and the echo from the 2nd sensor has already returned by then.

And thirdly, you have to wait a period of time for any "secondary" echos, the datasheet says 60ms, I've had good success with 40ms. But if I have 2 of them, I have to wait 40ms before firing the 2nd one, or it get's false echos from the first one (they're facing about 30 degrees away from each other).

The reason I was looking here, is that I wanted to know if I could use the same echo pin for multiple SR04 sensors (or for that matter, multiple IR distance sensors too). If I trigger 1 SR04, then read the "combined" echo pin, then I only need 1 pin to read any number of sensors, but 1 pin to trigger each one.

The other option, is to change the pin to output, send the trigger, then change it to input and do the pulseIn and have the same wire go to both the trigger and echo pins on the SR04 board. I'm going to try both of these. But wanted to see if anyone had done either of these before.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.