XBee series 1 mesh and data collisions

XBee projects like the adapter, xBee tutorials, tweetawatt/wattcher, etc. from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
johnmccombs
 
Posts: 23
Joined: Sun Aug 08, 2010 5:20 pm

XBee series 1 mesh and data collisions

Post by johnmccombs »

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “XBee products (discontinued)”