# main.py - MicroPython for Raspberry Pi Pico (reads soil sensor on GP26 / ADC0)
from machine import ADC
import utime
adc = ADC(26) # GP26 is ADC0 on Pico (connect to sensor OUT)
while True:
raw = adc.read_u16() # 0..65535
voltage = (raw * 3.3) / 65535 # convert to volts (assuming 3.3V scale)
moisture_pct = (voltage / 3.3) * 100.0
print("Raw:", raw, " Voltage: {:.2f} V".format(voltage),
" Moisture: {:.1f} %".format(moisture_pct))
utime.sleep(1)