Call of overloaded write is ambigious

Hi All,

I'm new to Arduino and am trying to build a simple datalogger for temperature and write the sensor data with date and time to a log file on a SD card. I'm getting an error "

exit status 1 call of overloaded 'write(uint8_t, int)' is ambiguous" trying to compile my code.

While searching for a solution, I've found that it appears while switching from SD.h to SDfat.h, the way to pass parameters to file.write (SDFat.h) is different than from logfile.print (SD.h).

I just can't figure out what I'm doing wrong....

void logData() {
  int val;                
  double temp;            
  val=analogRead(0);      
  temp=Thermistor(val);   
  DateTime now;
  now = RTC.now();
  file.write(now.day(), DEC);
  file.write("/");
  file.write(now.month(), DEC);
  file.write("/");
  file.write(now.year(), DEC);
  file.write(",");
  file.write(now.hour(), DEC);
  file.write(":");
  file.write(now.minute(), DEC);
  file.write(":");
  file.write(now.second(), DEC);
  file.write(",");    
  file.write(temp);
  file.println();
  
}

DateTime now;

?????

backwoodsjack: DateTime now;

?????

Datetime is a public class in RTClib.h It can hold the date and time from an DS1307 realtime clock.

    file.write(now.day(), DEC);

write doesn't work like that. write is for sending raw bytes. If you want to send something in a human readable format use print instead. And you don't need the DEC as that will be the default.

file.print(now.day());

Succes!! Thank you Delta_G!

is file.write() for binary files and file.print for text files ?

peterj1978: Succes!! Thank you Delta_G!

is file.write() for binary files and file.print for text files ?

Sort of like that, write is to send raw bytes and print is for sending something as ascii characters.