rocketscream / Low-Power

Low Power Library for Arduino
www.rocketscream.com
1.27k stars 346 forks source link

Nrf24l01 not working after sleep #41

Closed jeffp600 closed 7 years ago

jeffp600 commented 7 years ago

I have multi pir (4) with nano atmega128p, nrf24l01.the pit will trigger the onboard led but not the radio. I have tried every lib I can find to no avail. All I want is to save changing 4aaa batteries every few days. I tried the code at start , end of void(loop). Any help?

include

include

include

include

int transmitterId;

// Set up nRF24L01 radio on SPI bus plus pins 9 & 10 //Contacts from the radio to connect NRF24L01 pinamnam -> Arduino

//SCK -> 13 //MISO -> 12 //MOSI -> 11 //CSN -> 10 //CE -> 9

RF24 radio(9, 10);

// this is not the channel address, but the transmitter address const uint64_t pipe = 0xE8E8F0F0E1LL;

//button connected to these pins

int buttonPin1 = 2;

void setup() {

// CHANGE THIS PER EACH TRANSMITTER, from 0 to 4
transmitterId = 1;

radio.begin();

// the following statements improve transmission range
radio.setPayloadSize(2); // setting the payload size to the needed value
radio.setDataRate(RF24_250KBPS); // reducing bandwidth

radio.openWritingPipe(pipe); // set the transmitter address

}

void loop() {

LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF);

//until the button (buttonPin1) pressed send the package (id) to receiver Arduino
if (digitalRead(buttonPin1) == HIGH) {

    // some implementations automatically shut down the radio after a transmission: this
    // ensures the radio is powered up before sending data
    radio.powerUp();

    // read and write expect a reference to the payload (& symbol)
    // second argument is the packet length in bytes (sizeof(int) == 2)
    radio.write(&transmitterId, 2);
}

}

NeoLegends commented 4 years ago

What was your solution to this? I have the same radio.