How to sleep the RFM69W RF model?

Started by xujianningkp, December 08, 2013, 07:02:59 PM

xujianningkp

Hey all,

I'm new to this RFM69W 915MHz RF model. I have them attached to the Moteino R3. what are the ways I can set them to sleep mode? There is a example for the RFM12B but I just can't find one for the RFM69W. Could you all give me a example of a simple C code for the RF model sleep mode function? Thank you so much.

Felix


xujianningkp

#2
#include <SPI.h>
#include <RFM69.h>
#include <RFM69registers.h>
#include <LowPower.h>

int LEDPIN=9;
#define SERIAL_BAUD 115200
RFM69 radio;

void setup()
{
    Serial.begin(SERIAL_BAUD);
    pinMode(LEDPIN, OUTPUT);
}

void loop()
{
  digitalWrite(LEDPIN,HIGH);
  delay(3000);
  digitalWrite(LEDPIN,LOW);
  radio.sleep();
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

}

------------------------------------------------------------------
Here is the simple testing code. However once I inserted the radio.sleep() the whole program is not running anymore.
radio.sleep() is for sleeping the RF model, so how can I wake them up? Do I need to include the SPI library?
thank  you

Felix

Quote"the whole program is not running anymore"

Not surprised ... I'd guess at a minimum you'd have to initialize the radio ..

You don't need to do anything to wake it up. It will wake up automatically when you poll it.
See the MotionMote example where I sleep the radio: https://github.com/LowPowerLab/RFM69/blob/master/Examples/MotionMote/MotionMote.ino

In your code you're sleeping the radio then the AVR. Which means unless there's a hardware interrupt, the AVR will sleep 8 seconds then wake up, blink the LED for 3sec then go back to sleep.

xujianningkp

Quote from: Felix on December 08, 2013, 08:39:35 PM
Quote"the whole program is not running anymore"

Not surprised ... I'd guess at a minimum you'd have to initialize the radio ..

You don't need to do anything to wake it up. It will wake up automatically when you poll it.
See the MotionMote example where I sleep the radio: https://github.com/LowPowerLab/RFM69/blob/master/Examples/MotionMote/MotionMote.ino

In your code you're sleeping the radio then the AVR. Which means unless there's a hardware interrupt, the AVR will sleep 8 seconds then wake up, blink the LED for 3sec then go back to sleep.

great thanks for your help :)
one more question. If Moteino-A sends some data to Moteino-B through RFM69W RF model (both have sleep mode), is there any way for the Motineo-A to know and wait for Moteino-B wakes up and receive all data before it (A) goes to sleep again?

Felix

When a radio is in SLEEP mode it cannot receive anything.  So you have to listen when you estimate another Moteino is sending.

KanyonKris

One way to solve this is to make one Moteino a base station (gateway) that is always listening (never sleeping) so the low power remote Moteinos can wake up, send data to the base station then go back to sleep.

If you need low power peer-to-peer communication, perhaps you can do something like: sleep for 8 seconds, wake up and send with retry for 9 seconds, and add a subloop to the main loop to listen for 1 second before going back to sleep (to catch any transmissions from the other Moteino).