AnalogIn – read analog voltage

Usage:

import analogio
from board import *

adc = analogio.AnalogIn(A1)
val = adc.value
class analogio.AnalogIn(pin)

Use the AnalogIn on the given pin. The reference voltage varies by platform so use reference_voltage to read the configured setting.

Parameters:pin (Pin) – the pin to read from
deinit()

Turn off the AnalogIn and release the pin for other use.

__enter__()

No-op used by Context Managers.

__exit__()

Automatically deinitializes the hardware when exiting a context. See Lifetime and ContextManagers for more info.

value

The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only)

Even if the underlying analog to digital converter (ADC) is lower resolution, the value is 16-bit.

reference_voltage

The maximum voltage measurable (also known as the reference voltage) as a float in Volts.