首页 文章

处于睡眠模式的XBee终端设备与Arduino板上的协调器通信

提问于
浏览
0

我想要的:将处于睡眠模式的独立终端设备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 回答

  • 0

    我相信你需要调整 IRSP 设置 . 这个在Digi网站上的Knowledge Base Article有一个很好的解释:

    示例:采样速率在循环睡眠模式下非常有效,因为无线电将在每个唤醒周期采样一次并立即返回睡眠状态 . 如果每个唤醒周期需要多个样本,则需要修改SO(睡眠选项)和ST(睡眠前的时间)参数 . 我想每分钟对ADC1,DIO2和DIO3进行一次采样,并将样本发送到特定的无线电 . 为了延长电池寿命,无线电应该每个唤醒周期只采样一次 . 配置:DH = 0x0013A200 DL = 0x12345678(收集器节点的地址)D1 = 0x02(ADC)D2 = 0x03(数字输入)D3 = 0x03(数字输入)IR = 0x200(512ms)SM = 0x04(循环休眠)SP = 0x1770(60秒)使用此配置,收音机将每分钟唤醒一次,将D1作为ADC,D2和D3作为数字输入,并将单个样本发送到地址为0013A200 12345678的收音机,然后再返回休眠状态 . IR参数不超过无线电的唤醒周期(这取决于无线电,但默认设置只有几毫秒),因此每分钟只拍摄一次样本并通过无线方式发送一次通过睡眠期而不是采样率间隔 .

相关问题