B4R Question Wemos SD card shield interface...

rbghongade

Active Member
Licensed User
Longtime User
Dear Erel,
I want a simple writing to SD card and am not able to follow the rSD example given in the link that you pointed at. The analog data is to be acquired , digitized and stored as it arrives. Attaching the Arduino sketch , where I was able to to do it. But I wish the same functionality in B4R.
 

Attachments

  • SD_WRITE.zip
    886 bytes · Views: 327
Upvote 0

rbghongade

Active Member
Licensed User
Longtime User
Dear Erel,
The zip file has been replaced. I am in fact testing it right now , but it seems that the first value is overwritten every time. Not sure how to go to the next line. Tried adding CRLF also!
 
Upvote 0

rbghongade

Active Member
Licensed User
Longtime User
Here is my code:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private timer1 As Timer
   Private sd As SD
   Private i As Int
 
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    sd.Initialize(4) '4 is the CS pin when using the ethernet shield
    timer1.Initialize("timer1_Tick", 1000)
    timer1.Enabled = True
End Sub

Sub Timer1_Tick
    Dim a As String
    Dim bc As ByteConverter
    Dim k(1) As Byte
sd.OpenReadWrite("DATALOG.TXT")
i=Rnd(0,1023)
a=i
k=bc.stringToBytes(a)
sd.Stream.WriteBytes(k,0,k.length)
sd.Close
Log(i)
End Sub
 
Upvote 0

rbghongade

Active Member
Licensed User
Longtime User
Hooray! Problem solved!
Erel is the GURU!

minor typo ,it should be
"sd.position=..." instead of "sd.stream.position"
 
Upvote 0
Top