Go Down

Topic: XBee Hibernate puts the Arduino asleep as well! (Read 1 time) previous topic - next topic

RickN

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?
Code: [Select]

    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
Game hobby project: Tower22

pawqar

Hi,

I don't understand you quite well. But I'm trying to explain what I'm doing.

I'm using an arduino FIO with a xbee module. The fio will feed from a battery. Like you, I achieve to sleep the xbee module, but I'm not sure if doing that I'm sleeping the fio too.

I have some questions or comments to ask.... You enter on command mode, why? I used the  x-ctu program to enable SM to 1, I'm not concerning to putting to 0 later. I copy I part of my program

void setup() {
  pinMode(sleepPin, OUTPUT);    // OUTPUT controls xbee module
  digitalWrite(sleepPin, LOW);       // set to LOW (wake)
 
  xbee.begin(9600);  // start XBee communication
}

void loop() { 

    Serial.print("\n  zZzZzZzZ \n");
    digitalWrite(sleepPin, HIGH);  // sleep state

    delay(SLEEP_CYCLE*1000);  // tiempo en ms, declarado como UNSIGNED LONG !!!!

    digitalWrite(sleepPin, LOW); // ESTADO DESPIERTO
    Serial.print("\n  DESPIERTO\n");
    delay(1000);
    // 1. medir temperatura y humedad
    temperature = readSensor('T');
    humidity = readSensor('H');
    uint8_t data[] = { 3,4,1,temperature,2,humidity };
    uint8_t length = sizeof(data);
    uint8_t option = 0;

As you can see I do not enter to command mode...

well, maybe you don't need my experience xD but I was wondering if you are interesting on sleeping the board. I found these libraries:
narcoleptic --> (http://code.google.com/p/narcoleptic/)
enerlib --> (http://arduino.cc/playground/Main/LibraryList).

But, in all of them, it seems to be necessary an external action like press a button or write something on the monitor ... Well, rigth now, I am not quite sure of that, but what I need is a sort of a counter that when it is expired the board wakes up do something and again sleep, all itself without a external action.

I hope I could help you and overall,  you or somebody could give me a clue.

Greetings

(sorry for my english)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy