Hello everybody,
I didn't find any solution to my problem, so I decided to register here and start a new topic. Here is, what it's all about:
I built up kind of a measuring station with an Arduino, RTC, Melexis IR Sensor and a sensor for temperature and humidity. They are all connected via I²C to the Arduino, while the microSD breakout board is connected via SPI. Every five minutes the average values of the past five minutes are written down in a csv file. I will hang up the station in a tree to measure leaf surface temperatures during the summer season.
To read put the data once a week, I want to connect the Arduino via the USB I/O to the notebook and read out the data with a processing sketch. But everything I found was, how to read out data immediately while measuring and not as a post process. My suggestion is, to write a code for the Arduino to read out the csv and a sketch running on the notebook which reads the serial port.
This code would read the file on the SD-Card on the Arduino:
#include <SPI.h>
#include <SD.h>
const char* fileName = "LOGGER08.CSV";
String fileName2 = "LOGGER08.CSV";
File logfile;
const int chipSelect = 10;
void setup(){
Serial.begin(9600);
Serial.println("Initializing SD card...");
pinMode(10, OUTPUT);
if (!SD.begin(10)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
logfile = SD.open(fileName);
if (logfile) {
Serial.println("Content of Logfile "+ fileName2+":\n");
while (logfile.available()) {
Serial.write(logfile.read());
}
logfile.close();
}
else {
Serial.println("error opening "+fileName2);
}
}
void loop(){
}
This is the output on the serial monitor:
I think the code for the processing sketch should look like this:
import processing.serial.*;
Serial myPort;
String val;
void setup() {
String portName = Serial.list()[1];
myPort = new Serial(this, portName, 9600);
}
void draw() {
if ( myPort.available() > 0) {
val = myPort.readStringUntil('\n');
}
println(val);
}
This is an extract of the processing console:
Why are there these "null" entries?
And how can I save it as a csv file without all these "null" entries?
I hope I was clear enough in my explanation.
Thanks a lot,
banff

