Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7070

MicroPython • Unstable ADC readings with Pico W (MicroPython) with Grove ORP Sensor kit

$
0
0
Hi everyone,

I'm facing a noise issue with my water quality project and hope someone can shed some light on it.
Here's the setup I'm currently using:

Board: Raspberry Pi Pico W, attached to Maker Pi Pico
Language: MicroPython
Sensor: Seeed Studio Grove ORP Sensor Kit
Environment: A fish tank with a small branch of waterweed .No pumps, filters, or lights are running in the tank.

The code:

Code:

import machine, timeVOLTAGE = 3.3         ARRAY_LENGTH = 40    ORP_PIN_GP = 27      OFFSET_VAL = 0        orp_pin = machine.ADC(ORP_PIN_GP)led = machine.Pin("LED", machine.Pin.OUT)orp_array = [0] * ARRAY_LENGTHorp_array_index = 0last_sample_time = 0last_print_time = 0def get_average_read(arr):    length = len(arr)    if length < 5:        return sum(arr) / length        max_val = max(arr)    min_val = min(arr)        total = sum(arr) - max_val - min_val    return total / (length - 2)print("monitoring ORP value")while True:    current_time = time.ticks_ms()        if time.ticks_diff(current_time, last_sample_time) >= 20:        last_sample_time = current_time                orp_array[orp_array_index] = orp_pin.read_u16()        orp_array_index += 1                if orp_array_index >= ARRAY_LENGTH:            orp_array_index = 0    if time.ticks_diff(current_time, last_print_time) >= 800:        last_print_time = current_time        led.toggle()                 avg_raw = get_average_read(orp_array)        voltage = (avg_raw / 65535) * VOLTAGE        orp_value = ((30 * VOLTAGE * 1000) - (75 * voltage * 1000)) / 75        final_orp = orp_value - OFFSET_VAL                print("-" * 30)        print(f"raw value: {int(avg_raw)}")        print(f"voltage:      {voltage:.3f} V")        print(f" ORP :     {int(final_orp)} mV")
My issue is when testing in a small cup of water, adc.read_u16() gives stable values, which is around 330~340, but as soon as I put the probe into aquarium water, the readings fluctuate wildly (large spikes in ADC values), making the data unusable, around 330~400.
I tried powering the Pico W with a USB Power Bank, but the results are the same. I also tried averaging the values (removing min/max), but the fluctuation is still too high in the tank.

Is this a known issue with the Pico's ADC sensitivity combined with the high impedance of the ORP probe in a larger water volume?And are there any specific MicroPython filtering algorithms recommended?

Statistics: Posted by jason0570 — Sun Jan 18, 2026 8:47 am — Replies 10 — Views 184



Viewing all articles
Browse latest Browse all 7070

Trending Articles