PROTO low power mode

Reducing PROTO power consumption with sleep mode

Tom

If you want to use the Industruino in a low power mode, you can make use of the standard Arduino sleep functions to reduce the power consumption to 10-15mA.

Your sketch can put the Industruino in sleep mode, and an interrupt on pin 2 (INT1) or 3 (INT0) can wake up the microcontroller again. One issue to keep in mind is that the wake up from full SLEEP_MODE_PWR_DOWN does not restore the USB connection. So you need to make sure that your sketch allows some time to upload new code before entering sleep mode, otherwise the Serial connection breaks before any new code can be uploaded.

Below code runs on the Industruino PROTO with 32u4 topboard. It counts 10 seconds before going into sleep mode. The first 5 seconds with the backlight full on, then off. Wake up by putting GND on D3 (INT0), and the counter starts again. The interrupt only works while in sleep mode.

The normal power consumption (power supply of 5V) with backlight LED (D13) full on is around 100mA, and with the backlight off, it's around 45mA.

Going into sleep mode reduces this to around 13mA, a considerable power saving.

/* Industruino PROTO low power test
 *  sleep mode http://forum.arduino.cc/index.php?topic=146159.0
 *  topboard 32u4
 *  power consumption with 5V power supply:
 *  active mode: 110mA (backlight ON)
 *  active mode: 45mA (backlight OFF)
 *  sleep mode: 13mA
 *  
 *  Tom Tobback, October 2016
 */

#include <avr/sleep.h>

#include <UC1701.h>
static UC1701 lcd;

long timestamp;

void wakeupFunction() {
  timestamp = millis();
  digitalWrite(13, LOW) ;              // backlight ON
}

void toSleep() {
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_enable();
  attachInterrupt(0, wakeupFunction, LOW); // wakeupbutton : pin 3 on leonardo!!!
  sleep_mode();                            // here MCU goes into sleep
  // here MCU resumes after sleep
  detachInterrupt(0);
  sleep_disable(); //fully awake now
}

void setup()
{
  Serial.begin(9600);  
  pinMode(3, INPUT_PULLUP);
  Serial.println("allow time for new upload..");

  lcd.begin();
  lcd.clear();
  lcd.setCursor(3, 2);
  lcd.print("Allow time");
  lcd.setCursor(3, 3);
  lcd.print("for new upload");
  
  delay(5000);         // to be able to upload new code
                       // USB connection is lost after sleep

  timestamp = millis();
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);     // backlight ON
  lcd.clear();
}

void loop()
{
  int counter = (millis() - timestamp) / 1000;

  lcd.setCursor(3, 2);
  lcd.print("AWAKE");
  lcd.setCursor(3, 4);
  lcd.print(counter);
  lcd.setCursor(3, 6);
  lcd.print("backlight ON");
  
  if (counter > 5) {
    digitalWrite(13, HIGH);           // backlight OFF
    lcd.setCursor(3, 6);
    lcd.print("backlight OFF");
  }

  if (counter >= 10) {
    Serial.println("going to sleep...");   // only works first time, after wake up the serial connection is broken
    lcd.clear();
    digitalWrite(13, HIGH);      // backlight OFF
    toSleep();
  }
}