I want to get a Pi Pico to accurately measure voltages on an analog input. I have been using the attached input circuit to auto range by outputting a ground from a dig out pin to alter the voltage divider hence the range for the measured voltage.

R1=1M0
R2=10K
R3=100K
R4=1M0 (R4 is always grounded)
D1=Schottky Diode
Here is a snippet of code I was using for the F4 ArmMite.
' Autoranging here
Vm=Pin(PA0): Pause 100
Volts=103.05*Vm 'CALIBRATION EQUATION
If Volts < 20 Then
Pin(PA1)=1:Pin(PA2)=0 '20V setting
Vm=Pin(PA0): Pause 100
Volts=12.05*Vm 'CALIBRATION EQUATION
BL=1:BEEP
EndIf
If Volts < 2 Then
Pin(PA1)=1:Pin(PA02)=1 '2V setting
' Pin(PA3)=0
Vm=Pin(PA0): Pause 100
Volts=2.05*Vm 'CALIBRATION EQUATION
BL=1:BEEP
EndIf
If Volts > 9.999 Then V$=Str$(Volts,2,2) Else V$=Str$(Volts,1,3)
Text MM.HRes/2, MM.VRes/2 - 30,V$ , CM, 6, 2, RGB(white)
' This code to emulate decimal point not available on first fonts
' If Mid$(V$,2,1)="." Then Offset=95
' If Mid$(V$,3,1)="." Then Offset=155
' Circle Offset, 130, 6, 0, 1, 0, RGB(white)
Text 150, 160, Date$, CM, 2, 1, RGB(Green)
Text 150, 190, "UTC "+Time$, CM, 2, 1, RGB(Green)
Offset=0
DrawButton 0, 0, 0, 210, 90, 30, RGB(Red), "EXIT"
DrawButton 1, 0, 110, 210, 100, 30, c.ghosttext, "HOLD"
DrawButton 2, 0, MM.HRes-90, 210, 90, 30, c.ghosttext, "LOG V"
' CheckButtonRelease btn
If LogV=1 Then 'Log every 10 seconds
If Right$(Time$,1)="0" Then Print "UTC,";Date$;",";Time$;",";V$
Pause 800
EndIf
If LogV=2 Then 'Log every minute
If Right$(Time$,2)="00" Then Print "UTC,";Date$;",";Time$;",";V$
Pause 500
EndIf
If LogV=3 Then 'Log every hour
If Right$(Time$,4)="0:00" Then Print "UTC,";Date$;",";Time$;",";V$
Pause 500
EndIf
Loop
WatchDog 4000
End Sub
Can anyone help with suggestions to improve accuracy with the input circuit or the software?
OA47