nrf24l01 resuming after powercut

Building some low power sensors with Pro Mini and NRF24 and to minimize any leak currents of a regulator, I thought to power the radio with an output of the Atmega328P (regulator between output and nrf24).

I'm having trouble getting nrf24 to continue transmitting after the power resumes. I'm re-initializing it after the power cut but still still it fails if I cut the power every cycle, no matter how long delays I set before and after sending for the power toggling.
Most importantly, it works perfectly well if I cut the power only every other cycle.

I'm using the blocking write() and I don't see anything in RF24 source that would require a second cycle, so don't really know why it's acting like this. I can of course build the code to run a second cycle before powering off the radio and putting uC to sleep but would rather get it working without such "random" hacks.

It's again probably some stupid thing I'm not seeing but would appreciate any input. Thanks in advance!

void InitNRF24() {
  radio.begin();
  if (radio.failureDetected) {
    radio.failureDetected = 0;           // Reset the detection value
    PRINTL("NRF24 failure recovery");
  }

  if (!radio.isChipConnected()) {
    PRINTL("NRF24 chip not connected");
  }
  radio.openWritingPipe(address); // Re-configure pipe addresses
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS );
  radio.stopListening();
}


int sendcount = 1;
long millisp;

void loop()
{
  digitalWrite(NF24_PWR_PIN, HIGH);
  delay(100);
  InitNRF24();

  char text[27];
  sprintf(text, "Hail Satan and greetings %d", sendcount);
  radio.write(&text, sizeof(text));
  // radio.powerDown();
  delay(100);
  
 PRINTL(sendcount);

  
  // *** This works ***
  if (sendcount % 2 == 0) {
    digitalWrite(NF24_PWR_PIN, LOW);
    PRINTL("power down");
    delay(2000);
  }

  // *** This doesnt work ***
//  digitalWrite(NF24_PWR_PIN, LOW);
//  PRINTL("power down");
//  delay(2000);
  
  sendcount += 1;
  delay(1000);
}

How are you cutting power to the nRF24?

I have run my code (in this Simple nRF24L01+ Tutorial) on a pair of Unos. I can't recall ever having had a problem when I disconnect one the the Unos from the PC and later reconnect it. Communication starts again.

On the other hand I have built a few small receivers for model trains with an nRF24 and an Attiny powered by a 1S LiPo. I suspect my battery connections are dodgy and sometimes the radio communication seems to fail even though the flashing LED signifies that the Attiny is working. I have to remove the battery and re-insert it to get things going. I have not investigated this properly (laziness). Because the trains are small and they move debugging is not simple.

One thought is whether there needs to be a certain minimum power-off time for the nRF24 to get its ducks in a row.

...R

nRF24 VCC is fed with digital output (with a 3.3v regulator in between). Note NF24_PWR_PIN in the code.

Sure, it works fine if the whole thing is powered down but in my case the atmel328P stays a wake / in sleep and only the radio is fully powered down.

Like said, I do this instead of just using nRF24 sleep mode because the regulator has too much leakage current to leave it connected to battery supply directly (yeah I know, there are regulators that do quite well but I'll try to manage with what I have in hand).

Also like said, the nRF24 does work after a powercut but it needs to be handled in a certain way or then it will need few cycles / communication retries to resurrect. You can try to disconnect the VCC of it manually and plug it back and see how many cycles it misses.

Anyhow what I'm curious about is what exactly causes it work fine if I only cut the power on every other cycle.

willmackey:
nRF24 VCC is fed with digital output (with a 3.3v regulator in between). Note NF24_PWR_PIN in the code.

I can’t make sense of that. On the face of it you are drawing power for the nRF24 from one of the Arduino I/O pins. But they can only supply a max of 40mA and really should only be expected to provide about 20mA whereas an nRF24 needs considerably more than 40mA.

Please post a circuit diagram so we are all seeing it the same way. A photo of a pencil drawing is best. See this Simple Image Posting Guide

What voltage is on the nRF24 signal pins when the nRF24 is powered down and the Arduino is awake or asleep?

…R

There's not much to make sense about, or to draw diagrams of:
Arduino output -> 3.3v regulator (actually up/down booster) -> nRF24 VCC

Where did you come up with >40 mA requirement? Specs say 13.5 mA max and even the shitty china clones can't draw that much more. My crappy DMM measures 28 mA from Arduino output if sending that 27 bytes packet every cycle (using the blocking .write() method) with max transmitting power at 250 kbps. I'm sure that amount isn't a problem as the node would be only sending once per 10 mins few bytes and additional capacitor would help with surges.

If the current would be an issue, it would not work with this cyclical write example either.

I did try to write CSN pin HIGH and MISO, MOSI, CE, SCK pins LOW before killing the VCC from the radio and also some other combinations but they didn't seem to make any difference. RF24 lib radio.begin() sets them back to initiate comms after powering it up again. Didn't measure the actual voltages there tho.

My current measurements seem to align with this guy's ones:

This is the kind of temporary hack that I use to get past this issue and it works without problems. Still, would rather know the root cause.

unsigned int sendcount = 1;
unsigned int cyclecount = 1;
void loop()
{
  
  if (cyclecount % 2 == 1) {
    digitalWrite(NF24_PWR_PIN, HIGH);
    delay(100);
    InitNRF24();
  
    char text[32];
    sprintf(text, "Hail Satan and greetings %d", sendcount);

    radio.write(&text, sizeof(text));

    sendcount++;
  } else {

    digitalWrite(NF24_PWR_PIN, LOW);
    PRINTL("power down");
     delay(1000);
  }

  PRINTL(cyclecount);
  cyclecount++;
}

willmackey:
There's not much to make sense about, or to draw diagrams of:
Arduino output -> 3.3v regulator (actually up/down booster) -> nRF24 VCC

I am intrigued. I have not heard of that being done before.

Many people on the Forum have not been able to get an nRF24 to work when powered from the 3.3v pin on a nano and I have not been able to get them to work from the 3.3v pin on a Mega clone - even though they work fine on a genuine Mega.

It must be that your 3.3v booster is acting as a store of energy.

Please post a link to the datasheet or supply source for the booster you are using.

...R

It’s one of these I believe. If the link gets broken just search ‘2 in 1 up down converter 3.3v’ in ebay.
I ordered years ago, can’t recall if the chip was the same but quite surely it was.
Chip silk screen says N1IF and a bit of googling claims it to be the same as HX4002

Again, have I missed something as I never saw any info mentioning about higher than advertised currents?

willmackey:
Again, have I missed something as I never saw any info mentioning about higher than advertised currents?

I don't think so. The largest number in the Power consumption table in my nRF24L01+ datasheet is 13.5mA and that is for receiving.

But, then, why won't the nRF24 module work from some 3.3v output pins - maybe there is more current drawn by other components on the module?

If I follow your logic then the nRF24 should work directly from an I/O pin of an Atmega 328 powered with a pair of AA alkaline cells. I might try that in the near future.

...R

Maybe I'm just lucky (never been, don't know what it feels like), but I haven't had any issues so far with it, except the oddity that this thread was/is about. Still would appreciate any tips why it needs that extra cycle after TX before shutting down.

I'm renewing my sensor network and don't have long term experience on this setup but so far the sensor has been running fine on a fiddly breadboard test bench that is anything but ideal.

2xAA is one option but hoping to gain longer overall battery life with 3xAA + the booster. I can't leave the booster directly after output tho as it starts to draw too much current once the voltage gets low but instead have output controlling a transistor that lets the current flow from battery via this current hungry booster to the radio. This booster has a crappy no-load power consumption of 300uA and that's why I'd rather not leave it draining when everything else sleeps.

Then again, if you go with 2xAA, why don't just connect the nRF24 VCC directly to batt and use its sleep mode? It seems to be quite efficient, or at least the samples I have measure 2uA when sleeping.

willmackey:
Then again, if you go with 2xAA, why don't just connect the nRF24 VCC directly to batt and use its sleep mode? It seems to be quite efficient, or at least the samples I have measure 2uA when sleeping.

I was not suggesting that you should use 2 x AA cells, and I was only thinking of powering the nRF24 from an I/O pin to try out your system. My feeling is that it won't work without your booster - but it might.

I have built some battery powered projects with the nRF24 connected to the 2xAA cells. However my projects need to operate continuously so I have not been concerned with sleeping. The batteries are in RC transmitters that are used infrequently.

...R