Reading A0-A5, the same functions on every pin.
A0-A2 are read by the RP2040's ADC (0-3.3 V). A3-A5 are read by the on-board MAX11635 (0-2.048 V), which is set up the first time one of them is read. Keep every pin between 0 V and its full scale.
| analog_averaging |
( |
| samples | ) |
|
Averages several readings for every analogue result.
Steadier readings, but each takes longer. A3-A5 average in the external ADC itself; A0-A2 take the samples one after another.
The setting is 1 at start-up and applies to every analogue reading after the call, on all six pins and vbus_volts(); cpu_temperature() is not averaged. On a steady 1 V, going from 1 to 32 cut the spread of 100 readings from about 16 codes to 3 on A0, and from about 10 to 1 on A3.
- Parameters
-
| samples | 1 (off), 4, 8, 16 or 32; other values use the next lower one (values below 1 use 1). |
- Returns
- The setting used.
- Example
mcu.analog_averaging(16)
print(mcu.analog_millivolts("A0"))
| analog_differential_millivolts |
( |
| plus, |
|
|
| minus ) |
The voltage of one analog input pin minus another, in millivolts.
A3/A4 (either order) are a true differential inputs: the external ADC samples both pins at the same instant, so common noise is removed from the measurement. The differential voltage range is +/-1024 mV in 0.5 mV steps for A3/A4; however, each input pins maximum voltage is still 2.048V.
Any other combination of analog input pins will be measured in sequence, plus then minus. This may cause error in the measurement depending on how fast the signals are changing voltage. Take this into consideration when using this function.
- Parameters
-
| plus | "A0"-"A5". |
| minus | "A0"-"A5". |
- Returns
- plus - minus in mV (a float).
- Exceptions
-
| ValueError | Not an analogue pin. |
| OSError | The external ADC did not respond (A3-A5). |
- Example
print(mcu.analog_differential_millivolts("A3", "A4"))