Is the receiver module active while in watchdog.sleep()?

Hi,

I am using a Adafruit Feather M0 RFM95 LoRa Radio. I am trying to use the feather to receive some messages from a trace which contains multiple messages. In order to skip any unintended message, I am trying to use watchdog.sleep(x) to skip past that message, but the feather is somehow able to receive a message which is being transmitted while the feather is sleeping and by the time feather wakes up, it still receives that message.
The length of each message is 362ms and I am making the feather sleep for 500ms.
Does the receiver module says active while the watchdog.sleep() is active? How is feather able to receive the signal which is in the air and the board is sleeping?

unsigned long MSGSlotsA[20] = {1,2000000,4000000,6000000,8000000,10000000,12000000,...};
unsigned long MSGSlotsB[20] = {300000,2300000,4300000,6300000,8300000,10300000,12300000,...};

void loop()
{
  digitalWrite(LED, LOW);

  if (rf95.available())  {
    digitalWrite(LED, HIGH);
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);   
    
    if (rf95.recv(buf, &len)){
      printBuffer(buf, len);

      if(buf[2] == 0 && buf[4] == 0){ //beacon format                
        if(startFlag == 0){ //just to set the start time
          Serial.println("Setting start time ");
          startTime=micros(); //this will give us a ref time for the next msg
          startFlag = -1;
          startCtr = 1;
        }
      }
      else{
            Serial.print("Received at ");
            Serial.println(micros()-startTime + sleepDiff);        
        }        
      }

  }
  if(startCtr == 1){
    timeNow = (micros()-startTime) + sleepDiff;    
    if (timeNow > MSGSlotsB[msg_ctr]-550000) { //go to sleep 550ms before the coming msg for 500ms   
      beforeSleep = micros()+sleepDiff;
      Serial.print("Time before sleep: ");    
      Serial.println(beforeSleep-startTime); 

      Watchdog.sleep(500); // the board will wake up 50ms right before the message is expected

      Serial.print("Time after sleep: ");
      afterSleep = micros()+sleepDiff;
      Serial.println(afterSleep-startTime);
      
      sleepDiff += 500000; //because the micros() pauses during sleep
      msg_ctr++;
      
    }
  }
}


Measure the current used by the device. "~300uA during full sleep, ~120mA peak during +20dBm transmit, ~40mA during active radio listening." If not around 300uA, then it is NOT sleeping.

Hi Paul,

I don't have any external device to measure the current used by the device. I am fairly new with this so I don't have much knowledge about whether I can use any library that can report the current consumed.
Any help is appreciated.

The next step in your Arduino hobby is to begin to get test equipment so you can determine how your project is operating. A digital volt-Ohmmeter is very low priced and readily available. Start there!

Thank you for the suggestion, I will get that.
BTW Do you think if there seems to be anything wrong with the code?

When you sleep the micro on your feather, the radio module is probably still wide awake.

How do you know that it's an unintended (whatever that might mean) message? Just read the message, check it and ignore it away if it's unintended.

Okay, I will get a volt-Ohmmeter and verify the current consumption as well. Thank you

I have created a time schedule for the messages. Since the length of each message is around 362ms with preamble 110ms, there is a possibility of a slight overlap.
Now, since I know the time of arrival, Based on that, I am trying to make the receiver sleep so that it skips the unintended message. If I don't do that and lets say message A and B have a small overlap, with A in the beginning and I want to receive B, If the module does not sleep and receives A first then based on the principles of collision in LoRa, it will lock on to A's preamble and then it will ignore B. Hence I am trying to make the feather sleep with A is being transmitted so that once the preamble of A is skipped, B's preamble will be locked and the feather will receive B.
I home I am not confusing you.

Overlap of what? Are there two transmitters?

Overlap of the messages, the way the trace is created. Right now I only have one transmitter so I am creating a trace and then playing it over USRP B210 but yes, there can be 2 transmitters as well.
A collided message will look something like this.

Overlapped messages from two transmitters are guaranteed to interfere with each other, leading to loss of data.

Well the way I have created this trace right now is in matlab by adding 2 different wave forms and then I am transmitting it using a single transmitter. I have already tested it and It can be decoded.
So I don't think there is any problem with data loss. Because the feather can decode the collided packet but the abnormality I am ovserving with the sleep is the issue right now.

Be sure to patent your decoding method!

Thank you, we are already working on it. :slight_smile:
Do you have any suggestions with the sleep?

Make sure the meter you chose can measure below 1milliamp. 10's of microamps should be good enough.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.