# How far can a HC-SR04 can stand from the microcontroller?

I was wondering if I connect a HC-SR04 to an Arduino or any other microcontroller by normal cables, what would be the maximum length of this cable so that the measurements will still be true, and not affected by the length of this cable?

this problem consists of 2 things :

1. supply level drop (this one has severe effect)
2. signal level drop (a little more forgiving)

as the signals on the cables don't have high frequencies, the problem narrows down to just voltage level drop due to cable resistance.

supply level drop: the datasheet for SR04 says a maximum active current of 20mA is required for device to work properly. the supply voltage is 4.5~5.5v. so if you provide a 5v power for it, the cable must not drop it under 4.5v. the maximum resistance for the cable is calculated

R=V/I => R = (0.5/20)*10^3 = 25 Ohms

. you can use this value to find out maximum cable length using resistance tables provided by cable makers. e.g. if you have bought a 5ohms/meter cable, the maximum length should be under 5 meters to ensure a good power delivery.

the signals on the other hand, have very little current going between them. as the MCU/Module pins have a very high input impedance. so they are not as severe as the supply drop.

using a 100uF cap near SR04's supply pins would be great.

I have a couple measuring the liquid level of two tanks.

The units are distanced from the microcontroller by 12' of 18ga solid-core copper cable.

Testing was done with another microcontroller with the sensor attached by 6" cable to ensure accurate readings.

That's the longest I needed, so I haven't tested beyond that.

The signal of an HC-SR04 is the pulse on the "Echo" wire. The length of that pulse is directly proportionate to the distance from the object.

Since cable length does not affect the duration of that pulse, measurement accuracy isn't affected either.

• Though that doesn't mean, that you can use any cable length. At some point the resistance of the cable might get too high, thus pushing the voltage too low for the Arduino to detect correctly. Also the increasing capacitance can smooth out the edges of the signal. But that can only be tested with the used cable, since there is no standard for a "normal cable". Mar 5, 2020 at 9:31
• Oh, absolutely. I don't think it'll have much influence in practise though - the input impedance on Unos is quite large, and so is the pull-up resistor. If all else fails, you could probably even analogRead the port.
– towe
Mar 6, 2020 at 7:09