Arduino with nrf24l01 as keyless system

Hello,
Im trying to make keyless system with two nrf24l01 and two arduino (in final product atmega8L)
How it will work:

if first arduino detect motion with PIR sensor then nrf send packet to key, if key receive packet it will respond to arduino
so it looks like: sending packet to key with question “are you there?” when key receive packet it will respond “yes, i am here”

if key doesn’t respond that means someone triggered PIR sensor without key and first arduino is sending sms to me about this fact.
This project works great on breadboards with unlimited power supply

Where is problem?

Key will be powered from CR2032 battery it has about 200mAh capacity so I need to handle avr sleep feature with interrupt

nrf24l01 has IRQ pin which changes state when receiving so its good as interrupt to execute response function

but nrf24l01 must be in listening mode to receive packet and make interrupt otherwise there is no way to wake sleeping arduino

so:
at the beginning arduino draws 30mA
after few seconds it drops to 19mA (its sleeping but nrf24l01 is listening)
when I turn off listening it drops to 3mA but I won’t be able to receive packet and wake arduino
is there way to listen for packet “without listening”?
I heard about retrieving packets from payload, but I can’t get it work

my receiver code:

#include <SPI.h>
//#include "nRF24L01.h"
#include "RF24.h"
#include <avr/sleep.h>
byte msg[1];
const int pinCE = 9; //This pin is used to set the nRF24 to standby (0) or active mode (1)
const int pinCSN = 10;
const uint64_t pipe = 0xE8E8F0F0E1LL;
const uint64_t pipe2 = 0xF0F0F0F0AA;
int odczytano = 0;
RF24 radio(pinCE,pinCSN);
 
void setup()
{
 Serial.begin(9600);
 radio.begin();
 radio.setAutoAck(1);
 radio.enableAckPayload();         //allows you to include payload on ack packet
 radio.maskIRQ(1,1,0);
 radio.setChannel(115);  //115 band above WIFI signals
 radio.setPALevel(RF24_PA_MIN); //MIN power low rage
 radio.setDataRate( RF24_250KBPS ) ; //Minimum speed
 radio.openReadingPipe(1,pipe);
 radio.openWritingPipe(pipe2);
 radio.startListening();
 //zeby sie tx nie swiecil, a bo to jest wlasnie sluchanie.
 
 ADCSRA = 0;
 
}
 
void loop()
{
set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
  sleep_enable();
 
  // Do not interrupt before we go to sleep, or the
  // ISR will detach interrupts and we won't wake.
  noInterrupts ();
 
  // will be called when pin D2 goes low  
  attachInterrupt(0, bylo, FALLING);
  EIFR = bit (INTF0);  // clear flag for interrupt 0
 
  // turn off brown-out enable in software
  // BODS must be set to one and BODSE must be set to zero within four clock cycles
  MCUCR = bit (BODS) | bit (BODSE);
  // The BODS bit is automatically cleared after three clock cycles
  MCUCR = bit (BODS);
 
  // We are guaranteed that the sleep_cpu call will be done
  // as the processor executes the next instruction after
  // interrupts are turned on.
  interrupts ();  // one cycle
  sleep_cpu ();   // one cycle
 
}
 
void bylo()//interrupt function
{
  sleep_disable();
  Serial.println("interrupt");
  odczyt();
  radio.startListening();
  detachInterrupt (0);
}
 
 
void nadaj()//send
{
 
  Serial.println("nadaje");//sending
 // delay(2000);
 
 msg[0] = 124;//epic security method :D
 radio.write(msg, 1);
}
 
void odczyt()//read
{
 
  Serial.println("odczytuje");//reading
 
   if (radio.available())
{
 
   while (radio.available()){
     radio.read(msg, 1);
     Serial.print("Odczytalem: ");      
     Serial.println(msg[0]);
     if (msg[0] == 123)//epic security method :D
{
radio.stopListening();
nadaj();
}
}
}
}

any ideas?

It would be easier to have the key sleep and then just wake up every 5 secs or so and broadcast that it is there. Then the PIR sensor can disarm, so to speak.

I have been thinking abut doing something like this, here is the plan i came up with let the "key" send a I am here packet every 4 or 8 sec or so, if you sleep with atmega8l and the nrf you should get down to less then 10ua during sleep. And when you wake up only stay awake the absolutely minimal time and send out a minimal power message at 250kbps with aa inactivated, this should take less then 5ms. If you can manage this a cr2032 should last at least half a year, 1 year are not impossible.

And then let the pir receiver only send the "intruder" sms when movement are detected and no message have been received in the last 40 sec or so.

Sorry there is no way to make the nrf24l01 listen during power-down.

If there is no way to listen during power-down your idea should be best option to do that. I will be happy with 3 month battery life :wink:

aa inactivated
??
what I can turn off to save power?

Thanks for help,

I have posted in few places, and just here I received answer with possible way to do that :wink:

PS key will only send data so I can use attiny85 which should be easier to solder on board

Have you seen Nick Gammon's power saving tutorial?

...R

Yep, used Sketch J in my receiver code but forgot about rest ;p

Thank you

aa= Auto acknowledgement

It means after the transmitter sends a message it listens for a automatic reply from the receiver.
If you want to save as much power as possible both the time you are waiting and the power the nrf takes in receiver mode are unnecessary.

I can not solve this problem for a long time but I could not solve the event when the receiver comes to the side of the transmitter,

freekevin:
I can not solve this problem for a long time but I could not solve the event when the receiver comes to the side of the transmitter,

I'm not sure if you are telling us that you have found a solution or you still have a problem.

If you have a problem and would like some help then post your pair of programs and explain in detail what they actually and what you want them to do that is different.

...R

PS. I have no idea why you posted your question in this Thread as it did not come to a useful conclusion.