When you configure an XBee IO line as analog to digital converter (ADC), you can only read its value (counts).

Read ADC value

The method used to read ADCs is different than the digital I/O method, but the parameter provided is the same:

Method Description

GetADCValue(IOLine)

Returns the analog value of the provided IO line. Parameter must be an item of the IOLine enumeration class (line to get its value). Returned value is an integer.

The GetADCValue(IOLine) method may fail for the following reasons:

  • The IO line argument is unknown, throwing an ArgumentException.

  • The device is not connected, throwing an InterfaceNotOpenException.

  • There is a timeout getting the ADC value, throwing a TimeoutException.

  • Other errors are caught as XBeeException.

A line must be configured in IOMode.ADC mode to read its analog value.
Read ADC value
// Instantiate an XBee device object.
XBeeBLEDevice myXBeeBLEDevice = new XBeeBLEDevice("00:00:00:00:00:00", "password");

// Connect the device.
myXBeeBLEDevice.Connect();

// Configure the DIO2_AD2 line to be ADC input.
myXBeeBLEDevice.SetIOConfiguration(IOLine.DIO2_AD2, IOMode.ADC);

// Get the value of the DIO2_AD2.
int value = myXBeeBLEDevice.GetADCValue(IOLine.DIO2_AD2);