Other Problem with ESP32 and SD card...

Status
Not open for further replies.

rbghongade

Active Member
Licensed User
Longtime User
Dear friends,
Tried to interface LOLIN32 with SD card but got compilation error:
B4X:
D:\DEVELO~1\WEMOSP~1\WEMOS_SD\B4R_SD~1\Objects\bin\sketch\rSD.cpp:11:7: note:   initializing argument 2 of 'bool B4R::B4RSD::open(B4R::B4RString*, Int)'
  bool B4RSD::open (B4RString* FileName, Int mode) {
       ^
D:\DEVELO~1\WEMOSP~1\WEMOS_SD\B4R_SD~1\Objects\bin\sketch\rSD.cpp: In member function 'bool B4R::B4RSD::OpenReadWrite(B4R::B4RString*)':
rSD.cpp:25: error: invalid conversion from 'const char*' to 'Int {aka short int}' [-fpermissive]
   return open(FileName, FILE_WRITE);
                                   ^
D:\DEVELO~1\WEMOSP~1\WEMOS_SD\B4R_SD~1\Objects\bin\sketch\rSD.cpp:11:7: note:   initializing argument 2 of 'bool B4R::B4RSD::open(B4R::B4RString*, Int)'
  bool B4RSD::open (B4RString* FileName, Int mode) {
       ^
Multiple libraries were found for "SD.h"
Used: C:\Users\RAJESH\Documents\Arduino\hardware\espressif\esp32\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
exit status 1
It seems there is some incompatibility with ESP32 SD library! (Probably needs a new/modified wrapper!)
This Arduino sketch works fine:
 

Attachments

  • SD_Test.zip
    1.4 KB · Views: 381

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try this:
B4X:
Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    Log("Initialize: ", sd.Initialize(5)) '4 is the CS pin when using the ethernet shield
    Log("OpenReadWrite: ", sd.OpenReadWrite("/log.txt"))
    sd.Stream.WriteBytes("abcde", 0, 5)
    sd.Close
    Log("Open: ", sd.OpenRead("/log.txt"))
    Log("Size: ", sd.CurrentFile.Size)
    sd.Close
    Log("Free memory: ", AvailableRAM)
End Sub
 
Upvote 0

whcir

Member
Licensed User
Longtime User
Try this:
B4X:
Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    Log("Initialize: ", sd.Initialize(5)) '4 is the CS pin when using the ethernet shield
    Log("OpenReadWrite: ", sd.OpenReadWrite("/log.txt"))
    sd.Stream.WriteBytes("abcde", 0, 5)
    sd.Close
    Log("Open: ", sd.OpenRead("/log.txt"))
    Log("Size: ", sd.CurrentFile.Size)
    sd.Close
    Log("Free memory: ", AvailableRAM)
End Sub

Yes Erel, adding the "/" before the file name worked

Thank you
 
Upvote 0
Status
Not open for further replies.
Top