float pressure;
float temperature;
float altimeter;
unsigned long rpm =4900;
char text[4]="hej";
// för tidtagning
unsigned long a,b;
//char charRead;
char dataStr[100] = "";
char buffer[10];
void setup(){
Serial.begin(9600);
}
void loop(void){
dataStr[0] = 0; //clean out string
pressure = 1024.23; //and convert Pa to hPa
temperature = 19.34;
altimeter = -3.23; //QNH is local sea level pressure
//----------------------- using c-type ---------------------------
//convert floats to string and assemble c-type char string for writing:
a=micros();
ltoa( millis(),buffer,10); //convert long to charStr
strcat(dataStr, buffer); //add it to the end
strcat( dataStr, ", "); //append the delimiter
//dtostrf(floatVal, minimum width, precision, character array);
dtostrf(pressure, 5, 2, buffer); //5 is minimum width, 1 is precision; float value is copied onto buff
strcat( dataStr, buffer); //append the converted float
strcat( dataStr, ", "); //append the delimiter
dtostrf(temperature, 5, 1, buffer); //5 is minimum width, 1 is precision; float value is copied onto buff
strcat( dataStr, buffer); //append the converted float
strcat( dataStr, ", "); //append the delimiter
strcat(dataStr, text);
strcat(dataStr, ", ");
dtostrf(altimeter, 5, 2, buffer); //5 is minimum width, 1 is precision; float value is copied onto buff
strcat( dataStr, buffer); //append the converted float
strcat( dataStr, "\0"); //terminate correctly
b=micros()-a;
Serial.println(dataStr);
Serial.println(b);
delay(1000);
}