I’m facing an issue with unstable analog readings on my Arduino Uno. I’m using an analog sensor connected to A0. When the board is powered via USB from a laptop, the readings fluctuate significantly even when the sensor value should be stable.
I’ve tried:
Adding a 0.1 µF capacitor between A0 and GND
Using different USB cables and ports
Adding delay between readings and averaging values in code
The problem still persists. However, when I power the board from an external 9V adapter, the readings become much more stable.
Could this be related to USB power noise or grounding issues? What is the recommended way to stabilize analog readings in such cases?
What is the recommended way to stabilize analog readings in such cases?
Try putting a 10uF capacitor beween AREF and GND.
Continue to average readings.
If still not stable you will need a clean voltage reference connected to the AREF pin and select analogReference(EXTERNAL) or use a clean power source (like 9V battery) to power the board
Welcome!
When powering from the USB the ~5V has the computer noise, and what ever noise it picks up in the cable; there is not much filtering. When you power it from the external Vin (7-12V) power goes through a regulator and filters. Also note the Vref for the A/D converter is powered by the 5V on the UNO. Any changes in the 5V will be reflected in your analog readings.