Skip to content

Instantly share code, notes, and snippets.

@mcgodfrey
Created March 26, 2016 02:35
Show Gist options
  • Save mcgodfrey/e82c455c8468f97db1b4 to your computer and use it in GitHub Desktop.
Save mcgodfrey/e82c455c8468f97db1b4 to your computer and use it in GitHub Desktop.
Log to SD function from homebrew temperature logger
/*
* Logs current temperature data to SD card.
* Note that the global variable "filename" must be initialised
* File format is:
* datestring,sensor0_name,temp0,sensor1_name,temp1,sensor2_name,temp2
* datestring,sensor0_name,temp0,sensor1_name,temp1,sensor2_name,temp2
*/
byte log_temps(char *date_str){
File f = SD.open(filename, FILE_WRITE);
if(f) {
f.print(date_str);
for(byte a=0; a<num_sensors; a++){
f.print(",");
f.print(probe_name_array[a]);
f.print(",");
f.print(temp_array[a]);
}
f.println("");
f.close();
}else{
state=ERR;
error_code = ERROR_LOGGING;
}
return(ERROR_NONE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment