This is the documentation for the latest development branch of MicroPython and may refer to features that are not available in released versions.

If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

machine.ADC

Attributes

ATTN_0DB

Classes

ADC

Access the ADC associated with a source identified by id. This

Module Contents

class machine.ADC.ADC(id, *, sample_ns: int | None = 0, atten: int | None = ATTN_0DB)

Access the ADC associated with a source identified by id. This id may be an integer (usually specifying a channel number), a Pin object, or other value supported by the underlying machine.

If additional keyword-arguments are given then they will configure various aspects of the ADC. If not given, these settings will take previous or default values. The settings are:

  • sample_ns is the sampling time in nanoseconds.

  • atten specifies the input attenuation.

block() Incomplete

Return the ADCBlock instance associated with this ADC object.

This method only exists if the port supports the ADCBlock class.

init(*, sample_ns, atten) Incomplete

Apply the given settings to the ADC. Only those arguments that are specified will be changed. See the ADC constructor above for what the arguments are.

read_u16() int

Take an analog reading and return an integer in the range 0-65535. The return value represents the raw reading taken by the ADC, scaled such that the minimum value is 0 and the maximum value is 65535.

read_uv() int

Take an analog reading and return an integer value with units of microvolts. It is up to the particular port whether or not this value is calibrated, and how calibration is done.

machine.ADC.ATTN_0DB: int = Ellipsis