Hi,
I try to save the data acquired by different sensors into an ascii file (named data.log) at a microSD card (This one: http://www.libelium.com/tienda/catalog/product_info.php?cPath=21&products_id=66), by the use of Filelogger library.
I tried to use the example included with the filelogger library with a very simple example that measure the inner temperature and voltage of my arduino duemillanove without any extra component. In my real project i want to save more data from temperature, humidity, pressure sensor, etc. But in this way is more simple.
The problem is that the code does not compile. I am sure that the solution is quite simple, but i don´t know how to solve it...
Here is the code:
#include <FileLogger.h>
#define MEM_PW 8
long readTemp() {
long result;
// Read temperature sensor against 1.1V reference
ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3);
delay(20); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = (result - 125) * 1075;
return result;
}
long readVcc() {
long result;
// Read 1.1V reference against AVcc
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = 1126400L / result; // Back-calculate AVcc in mV
return result;
}
void write_data(float msg[]){
unsigned int length = (strlen(msg)+1);
buffer[length];
for(int i=0; i<length;i++)
buffer[i] = msg[i];
FileLogger::append("data.log", buffer, length);
}
void setup() {
pinMode(MEM_PW, OUTPUT);
digitalWrite(MEM_PW, HIGH);
Serial.begin(9600);
Serial.println("Arduino inner temperature and inner voltage");
}
void loop() {
Serial.print(readTemp(), DEC); // read the inner temperature of arduino
Serial.print(" x10^-4 degC ");
Serial.print(readVcc(), DEC); // read the voltage
Serial.println(" mVolts");
buffer[0]= (readTemp()); // save the data at the microSD
buffer[1]= (readTemp());
writedata(buffer);
delay(1000);
}
and this is the error showed during compilation:
In function 'void write_data(float*)':
error: cannot convert 'float*' to 'const char*' for argument '1' to 'size_t strlen(const char*)' In function 'void loop()':
I think that the problem is related to two things. First that i should establish the number of components in the array, what is the number of values that i want to save in the same line of the data.log file, one per sensor... And the other topic is that i should establish the length of each value in the array. I am not sure if this is true and neither how should i do that.
Could you help me?
Thanks!