我想要的:将处于睡眠模式的独立终端设备XBee连接到连接到sparkfun红板(Arduino Uno)的XBee协调器 . 对于这个例子,我在浪漫照明上使用Faludis无线传感器网络示例,但路由器/终端设备处于睡眠模式
当不处于睡眠模式时,我有一个光传感器连接到我的终端设备,并通过引脚20发送到协调器无线电 . 我将协调器引脚2和3分别连接到arduino板引脚0和1 . 我的协调员arduino的代码来自这本书,
/*
* ROMANTIC LIGHTING SENSOR
*
* It detects whether your lighting is
* setting the right mood.
*
* USES PREVIOUSLY PAIRED XBEE ZB RADIOS
* by Rob Faludi http://faludi.com
*/
/*
CONFIGURATION
SENDER: (REMOTE SENSOR RADIO)
ATID3456 (PAN ID)
ATDH -> set to SH of partner radio
ATDL -> set to SL of partner radio
ATJV1 -> rejoin with coordinator on startup
ATD02 pin 0 in analog in mode
ATIR64 sample rate 100 millisecs (hex 64)
* THE LOCAL RADIO _MUST_ BE IN API MODE *
RECEIVER: (LOCAL RADIO)
ATID3456 (PAN ID)
ATDH -> set to SH of partner radio
ATDL -> set to SL of partner radio
*/
#define VERSION "1.02"
int LED = 11;
int debugLED = 13;
int analogValue = 0;
void setup() {
pinMode(LED, OUTPUT);
pinMode(debugLED, OUTPUT);
Serial.begin(9600);
}
void loop() {
// Make sure everything we need is in the buffer
if (Serial.available() >= 21) {
// Look for the start byte
if (Serial.read() == 0x7E) {
//Blink debug LED to indicate when data is received
digitalWrite(debugLED, HIGH);
delay(10);
digitalWrite(debugLED, LOW);
// Read the variables that we're not using out of the buffer
for (int i = 0; i<18; i++) {
byte discard = Serial.read();
}
int analogHigh = Serial.read();
int analogLow = Serial.read();
analogValue = analogLow + (analogHigh * 256);
}
}
/*
* The values in this section will probably
* need to be adjusted according to your
* photoresistor, ambient lighting, and tastes.
* For example, if you find that the darkness
* threshold is too dim, change the 350 value
* to a larger number.
*/
// Darkness is too creepy for romance
if (analogValue > 0 && analogValue <= 350) {
digitalWrite(LED, LOW);
}
// Medium light is the perfect mood for romance
if (analogValue > 350 && analogValue <= 750) {
digitalWrite(LED, HIGH);
}
// Bright light kills the romantic mood
if (analogValue > 750 && analogValue <= 1023) {
digitalWrite(LED, LOW);
}
//Serial.println(analogLow);
//Serial.println(analogHigh);
Serial.println(analogValue);
//delay(100);
}
现在,当我将路由器上的设置更改为终端设备时,和
ATIR 3E8
ATSM 4
ATSP 64
ATST 14
我看到终端设备每秒都开机(从LED我已经连接到引脚13 15和6),但协调器端没有任何东西 . 有没有我在协调器上做错了,或者Arduino上的串行读取是不是像循环睡眠模式?
1 回答
我相信你需要调整
IR
和SP
设置 . 这个在Digi网站上的Knowledge Base Article有一个很好的解释: