I am wondering whether or not it is possible to use an Arduino ultrasonic sensor in a closed box (30 cm x 30 cm.)

I have been told that the walls will cause the signal to bounce all over the place and the sensor will get messed up, but I am not sure if this is accurate. Please let me know if this is possible.

Also, if ultrasonic sensors don't work, I believe the best alternative would be a laser sensor.

Unfortunately, I noticed that laser sensors require SDA and SCL pins. My ATmega64 microcontroller only has one of each of these pin types, yet I need three laser sensors. Is there any workaround for this problem?

  • 2
    \$\begingroup\$ Those SDA and SCL pins are for the I2C bus, which is a multi-slave bus. There won't be a problem in connecting multiple sensors assuming they have different addresses. \$\endgroup\$ Commented Dec 2, 2020 at 20:43
  • \$\begingroup\$ Pulsed or CW ultrasound? Pulsed ultrasound will work, you'll just see additional echoes from the walls, which you can ignore. \$\endgroup\$ Commented Dec 2, 2020 at 21:14
  • \$\begingroup\$ The key question for ultrasound is if the range to your intended target exceeds the sensor module's ringing-limited minimum. If it does, your closed box is mostly a problem in terms of the fact that with no closer target you will read the short distance to the opposite wall. In any case with such a sensor, you need to wait for echos of one reading to all but completely die out before you can meaningfully take another by triggering a new transmission. \$\endgroup\$ Commented Dec 2, 2020 at 21:46

1 Answer 1


You can also bit bang the I2c node if you wish to use it on a port independent of the single hardware I2C port.

However, I2c is a multi-node bus so you can connect multiple devices to it as long as they have separate addresses and as long as the bus speed is adequate for the data from all equipped devices.


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.