Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SD Card power usage in deep sleep (or when idle) #2958

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

Closed
ducalex opened this issue Jul 3, 2019 · 6 comments
Closed

SD Card power usage in deep sleep (or when idle) #2958

ducalex opened this issue Jul 3, 2019 · 6 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@ducalex
Copy link
Contributor

ducalex commented Jul 3, 2019

Hardware:

Board: Lolin32
Core Installation version: ESP-IDF: v3.3-beta3-103-ga9d266b92, Arduino as a component: 7d78247
IDE name: VS Code
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 15200
Computer OS: Windows 8.1

Description:

When I use the SD library and then go into deep sleep the SD Card uses an absurd amount of power (10-12mA). This does not occur if I use esp_vfs_fat_sdmmc_mount instead of the SD library even if I do not uninitialize it before sleeping.

I've investigated and the IO pins are freed correctlty (although card->ssPin isn't done explicitely). So the SD Card must be left in a weird state because of a wrong or incomplete command in the driver.

I fixed my problem by adding: sdTransaction(pdrv, GO_IDLE_STATE, 0, NULL); in sdcard_uninit

But the real problem is probably elsewhere.

Sketch: (leave the backquotes for code formatting)

#include <Arduino.h>
#include <SD.h>
#include <esp_sleep.h>

void setup() {
    SD.begin();
    SD.end();
    esp_sleep_enable_timer_wakeup(10 * 1000 * 1000);
    esp_deep_sleep_start();
}

void loop() {
}

Debug Messages:

None
@stale
Copy link

stale bot commented Sep 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Sep 1, 2019
@stale
Copy link

stale bot commented Sep 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Sep 15, 2019
@NikolaiRadke
Copy link

Dear ducalex,

i encountered the same problems, the sd card draws too much current. I am looking for a solution for a long time, so i wonder if your fix works. Were did you add the line sdTransaction(pdrv, GO_IDLE_STATE, 0, NULL); in sdcard_uninit in file sd_diskio.cpp?

I couldn't apply your fix, the card is still draining my poor battery. Maybe you are reading this after a year...

Best wishes from Berlin!

@lbernstone
Copy link
Contributor

Put it at line 651 before the ff_diskio_register call. Let me know if this works and I will submit a PR.

@NikolaiRadke
Copy link

Yes!!
It works flawless! 12mA less current, now the ESP32 deep sleep isn't senseless anymore.

Thanks for your reply and best regarts from Berlin.

@tueddy
Copy link
Contributor

tueddy commented Dec 19, 2020

I wonder if this is valid/fixed for SD_MMC also? So if you call SD_MMC.end() the SD card goes to idle state and save power?
Thanks!

@0x0fe 0x0fe mentioned this issue Jun 30, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

4 participants