Three ultrasonic rangefinders work reliably on USB but not with wall power

I have an Arduino Maker WiFi 1010 connected to three HC-SR04 ultrasonic rangefinders. When I plug the Arduino into my USB Hub (NOT powered), it correctly reports a distance of approximately 80 inches when pointed at the wall. This is extremely consistent across sensor readings.

But, when I unplug the Arduino from the computer and plug it into a wall wart (output is 5V 2.5A), the sensors start spewing seemingly random numbers for long distances. If I put an object close to the sensors, it seems to get a correct reading within 1ft, but less reliably than when it's connected directly to my USB hub.

My sketch reads each sensor 5 times, with a 60ms pause in between every reading, and a 60ms delay between each sensor. This works really consistently on the USB hub power, but seems to be much less consistent on anything else.

Is there something I'm doing wrong here? I am not an electrical engineer (in case that wasn't obvious!)

How, exactly, are you connecting the Arduino to the wall wart?

Apologies - I'm connecting it through the USB Micro port on the side of the Arduino.

That should work, but you might try connecting to the power leads to Vin and GND instead.

Are the HC-SR04 sensors specified for 3.3V operation, as required? How are they powered and connected?

Please post a complete, hand drawn circuit diagram, with parts and pins identified. Image posting guide.

jremington:
Are the HC-SR04 sensors specified for 3.3V operation

Very important point as they come in both 5V only and 3.3-5V versions.

mikethomas:
pointed at the wall. This is extremely consistent across sensor readings.
[...]
an object close to the sensors, it seems to get a correct reading within 1ft

That is also an inconsistency which may explain the results. Do test on the wall at all times, as that's one of the few things that I know to give a good reflection. A pane of wood, a flat book - that kind of objects placed perpendicular also work quite well. Other objects are hit or miss... hard, smooth objects usually work quite well, but not always. Point in case: I'm using such a sensor to detect whether my tortoise is under its heat lamp, and that doesn't always detect the smooth, rigid shell even at just 10 cm distance...

jremington:
That should work, but you might try connecting to the power leads to Vin and GND instead.

Are the HC-SR04 sensors specified for 3.3V operation, as required? How are they powered and connected?

Please post a complete, hand drawn circuit diagram, with parts and pins identified.

I will have to buy another power supply - I don't want to cut this USB one open. I can do that if the other troubleshooting steps don't work.

The HC-SR04 I have are 5V operation. Here's the datasheet for mine: https://cdn.sparkfun.com/datasheets/Sensors/Proximity/HCSR04.pdf

They're connected in parallel to the 5V pin on the Arduino.

I wouldn't know how to draw a circuit diagram if my life depended on it. Sorry. To sum up the connections:

5V from Arduino is connected to the power rail on breadboard
GND from Arduino is connected to the ground rail on breadboard
VCC from all 3 sensors is connected to power rail on breadboard
GNDfrom all 3 sensors is connected to ground rail on breadboard

Trig and Echo from Sensor1 is connected to pin 0,1 on Arduino
Trig and Echo from Sensor2 is connected to pin 2,3 on Arduino
Trig and Echo from Sensor3 is connected to pin 4,5 on Arduino

I hope this is helpful. Thank you again for your help.

wvmarle:
Very important point as they come in both 5V only and 3.3-5V versions.

I got mine off eBay and the page went down so I can't see the datasheet but I'm 99% positive they're the sensors from this datasheet, which uses 5V supply: https://cdn.sparkfun.com/datasheets/Sensors/Proximity/HCSR04.pdf

wvmarle:
That is also an inconsistency which may explain the results. Do test on the wall at all times, as that's one of the few things that I know to give a good reflection. A pane of wood, a flat book - that kind of objects placed perpendicular also work quite well. Other objects are hit or miss... hard, smooth objects usually work quite well, but not always. Point in case: I'm using such a sensor to detect whether my tortoise is under its heat lamp, and that doesn't always detect the smooth, rigid shell even at just 10 cm distance...

That's good to know. I don't understand why it would consistently give ~80in on one power supply when plugging in another supply gives much less consistent readings, though. The surface hasn't changed between the two tests.

I have witnessed what you're saying with some surfaces being more detectable than others, though - I'm just not sure why the discrepency is so large between supplies.

If you have the 3-5 Volt version it might say HC-SR04P on the back. All of them that I've seen have two 8 pin ICs and a 14 pin IC on the back whereas the 5 V only version has a 16 pin and two 14 pin ICs. Regardless, it shouldn't make any difference in your configuration.

If you have or can borrow a different wall wart to try, that would be my first inclination. The circuit should only require about 100 mA so any phone charger should be fine. Alternately a 9V alkaline battery wired to Vin might be worth a try if you have one on hand. Note that 9V batteries are generally a lousy choice for this sort of application, but this is just testing the hypothesis that it's a primary power issue.

You will destroy the Arduino MKR WiFi 1010 by using it with 5V sensors. The inputs are 3.3V ONLY.