Home/Support/Support Forum/help me with arduino code to make zigbee router & zigbee coordinator & connect to PC via LAN shield?

help me with arduino code to make zigbee router & zigbee coordinator & connect to PC via LAN shield?

0 votes
need arduino program to happen interaction between sensor & PC via IP. Thanks.
asked Dec 2, 2015 in XBee Programmable Development by roy_2015 New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
Which zigbee module are you using; S2B or S2C?
answered Dec 3, 2015 by asgm Veteran of the Digi Community (1,499 points)
i'm not sure. probably S2C.
If its S2C, then write a code to create serial socket connection with modules and pass one "CE" AT command to it with appropriate parameter. This parameter is used to configure module to Coordinator/Router.

I wrote a similar code in python, you can use it for reference:

import serial
import sys
import time


######### USER DATA ###########
com_port = 'COM4'
baud_rate = 9600
###############################

## Create serial connection to module
ser = serial.Serial(com_port, baud_rate, timeout=1)

while True:
    cmd = raw_input("Enter Command (to quit type EXIT): ")
    if cmd == 'EXIT':
        break
    count = 0
    
    while True:
        print "Attempting to enter AT Mode"
        count += 1
        ser.write("+++")
        time.sleep(1)
        resp = ser.read(2)
        if (resp == "OK"):
            print "Successfully entered Command Mode"

            ser.write("AT" + cmd + '\r')

            print "Response from module: "
            print ser.readline()
            print "-----------------------------------------"
            break
        elif (count > 5):
            print "** Unable to enter Command Mode. Check parameters **"
            break


    

    
ser.close()
...