Go Down

Topic: Can Arduino write to a text file? (Read 28 times) previous topic - next topic


Is there an easy way to save variables to a text file?  I am hoping to write sensor data to a text file that will eventually be used in a web app.




There is no file system available to the (native) Arduino environment, so in a nutshell the answer is "no".  If you need permanent data storage, you will have to use the on-board EEPROM (512 bytes) or add one of the many external storage options (see http://www.arduino.cc/playground/Main/InterfacingWithHardware#Storage).  Alternatively, concoct a system to transmit data to a PC with a file system (http://www.arduino.cc/playground/Main/InterfacingWithHardware#Communication).



Do you want the file to be on the computer or on the arduino ? If it's on the computer, you could use any programming language that can write files (processing, C++, java, python, ....) to establish a serial connection with the arduino, read the values from serial and write it to the text file.
If you want the file to be on the arduino (GPS datalogging, for exemple), you might consider writing to an SDcard. Not sure if you can output a .txt file directly readable by your computer, though.


Thank you both. I am planning on saving the information in a text file on my Mac. I'll look into using Processing to pull the data from the Arduino. Any pointers or suggestions would be greatly appreciated. If my Arduino code has a snip that looks like:

char message[6] = "hello";

will I be able to have Processing access that using something like:


and see it output "hello"?

Thanks again.


You would need Processing (or whatever language you choose) to establish a serial connection to Arduino.

Then either send a message to Arduino to command it to send back the required data, or you could have Arduino just send data when apropriate and in the Processing app. continously check the serial port for incoming data.

Check the Processing forum there's probably tons of info on doing what you need.

Go Up