Hi, I have an array of 12 HC-SR04 ultrasonic sensors, which are all connected to one Arduino Mega and are powered by a single 5V 40A external power supply. The Arduino is being powered through a laptop and is grounded to the power supply as well.
I'm currently encountering an issue where if the power supply is turned on and kept running, the ultrasonic sensors will give wrong and unstable readings, however when I switch the power supply off and its light slowly turns off (where the power supply starts discharging? I'm not sure about the correct term sorry) the sensors work as expected and are completely fine for that 5 seconds the power supply is turning off. I'm not very well-versed in electronics so any advice would be much appreciated to what this issue could be, thanks!
I suspect your sensors are sensitive to noise on the supply rail - no doubt that large
supply is a switch-mode supply and putting noise on the rails.
When its turned off the output caps are discharging slowly (as it has almost no load), and there is no switching noise any more, hence the improvement in performance of the sensors then.
An ultrasonic sensor is analog and requires a quiet supply rail for best performance, such as a linear regulator would provide (such as by a 7805).
Any reason you have a 40A supply for a handful of sensors?
Hi, this power supply was what I had at hand, and it had worked for one of my other projects so I thought it would be able to work for these sensors as well. Do you have any suggestions on what to do to remedy this problem? Through my research it seems that a wall plug type of power supply that outputs 5V 1A would work better, however I'm not too sure about it.
Some switch mode power supplies, particularly high current ones, have a minimum load requirement to maintain stable output voltage regulation. If this is the issue, hanging some additional loads to draw a couple amps would probably resolve the issue.
That said, a more suitable power supply is a more sensible solution. A decent quality phone charger is one that is probably readily available.
That's possible, but there's another potential issue - when some buck regulators are lightly loaded them drop their switching frequency down, often by large factors, creating noise at much lower frequencies then when highly-loaded. Such converters are usually bad news for any circuit processing analog audio for instance.