Shop OBEX P1 Docs P2 Docs Learn Events
BlocklyProp MicroSD read and write examples — Parallax Forums

BlocklyProp MicroSD read and write examples

I've tried all kinds of code examples; and, I can't get more than a *.txt file on the card.

I have GPS up and running, NeoPixels, joystick, and more....writing graphics to terminal, writing data to terminal, converting integers to strings, to write to display as strings....because I figure I have to do that to write data to the MicroSD...but, nothing gets me data on the card.

Here's a version of my code.


  • I'm trying to get lab materials ready for students at 3:30pm today.

    All they are doing for today's lab is data inputs from potentiometers, switches, control Neopixels, etc.

    But, I need them to write their data to MicroSD, too, by the end of the lab at 8:30pm tonight.

    Then, next week, they will have combined their data acquisition code, into a Mars Rover Mission, where they will go drive around town with their cars and the Propeller Activity Board WX's will be plugged into the car's lighter plug, with a 12vdc power cable, and the GPS will take data, temperatures will be read, light from the light poles will show up on their photo sensors, and more.

    But, it's gonna be kinda sad if I can't get them to write data to the MicroSD.

    These are gen-ed students that will be taking our Astronomy we're giving them just a taste of programming, and such. I could do this in SimpleC, myself. But, these students need to do it in BlocklyProp.

    Any help would be highly welcomed!

    - Rob
    Physics and Engineering Lab Manger, here at the Univ.
  • Hi cartwrig,

    What you have looks about right.

    Are you saying that the "filename.txt" file appears on the card, but that it's always empty ?

    Have you tried removing the "SD file set pointer = 0" command ?

  • Here's some simplified test code that writes the file with a list of items.

    I've noticed the SD Pointer "GET" block doesn't work, and have filed an issue to the developer :

    In the meantime, if you wanted to append data to an existing file, then you could add some code after the SD open block to search for the file end index.

    For example, you could add a loop with the SD Read block inside, counting up until you get to the end-of-file. (You'd need to check the terminal output probably, but I assume there will be a certain character or error value returned when you try to read beyond the end of the file). Then use the Pointer block to "SET" the file position one position back from the end-of-file.

  • I know this is complicated, however I write data to SD card in a simple way. I don't check for if the file exists, I simply overwrite the log file every time the prop is rebooted. This also includes custom block.
  • This thread has also been answered by Parallax staff this morning, by e-mail. To avoid duplication of efforts, maybe the poster will share the results here after code example was provided.

    Ken Gracey
Sign In or Register to comment.