Showing posts with label power efficiency. Show all posts
Showing posts with label power efficiency. Show all posts

Sunday, April 19, 2015

Reducing Arduino’s Power Consumption Part 4 (Turning Off the BOD)

This is the fourth, and most likely the last, in a series where we look at how to reduce your Arduino's power consumption. This series is great for anybody working on a project that is battery powered and you want to ensure the longest battery life possible. In this part we will look at how to turn off the Brown Out Detector (BOD) to save power.



************************Arduino Code*******************************************
/* This Arduino Sketch is part of a tutorial on the ForceTronics YouTube Channel and demonstrates how to use the Sleep cabilities on
Arduino as well as turn off the ADC to get low power consumption. In this tutorial the Extended Fuse on the Atmega was configured
to turn off the Brown Out Detection (BOD) for even further power savings. It is free and open for anybody to use at their own risk.
*/

/*
To turn off the BOD avrdude was used via the command prompt, the following command was used:
avrdude -c usbtiny -p atmega328p -U efuse:w:0x07:m
*/

#include <avr/sleep.h>

void setup() {
  delay(6000); //Delay to see normal power level first
  sleep_enable(); //enable the sleep capability
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); //set the type of sleep mode. Default is Idle
  ADCSRA &= ~(1<<ADEN); //Turn off ADC before going to sleep (set ADEN bit to 0)
  sleep_cpu(); //enter sleep mode. Next code that will be executed is the ISR when interrupt wakes Arduino from sleep
}

void loop() {
  // put your main code here, to run repeatedly:
}

Sunday, November 30, 2014

Reducing Arduino’s Power Consumption Part 2

In Part two, of this three part series, we will look at how to use the Power Reduction Register (PRR) to reduce power consumption by turning off parts of Arduino that are not being used. This series is for anybody using Arduino for a battery powered project where maximizing battery life is critical.



*************************Arduino Code***********************************
/* This Arduino Sketch is part of a tutorial on the ForceTronics YouTube Channel and demonstrates how to use the 
Power Reduction Registers (PRR). It is free and open for anybody to use at their own risk.
*/

#include <avr/power.h>
     
 /* Power Reduction Register (PRR) functions from avr/power.h library. 
 For every disable function there is an enable function
  power_adc_disable() or power_adc_enable()
  power_spi_disable() or power_spi_enable()
  power_timer0_disable() or power_timer0_enable()
  power_timer1_disable() or power_timer1_enable()
  power_timer2_disable() or power_timer2_enable()
  power_twi_disable() or power_twi_enable()
  power_all_enable() or power_all_disable()
  
  Note that for max power efficiency you should also disable the rest of the module for ADC and SPI
   SPCR = 0; //disable SPI
   ADCSRA = 0;  // disable ADC
  */

void setup() {
  delay(6000); //Delay to see normal power level first
  ADCSRA = 0;  // disable ADC by setting ADCSRA register to 0
  power_adc_disable(); //disable the clock to the ADC module
  delay(4000); //delay to see just ADC off power level
  SPCR = 0; //disable SPI by setting SPCR register to 0
  power_spi_disable(); //disable the clock to the SPI module
  delay(4000); //delay to see just ADC and SPI off power level
  power_all_disable();
}

void loop() {
  // put your main code here, to run repeatedly:
}