Is there a way to put the radio module to sleep?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
raghavrathi
 
Posts: 13
Joined: Wed Apr 20, 2022 2:12 pm

Is there a way to put the radio module to sleep?

Post by raghavrathi »

Hi,
I am using a Adafruit Feather M0 RFM95 LoRa Radio. I am trying to find a way to put the radio module to sleep. In the documentation they mentioned that it can be done by calling " radio.sleep();" (https://learn.adafruit.com/adafruit-fea ... management). But I was unable to find radio.sleep(); in Arduino.
I even though about setting the RX pinout(0) to LOW but it didn't work. There are some LoRa radio control pinouts (4,7,8) I am not sure what functionality they have reset, but setting 4 and 7 to LOW seems to not serve the purpose. I referred this page for the pinouts (https://cdn-learn.adafruit.com/download ... module.pdf)
After setting the pin to LOW, the node is still receiving the signal.

I am fairly new, so I don't have much knowledge regarding this, but any help is appreciated.
Thank you

Code: Select all

#define RX 0
int flag = 0;

void loop()
{
  if (rf95.available())
  {
    digitalWrite(LED, HIGH);

    flag = flag+1;
    // Should be a message for us now
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);

    if (rf95.recv(buf, &len))
    {
      if(flag == 1){ // set the radio off after receiving 1st message
        digitalWrite(RX, LOW);
        flag = flag+1;
        }
      RH_RF95::printBuffer("Received out: ", buf, len);
      delay(1000);
// create a reply
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
}

User avatar
mikeysklar
 
Posts: 14194
Joined: Mon Aug 01, 2016 8:10 pm

Re: Is there a way to put the radio module to sleep?

Post by mikeysklar »

You should be able to use sleep() from the adafruit/RadioHead library.

https://github.com/adafruit/RadioHead

If you are using rf95 as your prefix it would be rf95.sleep().

User avatar
raghavrathi
 
Posts: 13
Joined: Wed Apr 20, 2022 2:12 pm

Re: Is there a way to put the radio module to sleep?

Post by raghavrathi »

Hi Mike,
Thanks for the reply. I have already tried to use rf95.sleep() but I didn't observe any change.

User avatar
mikeysklar
 
Posts: 14194
Joined: Mon Aug 01, 2016 8:10 pm

Re: Is there a way to put the radio module to sleep?

Post by mikeysklar »

Are you using the Adafruit RadioHead library or a different one?

There are other options.

Watchdog.sleep() - but I'm not sure how well it wakes up from this. One person mentioned using standbyMode() on the issue thread linked below.

https://github.com/adafruit/Adafruit_Sl ... /Sleep.ino
https://github.com/adafruit/Adafruit_SleepyDog/issues/7

Another more extreme option is to use an external timer like the TPL5110 and shut it all down for specific intervals.

viewtopic.php?t=115131

User avatar
raghavrathi
 
Posts: 13
Joined: Wed Apr 20, 2022 2:12 pm

Re: Is there a way to put the radio module to sleep?

Post by raghavrathi »

Hi Mike,
Thanks for the information. Its working but I am facing the same issues like others with the serial, but then I can work it out. Thanks a lot.

User avatar
mikeysklar
 
Posts: 14194
Joined: Mon Aug 01, 2016 8:10 pm

Re: Is there a way to put the radio module to sleep?

Post by mikeysklar »

Which sleep code did you end up using that is working?

User avatar
raghavrathi
 
Posts: 13
Joined: Wed Apr 20, 2022 2:12 pm

Re: Is there a way to put the radio module to sleep?

Post by raghavrathi »

I am using watchdog.sleep() currently. But the serial keeps breaking when it goes to sleep so it gets harder to see if it is working properly, but it's better than nothing. Trying to work it out.

User avatar
mikeysklar
 
Posts: 14194
Joined: Mon Aug 01, 2016 8:10 pm

Re: Is there a way to put the radio module to sleep?

Post by mikeysklar »

Have you seen these two forum threads related to serial monitoring and sleep wakeup on the M0 boards?

viewtopic.php?f=52&t=137543

viewtopic.php?f=57&t=137520

User avatar
raghavrathi
 
Posts: 13
Joined: Wed Apr 20, 2022 2:12 pm

Re: Is there a way to put the radio module to sleep?

Post by raghavrathi »

Thanks Mike for pointing me towards that post, I tried his Comm, I am a linux user so I was able to use it using Wine because that comm is made for windows. After getting a connection in the comm, I am not able to see any output. It can be some platform differences but I will try to contact the author if I cannot fix it.

User avatar
mikeysklar
 
Posts: 14194
Joined: Mon Aug 01, 2016 8:10 pm

Re: Is there a way to put the radio module to sleep?

Post by mikeysklar »

Looking at the authors Main.pas code in the comm.zip it looks like the code is just counting through serial ports attempting to grab the next COM# port when it becomes available.

If you are on linux that might be as simple as a shell script. Here is some pseudo code without any retry or wait logic.

Code: Select all

for i in `seq 0 9`
do
screen /dev/ttyS$i
done

User avatar
raghavrathi
 
Posts: 13
Joined: Wed Apr 20, 2022 2:12 pm

Re: Is there a way to put the radio module to sleep?

Post by raghavrathi »

I use stty to get the serial output in terminal in something like this,
>> stty -F /dev/ttyACM0 raw 115200
>> cat /dev/ttyACM0

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”