Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entering deep sleep on an esp32 re-enables outputs #36

Open
floretan opened this issue Apr 14, 2024 · 0 comments
Open

Entering deep sleep on an esp32 re-enables outputs #36

floretan opened this issue Apr 14, 2024 · 0 comments

Comments

@floretan
Copy link

I have a project running on an esp32 where I only need to move a motor every few minutes, and I'm using deep sleep to reduce the power consumption. However, the motor is still powered (which probably uses more power than the esp32 itself), so I tried to call stepper.disableOutputs(), but it turns out that somehow the output pins are re-enabled when the esp32 enters deep sleep.

Here is some code to reproduce the problem:

#include <AccelStepper.h>
#define IN1 5
#define IN2 18
#define IN3 19
#define IN4 21

// Create an instance of AccelStepper
AccelStepper stepper(AccelStepper::HALF4WIRE, IN1, IN3, IN2, IN4);

void setup() {

  // Initialize the serial port
  Serial.begin(115200);

  stepper.moveTo(123);
  stepper.runToPosition();

  stepper.disableOutputs();

  sleep(3); // Wait for three seconds to have time to observe the outputs.

  // Outputs are now all low

  Serial.println("Entering deep sleep");
  esp_deep_sleep(10000000);

  // Some outputs are enabled again, reflecting the last motor position before disabling outputs.
}

I'm not sure this is relevant, but this project is using a unipolar 28BYJ-48 stepper motor.

Any idea what could be causing this issue, and how it could be possible to disable outputs while the esp is in deep sleep?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant