AIN – Analog Input

The Ain class provides an interface to analog-to-digital convertors, and represents a single endpoint that can sample a continuous voltage and convert it to a discretised value.


For details related with hardware (pinout, cables, schematics, …), please check this section.


class Ain

Analog input pin manager that allows reading the analog input pin voltage.
SBC supports analog input pins: VAIN1, VAIN2 and VIN


Converts ADC value to voltage.


pin_id: Pin to read, it can be an integer (0, 1, 2) or a string (“VAIN1”, “VAIN2”, “VIN”).


Voltage readed

Example to read VAIN1 pin using an integer or using a string:

>>> import sbc
>>> ain = sbc.Ain()
>>> print( ain.read_v( 0 ), "[V]" )
2.0 [V]
>>> print( ain.read_v( "VAIN1" ), "[V]" )
2.0 [V]