Strange behaviour of the SDCard Module #11323
Unanswered
WolleKette
asked this question in
Libraries & Drivers
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have noticed some strange behavior in my experiments with an SD card module.
I'm using a Lolin D32Pro module and want to use an external SD card module. (Although the D32Pro contains an SD card module).
Cards should be able to be inserted, mounted, unmounted and removed as normal.
In my first attempts, I used the following code.
This works fine, if the card is inside the reader at boot time or before the first access. But it works only once. If the card is removed and inserted again, then error messages occur. Depending on whether you just remount the card or recreate the SDCard object, different errors will occur. But that is not the focus here. I want to show how I did it, in case someone has the same problem.
Instead of using the SDCard class from the machine module, I used the one from the separate module sdcard.py from this repository here at github. And I used the SoftSPI class.
Now the code looks like this.
With this, I can access the card as often as I want. I can remove the card and insert another one. It just works.
I hope it helps someone who may have the same problem.
By the way, the same problem occurs with the module's internal card reader. There I used then slot=2 and cs=4.
Beta Was this translation helpful? Give feedback.
All reactions