I have been obtaining a peak on the A0 ADC readings with my photon.
Investigating the issue I could check that this problem disappears when wifi is off.
The problem seems related with powering the device. The device has microdrops on voltage even with a 2A powering source and a short USB wire.
¿Is there any way to prevent this to happen? ¿Maybe a capacitor on 3V3?
I definitely recommend a large capacitor on the Vin pin of the Photon. I usually use a 470uF cap in my prototype drawer. To stop the ADC peaks, a capacitor on the ADC pin (A0 in your case) is also recommended. That size is a bit subjective not knowing your circuit so I’m guessing something like a 1uF cap.
I would suggest a 0.1uF cap on the ADC input as the capacitance will affect the input impedance of the input circuit. If I read correctly, you are getting a clean 500us pulse which seems suspicious. You may want to look at your USB cable and your power supply.
What exactly is your powering source? I would echo the other 2 contributors @ninjatill and @peekay123 about having a conditioned supply to your photon. The Particle photon board schematics (sorry do not have the github link to hand) are a good example of what to do - this is a part of the schematic for the carrier board I use that takes power from a microUSB 5V input [but uses a switched PSU on another board that is designed to produce a very clean reference voltage for the sensor]. I am reading voltage on A0 from a hall-effect current sensor and do not get the dropouts you are seeing here.
Firstly I was using a switched PSU ( VTX-214-006-105 ) with a 6800uF capacitor to help with the transients. After that I tried with USB from PC and with the iPhone charger, and I keep getting the same:
-it's fine without wifi
-when wifi is on it starts to drop voltage
Another strange thing I could find out is that if the signal has an offset the ADC is less affected (Then the cap at the input doesn't solve the issue)
Vigortronic PSUs are good but maybe the capacitor values need looking at because you are trying to filter out a high frequency pulse with a very large capacitor. In practice you want a number of ceramic capacitors in parallel - 47uF, 100nF, 10nF. Also, you may need to ensure your signal cables are screened. Apologies if this is motherhood and apple pie. It took some experimentation to get our setup working reliably. Footnote: you could also apply DSP on the values once read if the analog stuff fails!
The most incredible thing is that I can see the peaks powering the photon alone, with one of the particle usb cables. It should be stable or at least be documented.(I could just see the current peak documented)
I’m breaking my mind trying to understand if is possible I am doing something wrong. I’ve tested several photons and is the same on all. I could reduce the drop with a capacitor, but not eliminate it.
This topic had me curious when i saw that Vin had a 1.5v drop & the 3.3v had more than a 200mv. I thought no way can that be. So I pulled out a brand new Photon, registered it, and flashed Tinker to it. I looked at the Vin and 3.3v rails with the scope. The largest drop i saw on the 5v rail was 153mv, and the 3.3v rail was 52mv. So i’m kinda stumped at why your getting such a mega voltage drop on your end.