Go Down

Topic: Error writing to SD Card (Read 180 times) previous topic - next topic

MadTinker1407

Jan 12, 2019, 04:13 am Last Edit: Jan 12, 2019, 04:14 am by MadTinker1407
Hi,

My project:
Arduino Uno WiFi Rev2 (Bottom of stack)
Grove base shield V2 (Middle of stack)
Seeed SD Card Shield (Top of stack)
Grove 6 Axis Accelerometer & Gyroscope, connected to base shield via I2C port.  


I am brand new to this and this is my first project.  I seem to be stuck again.  I can connect to the internet and read the sensor values in the serial monitor.  Now I am trying to write my accelerometer values to my sd card.  I cannot seem to get the string syntax correct to write to the card.  Any suggestions of what I am doing wrong?

Thanks!

pert

Please don't post pictures of text. That is very unhelpful.

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here USING CODE TAGS (</> button on the forum toolbar).

Juraj

the CardInfo example works?
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

MadTinker1407

@pert

Sorry about that.  Thank you again for the direction.  When I try and post the actual error it tells me I have gone over the allowed length (9000 characters).  Should I post it in a text file?

MadTinker1407

the CardInfo example works?
Yes this example works and will write a file to the card.  

Juraj

#5
Jan 12, 2019, 01:14 pm Last Edit: Jan 12, 2019, 01:20 pm by Juraj
Yes this example works and will write a file to the card. 
the CardInfo example doesn't write to SD card. it only reads. what does it output to Serial Monitor?

you must first begin() the SD card because if uninitialized it will disturb initialization of WiFi over SPI
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

pert

When I try and post the actual error it tells me I have gone over the allowed length (9000 characters).  Should I post it in a text file?
Yes, please. If you click the "Reply" button here, you will see an "Attachments and other settings" link.

MadTinker1407

I'm pretty confused on this so bear with me.  I can see the myIMU.readFloatAccelX data in my serial monitor.  I understand the Serial.print command sends the data to the serial monitor.  It's exactly the way I need it in the serial monitor.  I am just trying to write that to a file now on an SD card.  I can open and write to a file using the Datalogger example provided so I know that the SD card is working. Maybe I don't need to be using a String command to write the data to a file.  I was just trying to follow the Datalogger example.  If there is another way please let me know.   


pert

Regarding the errors when compiling your sketch, you have an extra closing brace near the start of your printData function, which causes the rest of the code intended to be inside that function to be not in any function, which is not allowed.

A very helpful troubleshooting tool is the Auto Format feature (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor). If you do an Auto Format and then compare the resulting indentation to your intended program structure, it will quickly point you to where there is a missing or extra brace. In your current code, you will notice all the lines at the end of the program have one less level of indentation than you would expect for code inside a function.

Another useful feature of the Arduino IDE/Arduino Web Editor is that when you place the cursor next to one bracket, it puts a box around the matching bracket. In the Arduino IDE, if the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.

MadTinker1407

the CardInfo example doesn't write to SD card. it only reads.
Yes you are correct.  I used the Datalogger example instead of CardInfo.  I should have read your post more carefully.  

MadTinker1407

Regarding the errors when compiling your sketch, you have an extra closing brace near the start of your printData function, which causes the rest of the code intended to be inside that function to be not in any function, which is not allowed.
Thank you, those were very helpful tips I was not aware of.  I will save your text so I don't forget those.  I found the offending bracket. 

Juraj

#11
Jan 12, 2019, 05:24 pm Last Edit: Jan 12, 2019, 05:25 pm by Juraj
off topic question. what for is the Base shield if SD card shield has I2C Grove connector?
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

MadTinker1407

off topic question. what for is the Base shield if SD card shield has I2C Grove connector?
I bought it before I bought the SD card shield.  I just left it on there and stacked.  The final goal is to print to a cloud server through WiFi.  The SD card was a last minute attempt to collect some data. 

Go Up