Customer:
I have an Inkplate 6 COLOR and adapted the examples from SDCard Read/Write and RTC/GPIO deep sleep. I can separately perform read and write operations on boot and deep sleep (RTC or wake GPIO) without SD card operations. However, once deep sleep wakes, any attempts to perform SD operations (even after sdinit = true) cause a reset on the board, which then performs correctly as per a new boot. Is there a way to deep sleep, wake, and successfully use the SD card?
Originally submitted via email support on 2 May 2025. Migrated to the forum for community visibility.
Soldered Support:
Do you turn off the micro SD card power supply before going to deep sleep? There are functions sdcardwake and sdcardsleep and you should put the micro SD card to sleep. This could be a cause of this. If you want, you can send us your sketch (just the bare bones part of it, you can omit any details you like) for us to test and see what’s up.
Customer:
I use the Arduino IDE. I use display.sdCardInit() after I wake, and before I start using the SD card. I use display.sdCardSleep() after I am done with the card, and before I call the deep sleep function. Let me check once more and get a simplified code block to you.
Soldered Support:
It’s good you put the SD card to sleep and then power it on manually once the ESP wakes back up. I believe this is a software issue (the software is interfacing with the hardware in the wrong way) and possibly an issue with our library which is causing the crashing. I will get an Inkplate 6 COLOR and have a colleague test this out in-office once you send us the code snippet to investigate more.
Customer:
I have attached a simplified version of the code. I’ve also logged the outputs, and I see the failure upon trying to sdcardInit() upon wake. I have not yet tried writing, then immediately reading back before sleep. I have separately tested the example write code, then the read code (although in the example, the file name provided is wrong - test.txt vs text.txt, you may want to separately update), and that works.
Boot Up with SD Card Write
21:57:01.184
-> ***** SETUP ******
21:57:01.387
-> Wake since last reset: 0
21:57:01.387
-> Wakeup was not caused by deep sleep: 0
21:57:01.430
-> Likely aBoot Up...
21:57:01.430
-> We will try to write something to the SD Card
21:57:01.430
-> generateHeader: completed
21:57:01.430
-> SDWrite: Init SD Card!
21:57:01.551
-> SDWrite: Prepare to write SD Card!
21:57:01.591
-> SDWrite: File open OK...
21:57:01.591
-> SDWrite: Writing buffer to file...
21:57:01.764
-> SDWrite: Buffer saved to SD card!
21:57:01.764
-> SDWrite: Sleep SD Card!
21:57:01.764
-> ****** Refreshing Display *******
21:57:32.290
-> ****** Refreshing Display Completed *******
21:57:32.290
-> CODE_ON_RTCWAKETIMER: SLEEP_Enable Timer: RTC interrupt
21:57:32.290
-> SLEEP_Enable EXT0: GPIO36 - Manual Wake
21:57:32.290
-> ****** esp_deep_sleep_start *******
RTC Wake up and SD Card Read (Error upon SDCardInit)
21:58:33.525
-> ***** SETUP ******
21:58:33.714
-> Wake since last reset: 0
21:58:33.714
-> Timer Wake...
21:58:33.714
-> We will try to read something to the SD Card
21:58:33.714
-> SDRead: Init SD Card! ***** SETUP ******
21:58:36.326
-> Wake since last reset: 0
21:58:36.326
-> Wakeup was not caused by deep sleep: 0
21:58:36.326
-> Likely aBoot Up...
21:58:36.326
-> We will try to write something to the SD Card
21:58:36.359
-> generateHeader: completed
21:58:36.359
-> SDWrite: Init SD Card!
21:58:36.471
-> SDWrite: Prepare to write SD Card!
21:58:36.510
-> SDWrite: File open OK...
21:58:36.510
-> SDWrite: Writing buffer to file...
21:58:36.659
-> SDWrite: Buffer saved to SD card!
21:58:36.695
-> SDWrite: Sleep SD Card!
21:58:36.695
-> ****** Refreshing Display *******
21:59:07.188
-> ****** Refreshing Display Completed *******
21:59:07.188
-> CODE_ON_RTCWAKETIMER: SLEEP_Enable Timer: RTC interrupt
21:59:07.290
-> SLEEP_Enable EXT0: GPIO36 - Manual Wake
21:59:07.290
-> ****** esp_deep_sleep_start *******
Manual Wake up and SD Card Read (Error upon SDCardInit)
22:00:54.507
-> ***** SETUP ******
22:00:54.746
-> Wake since last reset: 0
22:00:54.746
-> Manual Wake (EXT0)...
22:00:54.746
-> We will try to read something to the SD Card
22:00:54.746
-> SDRead: Init SD Card! ***** SETUP ******
22:00:57.349
-> Wake since last reset: 0
22:00:57.349
-> Wakeup was not caused by deep sleep: 0
22:00:57.349
-> Likely aBoot Up...
22:00:57.349
-> We will try to write something to the SD Card
22:00:57.387
-> generateHeader: completed
22:00:57.387
-> SDWrite: Init SD Card!
22:00:57.527
-> SDWrite: Prepare to write SD Card!
22:00:57.527
-> SDWrite: File open OK...
22:00:57.527
-> SDWrite: Writing buffer to file...
22:00:57.717
-> SDWrite: Buffer saved to SD card!
22:00:57.717
-> SDWrite: Sleep SD Card!
22:00:57.717
-> ****** Refreshing Display *******
22:01:28.223
-> ****** Refreshing Display Completed *******
22:01:28.223
-> CODE_ON_RTCWAKETIMER: SLEEP_Enable Timer: RTC interrupt
22:01:28.223
-> SLEEP_Enable EXT0: GPIO36 - Manual Wake
22:01:28.223
-> ****** esp_deep_sleep_start *******
Attachment omitted in migration: Inkplate6COLOR_DeepSleepSDCardTest.txt
Soldered Support:
We came to the conclusion that the reboot may be connected to the return type of the function listed here: Inkplate-Arduino-library/src/include/System.cpp at 2dd263f2f9548aadac8638413a143beddf068a64 · SolderedElectronics/Inkplate-Arduino-library · GitHub
The sd.begin() function is of the type inline bool, and when we wake up from deep sleep, the data it returns may be invalid and thus it’s causing a software crash. As a hotfix it is recommended you simply don’t check the return value of the sdCardInit() function, just call it before reading/writing to a file.
While we weren’t able to test the writing of a .bin file to the SD card, we were able to read and write to a .txt file after deep sleep. We usually store text in txt, table data in csv, and images in jpg/png. We recommend these formats and there are examples for them in the Inkplate library.
We will write back when we have a more permanent fix with the Inkplate library.
Customer:
I did a quick test without checking the return value of sdCardInit(), but the board still seems to reset at file.open(). I will find more time to test with a simpler use case, and try to troubleshoot and share my findings.
Soldered Support:
The main thing I would recommend is to actually use a different kind of file type. The file formats I suggested work well - we got it to work with images and text files. I’m sure you can use the built-in image decoder for images with SD card. Let me know if you can get satisfactory results.