Electronic – Arduino UNO sensor works fine when connected to laptop but gives problem when connected to external power supply

arduinoflow-sensorpower supplysensor

I have encountered problem with Arduino UNO and water flow sensor. So here's situation:

I have connected a 12 V power supply from DC battery and then used 5 V regulator which output is used as input to 3.3 V regulator.

Ground of all power supply is the same that is ground of 12 V. It is connected to 5 V and then 3 V. I have a water flow sensor which uses 5 V from output of the 5 V regulator also this output is used to power the Arduino.

When serial port is connected to a laptop, the sensor works fine and gives accurate output. But when serial port disconnected sensor gives output even if there is no flow of water.

Best Answer

In the Arduino Uno design, if power is detected from the USB port, the power from the external barrel jack is disconnected.

That explains how the Arduino is working while connected to your laptop.

Now for the bit when it is not working. From the Aruduno Uno web page:

The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may become unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

So, if you are connecting your 5 volt regulated output to the barrel jack of the Arduino, you will likely encounter unexpected results.