MicroPython unstable ADC readings +/- 5% between reads
Pivert last edited by
Using Arduino, readings were stable, but with Micropython & UIFlow, the ADC is unaccurate with variations up to +/- 5% between each adc0.read()
Also, when M5Stack is alone, not a single pin connected, I see occasional jumps to raw 150 or more (max 4095) instead of expected steady 0.
Did you experience similar behaviour ?
How can we fix this ?
M5Stack Core1 + uiflow
Reading voltage drop by a water pressure sensor with 4-20mA through a 147 Ohms resistance. Power is 24V switching power supply, I added a 4700µF capacitor on the PSU. Reading every 1s.
Code slice (uiflow)
adc0 = machine.ADC(35) # Maximum attenuation for 0.17 to 3.10V Range adc0.atten(machine.ADC.ATTN_11DB) while True: adc_raw = adc0.read() label_adcraw.setText(str(adc_raw)) # Just for info # Converts the raw value to the range of the sensor (0-300cm water column pressure) # Values adjusted after some testing. height = int((((adc_raw - 530) / (3600 - 530)) * 300)) label_height.setText(str(height)) wait_ms(1000)
Probably irrelevant details
- TL-136 Liquid Level Sensor Detector Liquid Level Transmitter 24VDC 4-20mA Signal Output
- Using independant PSU for the sensor and the M5Stack Core1
- Using pin 35 for ADC