turning off / sleep mode Adafruit feather Proto

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
yigiter007
 
Posts: 175
Joined: Thu Oct 03, 2013 10:37 am

turning off / sleep mode Adafruit feather Proto

Post by yigiter007 »

I have a battery powered feather doing a bunch of things. I want to know how to turn it off when its connected to battery. I read the overview page and it said you can disable the 3.3 regulator, does that mean it would stop powering the pin or stop regulating/reducing the voltage to a safe level?

Also is there a way to make the feather/32u4 go to sleep mode? is there a arduino command or assembly command i can put into arduino IDE to enable sleep?

Thanks for any reply and help!
Last edited by yigiter007 on Wed Apr 13, 2016 3:34 pm, edited 1 time in total.

User avatar
yigiter007
 
Posts: 175
Joined: Thu Oct 03, 2013 10:37 am

Re: turning off / sleep mode Adafruit feather Proto

Post by yigiter007 »

Also i found a example code from a reply in another forum. Would this work for sleeping the feather?

Code: Select all

// Demonstrates power down mode. 
// Sketch will put Arduino to sleep when Pin 2 is HIGH
// Arduino will wake when Pin 2 goes low
// You can substitute another external interrupt pin for pin 2:
// See http://arduino.cc/en/Reference/AttachInterrupt for pin
// and interrupt number information.
// Written by Rick Lesniak for Adafruit Industries

#include <avr/sleep.h>

void setup()
{
  Serial.begin(115200);
  pinMode(2, INPUT_PULLUP);
  pinMode(13, OUTPUT);
}

void loop()
{
  while (LOW == digitalRead(2))    //wait for pin 2 to go high
  {
    delay(500);
  }
  Serial.println("going to sleep now");
  sleepNow();          //sleep until pin 2 goes low
}

void sleepNow(void)
{
    // Set pin 2 as interrupt and attach handler:
    attachInterrupt(0, pinInterrupt, LOW);
    delay(100);
    //
    // Choose our preferred sleep mode:
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
    //
    // Set sleep enable (SE) bit:
    sleep_enable();
    //
    // Put the device to sleep:
    digitalWrite(13,LOW);   // turn LED off to indicate sleep
    sleep_mode();
    //
    // Upon waking up, sketch continues from this point.
    sleep_disable();
    digitalWrite(13,HIGH);   // turn LED on to indicate awake
}
//
void pinInterrupt(void)
{
    detachInterrupt(0);
}

User avatar
yigiter007
 
Posts: 175
Joined: Thu Oct 03, 2013 10:37 am

Re: turning off / sleep mode Adafruit feather Proto

Post by yigiter007 »

Does disabling the regulator mean it stops lowering the voltage and lets whatever voltage is applied to Vin into the rest of the circuit, Or does it stop any voltage from going into the circuit?

User avatar
wildparadox
 
Posts: 1
Joined: Sat Apr 16, 2016 7:18 pm

Re: turning off / sleep mode Adafruit feather Proto

Post by wildparadox »

I too am looking for a solution to this. It's great to have the battery charger on-board and to be able to read it's power level, but it doesn't really do any good if you can't turn the system off.

In the learning section for the BTLE Feather it states the following:
Lipoly batteries are 'maxed out' at 4.2V and stick around 3.7V for much of the battery life, then slowly sink down to 3.2V or so before the protection circuitry cuts it off.
It's really reassuring that it won't run until it kills the battery, but it would be nice to not have to recharge it before every time I want to use it.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: turning off / sleep mode Adafruit feather Proto

Post by adafruit_support_mike »

Pulling the regulator's EN pin low shuts off power to the microcontroller completely.

The microcontroller can't hold EN low after you cut power to it, and can't re-enable EN once it's been pulled low. If you want to control power use that way, you'll need an external circuit.

All the microcontrollers have sleep modes, of varying complexity depending on the chip you're working with. The best place for information about those is the datasheet for the microcontroller.

User avatar
yigiter007
 
Posts: 175
Joined: Thu Oct 03, 2013 10:37 am

Re: turning off / sleep mode Adafruit feather Proto

Post by yigiter007 »

Thank you for the replay.

So i would need to make a switch that connects the ground of the battery to the enable pin. Which will keep the pin low after the board shuts down, and if you switch it back so that the EN pin is floating it will re-enable the regulator re-booting/re-powering the board correct? I just want to be sure so, as i already put it into a project and don't want to fry the board.

I check the datasheet and the 32u4 has many different options for sleep mode, all are down by changing a specific register. In the code I posted what is <avr/sleep.h> , will that work for any Arduino? Or is there a way to set a specific register in the Arduino C++ IDE?

User avatar
yigiter007
 
Posts: 175
Joined: Thu Oct 03, 2013 10:37 am

Re: turning off / sleep mode Adafruit feather Proto

Post by yigiter007 »

My main reason for my concern is, I have seen on other micro controllers where it is setup that you can disable the on-board regulator but it will allow what ever voltage you put on Vin to go into the circuit. This was done so that you could apply a lipo 4.2V voltage directly to the circuit without having the regulator drop the voltage by .7 V when it doesn't need to regulate anything voltage. Allowing the micro controller to be powered while battery was drained to a even lower voltage.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: turning off / sleep mode Adafruit feather Proto

Post by adafruit_support_mike »

yigiter007 wrote:will that work for any Arduino? Or is there a way to set a specific register in the Arduino C++ IDE?
You can set specific registers by using their names (the AVR support libraries create variable names for all the registers), but no two microcontrollers will sleep in the same way.
yigiter007 wrote:My main reason for my concern is, I have seen on other micro controllers where it is setup that you can disable the on-board regulator but it will allow what ever voltage you put on Vin to go into the circuit.
In this case, the regulator is an external component. It shuts off the whole board.

You will need to control the connections from external hardware that still has power when the microcontroller is shut down. Parasitic current paths do exist, and can cause problems.

User avatar
yigiter007
 
Posts: 175
Joined: Thu Oct 03, 2013 10:37 am

Re: turning off / sleep mode Adafruit feather Proto

Post by yigiter007 »

So i connected the ground of the battery to the enable pin and Success! It shuts off the board and still lets the battery get charged. Now I have to expert with the sleep modes. Thank you for your replies and help. :)

User avatar
yigiter007
 
Posts: 175
Joined: Thu Oct 03, 2013 10:37 am

Re: turning off / sleep mode Adafruit feather Proto

Post by yigiter007 »

Do I need a resistor in between ground and the enable pin? Does connecting ground to the enable pin affect how the battery charges or limit how much it would charge? I'm seeing some weird effects on the battery on the A9 pin. I charged it overnight after the battery went dead and this morning the battery read 3V.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: turning off / sleep mode Adafruit feather Proto

Post by adafruit_support_mike »

yigiter007 wrote:Do I need a resistor in between ground and the enable pin?
You shouldn't. It's just an input, so its equivalent resistance should be extremely high.

Do you have anything else connected to the Feather?

User avatar
yigiter007
 
Posts: 175
Joined: Thu Oct 03, 2013 10:37 am

Re: turning off / sleep mode Adafruit feather Proto

Post by yigiter007 »

I have several items connected to the feather.
adafruit 4x 7 segment backpack
adafruit sound fx board
a HC795 shift register
14 LEDs
rotary encoder

Nothing connected to the A9 pin.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: turning off / sleep mode Adafruit feather Proto

Post by adafruit_support_mike »

Are those connected to the regulated 3v output, or to the BAT pin?

User avatar
yigiter007
 
Posts: 175
Joined: Thu Oct 03, 2013 10:37 am

Re: turning off / sleep mode Adafruit feather Proto

Post by yigiter007 »

Everything that requires power is connected to the regulated 3.3V pin

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: turning off / sleep mode Adafruit feather Proto

Post by adafruit_support_mike »

Sounds like there's a parasitic connection somewhere.

Post a photo showing your hardware and connections and we'll take a look. 800x600 images usually work best.

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”