Analog I/O support

Analog input is available on D0 through D3. Configure these pins to 2 (ADC) to enable analog sampling.

PWM output is available on P0 and P1, which can be used for Analog line passing. Use M0 (PWM0 Duty Cycle) and M1 (PWM1 Duty Cycle) to set a fixed PWM level.

Function

Micro Pin

SMT Pin

TH Pin

AT Command

ADC0

31

33

20

D0 (DIO0/ADC0/Commissioning Configuration)

ADC1

30

32

19

D1 (DIO1/ADC1/TH_SPI_ATTN Configuration)

ADC2

29

31

18

D2 (DIO2/ADC2/TH_SPI_CLK Configuration)

ADC3

28

30

17

D3 (DIO3/ADC3/TH_SPI_SSEL Configuration)

PWM0

7

7

6

P0 (DIO10/RSSI/PWM0 Configuration)

PWM1

8

8

7

P1 (DIO11/PWM1 Configuration)

AV (Analog Voltage Reference) specifies the analog reference voltage used for the 10-bit ADCs. Analog sample data is represented as a 2-byte value. For a 10-bit ADC, the acceptable range is from 0x0000 to 0x03FF. To convert this value to a useful voltage level, apply the following formula:

ADC / 1023 (vREF) = Voltage

Note ADCs sampled through MicroPython will have 12-bit resolution.

Example

An ADC value received is 0x01AE; to convert this into a voltage the hexadecimal value is first converted to decimal (0x01AE = 430). Using the default AV reference of 1.25 V, apply the formula as follows:

430 / 1023 (1.25 V) = 525 mV