I have a 300mV input on ADC ch 0.
Reading the values on a loop (0.5s delay) they jump around between 0.34 and 0.39
I tried using this code:
num_readings = 10
readings = [board.read_adc(0) for _ in range(num_readings)]
average = sum(readings) / num_readings
print(f"Average ADC reading: {average}")
to average the readings but I still get
Average ADC reading: 0.3427939
Average ADC reading: 0.3508507
Average ADC reading: 0.3374228
Average ADC reading: 0.3830778
Which seems quite noisy.
Also ADC channels 1 and 2 are grounded input and they read
Average ADC 1 reading: 0.0876631
Average ADC 2 reading: 0.06483556
Average ADC 1 reading: 0.08632031
Average ADC 2 reading: 0.07020673
Average ADC 1 reading: 0.08632031
Average ADC 2 reading: 0.06617833
So I’m guessing something is awry?
Voltage measured at ADC inputs is:
300mV, 0mV, 0mV
Have you read section 3.3 of the Pico-W datasheet? It is about ADC measurements. You will learn that the Automation 2040W is not optimized for good ADC performance. And I don’t think there is much you can do about it, because the ADC_VREF is not broken out.
Driving the SMPS mode pin (WL_GPIO1) high forces the power supply into PWM mode. This can greatly reduce the inherent ripple of the SMPS at light load, and therefore reduces the ripple on the ADC supply.
However I have found that either PWM or not does not greatly alter the innacuracy :(
I see that pin 35 is the VRef, presumably adding a 3V stabilised supply there by soldering to that pin would improve ADC performance?
Is there a breakout for LM4040 that would do that? Thx.
Adafruit has a LM4040 but it is currently out of stock here. But these chips are also available as TO-92, so you don’t really need a breakout.
Depending on what you need this might help, but maybe this is not sufficient (I don’t think the Pico is built for precise ADC measurements). Have you thought about using and external ADC, like the Adafruit MCP3421 18-Bit ADC
There are others with slightly different specs, just search for ADC in the shop.