Can I use multiple hc-sr04 sensors on an Arduino?

Using multiple HC-SR04 sensors with multiple triggers and a common echo, has the advantage that all Arduino boards can be used while still using the interrupt method. The reading may be a bit slower, since all sensors will measure one by one, but for most applications it’s still fast enough.

How does the ultrasonic sensor hc-sr04 work?

About this project Ultrasonic Sensor HC-SR04 is a sensor that can measure distance. It emits an ultrasound at 40 000 Hz (40kHz) which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance.

What is the range of the hc-sr04?

The HC-SR04 is an inexpensive, easy to use ultrasonic distance sensor, with a range of 2 to 400 cm. It is commonly used in obstacle avoiding robots and automation projects.

How many sensors can be connected to the Arduino Uno?

The echo pin of every sensor, will be connected to a separate interrupt pin on the Arduino board (not just any pin). Since the Arduino Uno has only 2 interrupt pins, only 2 sensors can be used. The Arduino Micro has 5 interrupt pins, and thus can read 5 sensors. The method remains the same, so up-scaling (or down-scaling) is very easy.

What are the disadvantages of using multiple interrupts in Arduino?

With using multiple interrupts, there’s the disadvantage that the sensors may interfere with each other, when facing the same direction, and crossing each others line of sight. Also, since most Arduino boards are limited on the number of interrupt pins, the use of multiple sensors could become a problem.

How can I add more sensors to my Arduino Uno?

Download the electrical schematic for the Arduino Uno with four HC-SR04 sensors with multiple triggers and common echo below. The above can be extended very simply by just adding more sensors with every sensor connected to a different trigger pin, and with the echo pin connected via a diode to the common echo pin.

How to read interrupts on 32 bit Arduinos?

Go for the 32 bit Arduinos like the ZERO or the DUE, which have interrupts on (almost) all pins, or the MKR series which have 10 interrupts pins. Choose a different method by polling with micros () and using registers to read the pin states, rather than using digitalRead ().

You Might Also Like