XBEE intermittent functionality

Hey there,

I’m pretty new to the whole tinker community so bear with me, please.

I have two arduino r3’s with PIR motion sensors turning on an led when they detect something. They also both write to serial with is attached to my xbee series 2 chips. They are both setup as AT Routers with the destination high and low set to the coordinator and the pan address set to 0 which is what I have it as on the coordinator. The coordinator is plugged into a usb dongle that is monitored by xctu.

The setup seems to work intermittently. When i check the terminal in x-ctu i get messages every once in a while with a little junk attached to it.

EX:
~…@…r…AMotion ended!
…~.
…@…r…A.r~…u~…o~…@…r…AMotion detected!
.W~.
…@…r…A…~…@…r…A"…
…~.
…@…r…A.i~…@…r…A…~…@…r…Aended!
./~.#…@…r…ASensor 1 Starting up!
…~…@…r…Adetected!
…~…@…r…A2 Motion ended!
.G~.$…@…r…ASensor 2 Motion ended!
…~.'…@…r…ASensor 2 Motion detected!
.k~.$…@…r…ASensor 2 Motion ended!

Here is the code for the two arduinos:

/* Basic XBEE Communication Test */

//Settings
int sigLED = 11;
int sigPIR = 2;
int pirStatus = 0;
int motionFlag = LOW;

void setup(){
  Serial.begin(9600);
  pinMode(sigLED, OUTPUT);
  pinMode(sigPIR, INPUT);
  Serial.println("Sensor 1 Starting up!");
}

void loop(){
  //Check PIR
  pirStatus = digitalRead(sigPIR);
  //Light LED and Signal, or don't
  if (pirStatus == HIGH){
    digitalWrite(sigLED, HIGH);
    if(motionFlag == LOW){
      Serial.println("Sensor 1 Motion detected!");
      motionFlag = HIGH;
    } 
  }
  else{
    digitalWrite(sigLED, LOW);
    if(motionFlag == HIGH){
      Serial.println("Sensor 1 Motion ended!");
      motionFlag = LOW; 
    }
  }
}

the code is the same on both except for the messages say sensor 1 and sensor 2.

The messages are really rather infrequent.

Anyways, if someone has any inclination as to what might be the problem i’d really appreciate some advice. If you need more information, please let me know and i’ll add it. There are a ton of settings I don’t touch in x-ctu, but what i did change are as follows:

Coordinator:
Updated and set to api coordinator
pan id = 0

Router 1:
updated and set to at router
set pan id to 0
set DH to 0013A200
set DL to 408B2D78

Router 2:
Router 1:
updated and set to at router
set pan id to 0
set DH to 0013A200
set DL to 408B2D78

I also tried using my raspberry pi to receive the messages (python-xbee), and i get the same behavior. Here is some example output:

{'status': '\x01', 'id': 'status'}
{'status': '\x06', 'id': 'status'}
{'source_addr_long': '\x00\x13\xa2\x00@\xa2\x0br', 'rf_data': 'Sensor 2 Motion detected!
', 'source_addr': '(Y', 'id': 'rx', 'options': 'A'}
{'source_addr_long': '\x00\x13\xa2\x00@\xa2\x0br', 'rf_data': 'Sensor 2 Motion ended!
', 'source_addr': '(Y', 'id': 'rx', 'options': 'A'}
{'source_addr_long': '\x00\x13\xa2\x00@\xa2\x0br', 'rf_data': 'Sensor 2 Motion detected!
', 'source_addr': '(Y', 'id': 'rx', 'options': 'A'}
{'source_addr_long': '\x00\x13\xa2\x00@\xa2\x0br', 'rf_data': 'etected!
', 'source_addr': '(Y', 'id': 'rx', 'options': 'A'}

I’d super duper really appreciate any help y’all can give. Also, i’d appreciate forbearance if i’m perpetrating some forum faux pas. I did a fair bit of searching on several forums/google before posting here. I have duplicate post in adafruit’s forums and they directed me here.

bump

bump

anyone?! I’m pretty lost.

bump

bump

Hi jack,

not sure about the reason of your problem, but some questions just to figure out your configuration:

  • Are arduino xbee modules configured as routers or end devices?
  • Are arduino going to some sleep state, or are they always awake (routers should not go to sleep mode)?
  • Could you check before sending any data to the coordinator if arduino are really connected to the network? You could use JV param or watchdog function to check periodically that issue
  • If they are end device, have you set SN and SP parameters so that they don’t loose their parent too early?

Hey,

My coordinator is configured as a Coordinator API and the other two xbee’s are Router AP.

Everyone should always be awake. I haven’t done any sleeping.

Can you elaborate on this? I’d be happy to do any testing, I just don’t know exactly what you mean.

None of them are arn’t end devices.

Thanks so much for responding!

If you are just using coordinators and routers and all of them are always powered on, it sounds strange that some packets are lost.

JV param of watchdog are two internal mechanism of XBee that allow routers to check periodically if their associated coordinator is available or not. That way, in case something change on the network (PAN ID, channel, etc, is changed), they can look for the coordinator again.

The issue is that if nothing is changing on the network, there is no reason for routers not being attached to the network.

I’m not used to Arduino boards, but maybe there is some issue on how serial is configured (speed, parity bits, etc.)

Oh I see about the JV thing. Yeah, nothing changes changes in the network. They are literally sitting right next to each other, and some of the messages get there and others don’t.

It seems to come in bursts of working and not working. Is there anything I could do to help diagnose?

I apologize for not seeing this sooner. I’ve been very busy with work unfortunately and have had less time for fun.

Anyone?

Are there any broadcasts on your mesh? broadcasts kind of cripple ZigBee, and also do strange things with the AT buffering.

You do understand that a lot of PIR sensors create a lot of events - I have one, which creates from 1 to 10 events in a fraction of a second when it detects movement. You could have a case where you create 10 Serial.println() messages in say 100msec, so you might be running into serial buffer problems.

Also, check the RO setting on the AT nodes, you might need to increase this or small gaps in serial data cause your messages to be fragmented (sent as multiple packets).

I don’t think there are any broadcasts, although as a noobie, i’m not sure. I had thought broadcasts are setup by setting the destination address to 0x000000000000FFFF. Is that correct?

I didn’t realize that the pir sensor fires off so many events. That may be the issue since my code doesn’t really stop after the first detection. I’ll try putting in a sleep.

Can you recommend a setting for the packetization timeout?

Thank you so so much for helping. I’m going to try these things out as soon as i’m home.