im planning to build a simple robot. having several ultrasonic sentor and 12 servo motor.

How many ultrasonic sensor can a Raspberry pi B+ can handle? i need 8 ultrasonic working at the same time without having any errors or hang.

how can i make it work? do you have any alternative.

1 Answer 1


The B+ has 26 usable gpios. 12 for the servo control wires and 8 for the ultrasonics would use 20 gpios leaving 6 spare.

You can get I2C ultrasonic sensors. That would let you use just 2 gpios rather than 8.

The problem with multiple ultrasonic sensors is ensuring the echo came from the same sensor which sent the pulse. I suppose you could fire them in sequence. In that case you might be limited to 3-4 readings per sensor per second rather than the more normal 13-14.

I'm not aware of any software problems which would stop 8 ultrasonic sensors being usable.

  • im new to raspi, im an arduno user shifting to raspi.. is it possible also to conrol all servo motor and ultrasonic sensor using I2C? so i would only use two wires?. Commented Sep 29, 2014 at 16:13
  • Yes. Adafruit sell a an I2C board which allows you to control up to 16 servos over I2C. robot-electronics.co.uk/acatalog/Ultrasonic_Rangers.html has some I2C sonar rangers. Personally I'd drive the servos from the Pi rather than using I2C, but that is purely a personal preference. Using I2C would probably make the wiring neater. Remember I2C is a serial bus running at 100 or 400 kbps on the Pi (I'm not sure if it can be driven faster).
    – joan
    Commented Sep 29, 2014 at 16:30
  • do i still need an arduino? or raspberry pi B+ can handle all of the components(12 servo motor and 8 ultrasonic) at the same time. Commented Sep 29, 2014 at 16:40
  • The B+ will handle the servos and sonar rangers. The only thing missing from the Pi is analogue inputs. For analogue inputs you would need to use either an Arduino or an attached I2C/SPI ADC.
    – joan
    Commented Sep 29, 2014 at 16:48
  • look this cooking-hacks.com/… maybeyou can use if you are an arduino user and you have the projwct in arduino runing also there are a library to use rasberry like arduino
    – inye
    Commented Oct 3, 2014 at 11:21

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.