Hey there,
Time to hobby again with a XBee. Playing around with the Hibernate function on the XBee. It seems I can put the XBee asleep, but the Arduino main-loop stops as well, while it shouldn't. What I'm trying to do is:
- Arduino pin 8 is connected with XBee pin 9 for the sleep command
- in Setup(), set pin8 LOW, connect with the XBee and send "+++", followed by "ATSM 1"
- Set pin 9 of the XBee HIGH (=go to bed?)
- In the meanwhile, let the main loop switch on LED 13 shortly each 7 seconds
Nothing fancy, but when the XBee goes asleep (the green "Accosciate" LED on the shield goes off), the Arduino loop stops as well. At least, I don't see my LED toggling anymore.
If I keep pin 9 low, or put the sleep mode at ATSM 0 (sleep off), the main loop keeps working... It's as if the main loop is waiting forever, but for what (serial input?)? Should I stop the Serial connection as well when putting it to sleep (Serial.), and thus also restart with Serial.begin when I want to wake-up the XBee?
void setup()
{
// Wake XBee, set it up
pinMode( 13 , OUTPUT); // LED
pinMode( 8 , OUTPUT); // Goes to XBee Hibernate pin 9
digitalWrite( 8, LOW ); // Power up
digitalWrite( 13, LOW ); //
delay(250);
// Start serial comm, and send AT command to set the sleep modus
Serial.begin( 9600 );
Serial.flush();
delay(2100);
Serial.print("+++"); // put the XBee in command mode
Serial.flush();
delay(1100);
if (checkSerialForOk())
{
Serial.println("ATSM 1");
Serial.flush();
if (checkSerialForOk())
{
digitalWrite( 13, HIGH ); // Test if we received "OK"
}
}
// Bedtime
digitalWrite( 8, HIGH );
} // setup
void loop()
{
delay(7000);
digitalWrite( 13, HIGH ); // Just show we're alive
delay( 1000 );
digitalWrite( 13, LOW );
// Later on I want to wake up the XBee each X time, and use the watchdog
// to put the Arduino asleep as well...
}
Additional notes:
- Also when storing the sleep mode and skipping the entire AT-command setup will put both the XBee & Arduino asleep.
- Once asleep, the reset button doesn't work anymore... The green "power" LED keeps on though
- Using a Arduino duemilanove Atmega 328, XBee shield & Xbee shield. Nothing else.
Rick