MojoScale Studio Docs
API Reference

adc

ADC native Berry module.

Studio Docs Sensors & I/O

import adc

The adc module exposes analog-to-digital reads for ESP32 pins. Use it when a MojoPython script needs sensor voltages, potentiometer positions, or other analog input values.

Quick example

import adc
value = adc.read(34)
millivolts = adc.read_mv(34)
adc.config(34, 11, 12)

importadc

ADC native Berry module.

The adc module exposes analog-to-digital reads for ESP32 pins. Use it when a MojoPython script needs sensor voltages, potentiometer positions, or other analog input values.

API 3 available

adc.read(pin: int) -> int

Read the raw ADC count from a pin.

Parameters
Name Type Pass as Required Description
pin int positional or keyword Yes ADC-capable GPIO pin or channel.
Returns

int Integer raw ADC value reported by the native firmware.

adc.read_mv(pin: int) -> int

Read an ADC pin as millivolts.

Parameters
Name Type Pass as Required Description
pin int positional or keyword Yes ADC-capable GPIO pin or channel.
Returns

int Integer millivolt reading after native calibration.

adc.config(pin: int, attenuation: int, width: int) -> any

Configure ADC attenuation and width for a pin.

Parameters
Name Type Pass as Required Description
pin int positional or keyword Yes ADC-capable GPIO pin or channel.
attenuation int positional or keyword Yes Native attenuation value.
width int positional or keyword Yes Native ADC width or resolution value.
Returns

any Native success value, if the firmware returns one.