I always forget where the Digi wiki that covers Python on the ConnectPort (IP to PAN bridge).
Read data from an xbee using sockets on ConnectPort
After browsing the examples on the Digi cd that comes packaged with the ConnectPort, I decided to start rolling some code examples that actually combine some fundemental concepts. The code here, finds an xbee by it’s label or NI, then reads data from it.
import zigbee from socket import * ################################################################################ def getZigbeeAddressByLabel( strLabel ): ''' given the label of a zigbee/xbee device, find it's address. The label is often set using X-CTU and setting the "Node Identifier" or NI attribute. ''' zigbeeNodeList = zigbee.getnodelist() for oNode in zigbeeNodeList: if strLabel == oNode.label: return (True, oNode.addr_extended) return (False, None) ################################################################################ def readDataFromZigbee( strAddr, iLengthToRead ): # The Format of the tuple is: # (address_string, endpoint, profile_id, cluster_id) # # The values for the endpoint, profile_id, and # cluster_id given below are the values used to write # to the serial port on an Ember-based XBee module. DESTINATION=(strAddr, 0xe8, 0xc105, 0x11) # Create the socket, datagram mode, proprietary transport: sd = socket(AF_ZIGBEE, SOCK_DGRAM, ZBS_PROT_TRANSPORT) # Bind to endpoint 0xe8 (232): sd.bind(("", 0xe8, 0, 0)) # Block until a some amount of data is read (strData, src_addr) = sd.recvfrom( iLengthToRead ) sd.close() return strData ################################################################################ if "__main__" == __name__: (ok, strAddr) = getZigbeeAddressByLabel( "_GH1" ) data = readDataFromZigbee( strAddr, 16 ) print data
ConnectPort X2 is driving me crazy
Purchased a ConnextPort X2 (model X2-Z11-EC-A) from SparkFun. It took me about four hours to get my collection of Series 2 xbee’s to be discovered. The magic formula is that the S2 xbee’s need to be flashed with XB24-ZB “Zigbee” firmware. The older firmware starts with ZNET and is not compatible with the ConnectPort. I spent a lot of this time battling X-CTU. You have to manually change the Modem type (from XB24-B to XB24-ZB) to see the newer firmware. If you browse Digi’s ftp site, you can get newer (like circa 2010) firmware updates.
One of the problems that continually tripped me up, was needing to reset the firmware parameters to defaults. I run many of my xbee’s at a baud rate higher than 9600. When the firmware update completes with factory defaults, the baud rate is changed back to 9600 and X-CTU can’t the config via AT commands (this would be different if you are using API mode). To get around this, you have to power-cycle or reset the xbee. I really like SparkFun’s xbee to USB dongle, but it does not have a reset button…you have to pull the xbee out of the 2mm headers and reseat it…an electrically dubious action.
ConnectPort X2
Just got a box of goodies from SparkFun. Among them is a Digi ConnectPort X2. I’m very excited about the python integration they put into this. I can see my personal need for xbee units skyrocketing.
Arduino xbee shield
I tried out the xbee v1.1 shield. This model is one of the “L” shaped shields. I’m not impressed, in fact I think this shield is useless unless you intend to only have this shield and no others. The problem is the serial connectivity uses the ICSP header on the Arduino. All the shields I have seen, don’t pass this connector up the next shield.