USE UPS NEXT DAY AIR FOR ANY USA ORDER BEFORE 11AM ET *TODAY* 12/19/2014 TO GET YOUR PACKAGE IN TIME FOR XMAS - PLEASE SEE OUR SHIPPING DEADLINE NOTICE FOR MORE DETAILS!

XBee series 1 mesh and data collisions
Moderators: adafruit_support_bill, adafruit

XBee series 1 mesh and data collisions

by johnmccombs on Mon Dec 03, 2012 6:07 pm

I have a sensor network at home using Ardiunos and series 1 Xbees with the mesh software installed on them. The one unsolved problem I have is that if two sensors send data at the same time, the data (in this case json) from the sensors is intermingled.

So, what should look like this
{"stn":"k","t1":23.25,"p1":1001.05}
{"stn":"o","t2":20.19,"h1":58.80}

arrives like this
{"stn":"k","t1":23.25,"p1":{"stn":"o","t2":20.19,"h1":58.80}23.62,"p1":1001.05}

One way to handle this is to poll the sensors, but some of them run on batteries and spend the majority of their time asleep, so I can't do that.

Any suggestion on ways to fix this appreciated

UPDATE: Think I found a solution. The data was being written out as it was read from the sensors, which was inserting delays in sending the data to the serial port. Also the Packetization Timeout on the Xbee was the default of 3, which is the time to send 3 characters (approx 200us at 57600). The combination meant that the json messages were being sent as 2 or 3 packets as the timeout occured while waiting for the sensor to respond. The solution was to read all the data from the sensors, then send the json message, in a single Serial.println(). And set the Packetization Delay to 10 to make quite sure it didn't timeout.
johnmccombs
 
Posts: 23
Joined: Sun Aug 08, 2010 5:20 pm