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.