Creating CSV File

Hello,
I am trying to get my two temperature outputs to save automatically in an external .csv file while the code is running. I have the output formatted with separated commas, I just don’t know how to get them from the serial monitor to the file. Any help would be appreciated! The code is below…

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2
#define bus2 4

OneWire ourWire(ONE_WIRE_BUS);
OneWire ourWire2(bus2);

DallasTemperature sensors(&ourWire);
DallasTemperature sensors2(&ourWire2);

void setup()
{
Serial.begin(9600);
delay(1000);
sensors.begin();
}

void loop()
{
Serial.println();
sensors.requestTemperatures();
Serial.print(sensors.getTempCByIndex(0), DEC);
Serial.print(", ");

sensors2.requestTemperatures();
Serial.print(sensors2.getTempCByIndex(0), DEC);

delay(1000);
}

Thank you in advance!!!

michael_davidson: Hello, I am trying to get my two temperature outputs to save automatically in an external .csv file while the code is running. I have the output formatted with separated commas, I just don't know how to get them from the serial monitor to the file. Any help would be appreciated! The code is below...

Copy and paste works, although the serial monitor has a finite buffer, so that may not work depending on the volume of data. Another option is to use a terminal program to capture the traffic to a log file. CoolTerm, PuTTY, Tera Term and others have this capability.

PS: When posting code, use code tags. See http://forum.arduino.cc/index.php/topic,148850.msg1118324.html#post_codetags

You have an example in your IDE Arduino !!!!!!!!!!.

Search Example -> SD -> Datalogger

All is explain how to write the data in the file "à la volée" without copy on the serial monitor.

For csv file I prefer use semicolumn " ; " then comma " , " because comma is potentialy source of mistake.

68tjs: You have an example in your IDE Arduino !!!!!!!!!!.

Search Example -> SD -> Datalogger

For csv file I prefer use semicolumn " ; " then comma " , " because comma is potentialy source of mistake.

What if i am using ARDUINO UNO with no SD card option, can then i write file one the PC directly using my micro controller ? or i will have to use some serial logger like coolterm, or h-term etc ?

yiipmann: What if i am using ARDUINO UNO with no SD card option, can then i write file one the PC directly using my micro controller ? or i will have to use some serial logger like coolterm, or h-term etc ?

The latter. I use RealTerm but they are all much the same and I think they are all free. You really only need an SD card if you have no connection to a PC, or can't trust it. I didn't know it was possible to use the serial monitor for this. I'm not sure it is a good idea to bother. A terminal programme allows you to data/timestamp each line of data, using the PC clock.