Hi all,
just a basic question today, please. I've tried a few different variations, but the items keep going down to the next line.
I have in the setup;
// Write coloum headers to file
File dataFile = SD.open("DHTDATA.csv", FILE_WRITE);
if (dataFile) {
dataFile.print("Temp1, Temp2, Temp3, Temp4, Temp5, Temp6, Temp7, Humid1, Humid2, Humid3, Humid4, Humid5, Humid6, Humid7, Date, Time");
dataFile.println();
}
dataFile.close();
Which helps me layout the titles. But ideally, I want the date and the time first. I just can't figure out how to get them to layout.
The code for the data entry (which isn't determined by the title blocks) is;
//// COLLECTIVE SENSOR DATA COLLECTION FOR EXCEL OUTPUT
Serial.println("PRINT SD CARD VALUES & SAVE TO CSV");
hmids[0] = dht0.readHumidity();
temps[0]= dht0.readTemperature();
hmids[1] = dht1.readHumidity();
temps[1]= dht1.readTemperature();
hmids[2] = dht2.readHumidity();
temps[2]= dht2.readTemperature();
hmids[3] = dht3.readHumidity();
temps[3]= dht3.readTemperature();
//hmids[4] = dht4.readHumidity();
//temps[4]= dht4.readTemperature();
//hmids[5] = dht5.readHumidity();
//temps[5]= dht5.readTemperature();
//hmids[6] = dht6.readHumidity();
//temps[6]= dht6.readTemperature();
//Serial print values
Serial.print("Temps ");
for (int i=0;i<7;i++)
{
Serial.print(temps[i]);
Serial.print(", ");
}
Serial.println();
Serial.print("humids ");
for (int i=0;i<7;i++)
{
Serial.print(hmids[i]);
Serial.print(", ");
}
Serial.println();
//Write data to SD card
File dataFile = SD.open("DHTDATA.csv", FILE_WRITE);
if (dataFile) {
for(int i=0;i<7;i++)
{
dataFile.print(temps[i]);
dataFile.print(", ");
}
for(int i=0;i<7;i++)
{
dataFile.print(hmids[i]);
dataFile.print(", ");
}
//Enter date and time
{
dataFile.print(now.year(), DEC);
dataFile.print('/');
dataFile.print(now.month(), DEC);
dataFile.print('/');
dataFile.print(now.day(), DEC);
dataFile.print(",");
dataFile.print(now.hour(), DEC);
dataFile.print(':');
dataFile.print(now.minute(), DEC);
dataFile.print(':');
dataFile.print(now.second(), DEC);
dataFile.println();
}
dataFile.close();
}
Here is what the excel spreadsheet looks like - capture image.
Ideally, it would look like capture 2 image.
For that to happen I would just change my setup to;
// Write coloum headers to file
File dataFile = SD.open("DHTDATA.csv", FILE_WRITE);
if (dataFile) {
dataFile.print("Date, Time, Temp1, Temp2, Temp3, Temp4, Temp5, Temp6, Temp7, Humid1, Humid2, Humid3, Humid4, Humid5, Humid6, Humid7");
dataFile.println();
}
dataFile.close();
Can someone help on the main body text please. I've tried moving it around in order, but the temperature values just write to the next line leaving the date and time on their own row.

