Low power WITHOUT BURNING FUSES !!!

9 years 1 month ago - 9 years 1 month ago #2330 by skywatch
Hi all,

There has been much confusion and frustration about burning fuses to get a low
power arduino to work with battery sensors.
The 'tutorial' on this site leaves a lot to be desired :whistle: :lol:

Fear not, you DO NOT need to burn fuses to run in low power mode. That's right!
You can do it all in the arduino sketch and here is how to do it........

To run at a lower clock frequency only requires 2 lines added to the setup loop...
I added a third line to disable the ADC as this too saves power.
The below example has the options commented in so you can copy and paste
without losing details.

SET THE CLOCK.......
#include <SPI.h>
#include <MySensor.h> 

void setup() {
  // put your setup code here, to run once:
  
  // turn off ADC if not needed...  
  ADCSRA = 0;

//Now set the clock speed. I suggest that you do this as the last 
//enty in setup as then all code before it will execute at full speed.  
  
// Get ready to change the clock speed...

  CLKPR = 0x80;

// Make sure that this line is *immediately* followed by the next line. 
//No other code inbetween please.

//Set the next line by using one of the following .....
//0x01=clock divided by 2 
//0x02=clock divided by 4 
//0x03=clock divided by 8
//0x04=clock divided by 16

  CLKPR = 0x03; 

//So on an 8MHz pro mini the above will set it to 1MHz clock. - No fuses required!
}

DISABLE BROWN OUT DETECTOR
void loop() {
  // put your main code here, to run repeatedly:
    //Add the following in your code where you want to sleep the arduino 
    //with lowest power  //consumption.

 set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
 sleep_enable();
 MCUCR |= bit(BODSE) | bit(BODS); // timed sequence
 MCUCR = (MCUCR & ~bit(BODSE)) | bit(BODS);
 sleep_cpu();
}

That is all there is to it - 2 or 3 lines in setup and 5 lines in the loop - Simples! :)

I have tested this on a pro mini 5V 16MHz without regulator or led removed and it reduced the current from 14.5mA to 3.24mA!

With 3V 8MHz pro mini with led and regulator removed it goes down below a value my trusty old Fluke 75 can measure(!) - Note to self, must get a new good low current multimeter, any suggestions (not mega bucks though please)?

I hope this will help people who are put off trying this when they get to the low power
set up stage, I know it annoyed me! :)

It's my Birthday on Thursday, so this is a little early present from me to you! :)

So now you know, have fun!

Skywatch

Please Log in or Create an account to join the conversation.

8 years 5 months ago #3374 by neofox2k
Thats it's very interesting a useful. I'll try it next weeks.

Have you test it for a long time?


Thanks

Please Log in or Create an account to join the conversation.

8 years 5 months ago #3386 by skywatch
I was simply looking for a way to reduce power use without anything complicated that anybody could easily add to their projects.

I have tested for a few months, but lost interest in easyiot when it went from pi to cloud based as my main application is at a location with no internet connection. So only a month or so with that.

Please Log in or Create an account to join the conversation.

8 years 4 months ago #3393 by EasyIoT
Correct me if I'm wrong - you can set fuses in SW, but if Atmel goes in sleep and wakes up with interrupt fuses are set to initial state. This means if you set BOD to 1,8V in SW it may happen that after interrupt it doesn't run any more if battery voltage is too low, because BOD will be in initial state.

Please Log in or Create an account to join the conversation.

Time to create page: 0.249 seconds

Forum latest

  • No posts to display.