Nrf24lo1 low power consumption using attiny44

Hi, i am trying to write a code that would reduce my NRF24lo1 power but it is constantly showing me 13mA i want it to be in uA and for that purpose i tried using the powerUp and powerDown function but unfortunately it didnt worked out for me, please check my code and let me if there are any errors to it.
I will be powering it up using coin battery and with 13mA it will deplete very fast.

I am using arduino UNO as a programmer for my attiny44 IC.

#include<nRF24L01.h>
#include<RF24.h>
#include<avr/wdt.h>

///pin
#define led 3
#define solarPin 7
#define CE 9
#define CSN 10

byte api='L';
byte ledState=LOW;
RF24 radio(CE, CSN);
const byte address[5]={ 'M', 'T', 'P', '0', '0'};

unsigned long lastSignal=0;
unsigned long Time=500;
unsigned long lastSolarCheck=0;
unsigned long lastSave=0;
unsigned long sleepTime=0;
bool night=false;
bool saveMode=true;
bool Sleep=true;
bool w=true;

void setup() {

wdt_enable(WDTO_4S);

pinMode(led, OUTPUT);
pinMode (solarPin,INPUT);

radio.begin();
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_250KBPS);
radio.setChannel(0x66);
radio.setRetries(0, 0);
radio.setAutoAck(false);
radio.openReadingPipe(0,address);
radio.maskIRQ(1,1,0);
radio.startListening();
attachInterrupt(0, interruptFunction, FALLING);
}
void solarCheck()
{
if(millis()-lastSolarCheck>=5000)
{
night=((digitalRead(solarPin)==LOW)?true:false);
lastSolarCheck=0;
}
}
void loop() {

wdt_reset();

//after reciving signal, go to poweSave mode till ,10ms before next signal
PowerSave();

//check solar for every 5 sec
//solarCheck();

//if no signal for more then (2 signal time ) then go to sleepMode for 5mins
sleepMode();

///wakeup from sleepMode
//wakeUp();

}
void interruptFunction(){
if(radio.available())
{

radio.read(&api, sizeof(api));
ledState = (api== 'H')?HIGH: LOW;
digitalWrite(led ,ledState);
saveMode=false;
Sleep==false;
lastSignal=millis();
radio.stopListening();
radio.powerDown();
}

}

void PowerSave()
{
if((millis()-lastSignal>=Time-10)&&( saveMode==false))
{
radio.powerUp();
//radio.openReadingPipe(0,address);
radio.startListening();
saveMode=true;
}
}

void sleepMode()
{
if((millis()-lastSignal>=2000)&&(Sleep==false))
{

ledState=LOW;
digitalWrite(led, ledState);
radio.stopListening();
radio.powerDown();
sleepTime=millis();
Sleep=true;
w=false;

}
}

/*
void wakeUp()
{
if((millis()-sleepTime>=180000UL) && (Sleep==true) &&(w==false))
{
Sleep=false;
w=true;
radio.startListening();

}

}
*/

Are you measuring the total current consumed by the MCU and the NRF24L01 module together or just the current consumed by the NRF24L01 module ?

See here for putting the MCU in a sleep mode for maximum power saving: Gammon Forum : Electronics : Microprocessors : Power saving techniques for microprocessors

@anon52178662, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the Installation & Troubleshooting category.

Please edit your post, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.

i am measuring for nrf module and if i put my MCU to sleep mode the led won't light up

First of all, can you make the change suggested in post #3. Even better would be to format it nicely in the Arduino IDE beforehand.

You haven't said which NRF24L01 module you are using but I guess with a coin cell as a power source, it has to be the small module i.e not the one with a power amplifier and an SMA antenna.

The problem is that a lot of these are clones and power consumption can be a problem with non-original chips. When I use these devices in battery applications, I switch their power off usually using a mosfet or similar. I've published two projects here which use such method:

You may find something there you can use.

I'm not quite sure what your problem is with the MCU sleep mode but the code you have posted does not appear to use it.

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