XBee Coding with Pycharm

Hi, is this code will help me extract sensor data from XBee board, regardless of the sensor that is connected to it, or for every type of sensor i need code, in order to read the sensor data?

from digi.xbee.devices import XBeeDevice
from digi.xbee.io import IOLine, IOMode
import time
import threading

TODO: Replace with the serial port where your local module is connected to.

PORT = “COM1”

TODO: Replace with the baud rate of your local module.

BAUD_RATE = 9600

REMOTE_NODE_ID = “REMOTE”

IOLINE_IN = IOLine.DIO3_AD3
IOLINE_OUT = IOLine.DIO4_AD4

def main():
print(" ±----------------------------------------------+“)
print(” | XBee Python Library Get/Set Remote DIO Sample |“)
print(” ±----------------------------------------------+
")

stop = False
th = None

local_device = XBeeDevice(PORT, BAUD_RATE)

try:
    local_device.open()

    # Obtain the remote XBee device from the XBee network.
    xbee_network = local_device.get_network()
    remote_device = xbee_network.discover_device(REMOTE_NODE_ID)
    if remote_device is None:
        print("Could not find the remote device")
        exit(1)

    def io_detection_callback():
        while not stop:
            # Read the digital value from the input line.
            io_value = remote_device.get_dio_value(IOLINE_IN)
            print("%s: %s" % (IOLINE_IN, io_value))

            # Set the previous value to the local output line.
            local_device.set_dio_value(IOLINE_OUT, io_value)

            time.sleep(0.2)

    th = threading.Thread(target=io_detection_callback)

    remote_device.set_io_configuration(IOLINE_IN, IOMode.DIGITAL_IN)

    local_device.set_io_configuration(IOLINE_OUT, IOMode.DIGITAL_OUT_LOW)

    time.sleep(0.5)
    th.start()

    input()

finally:
    stop = True
    if th is not None and th.is_alive():
        th.join()
    if local_device is not None and local_device.is_open():
        local_device.close()

if name == ‘main’:
main()

If your sensor has a Digital Input and output, then yes that would work.