 #include <TimeAlarms.h>
 #include <DS1307RTC.h>
 #include <dht11.h>
-
 
 #include <SPI.h>
 #include <SD.h>

       
    if(dht11_code != 0 ) {
        // error
        sprintf(buffer+9,"%7s","error");

    } else {
        sprintf(buffer+9,"%-03d,%-03d",DHT11.temperature,DHT11.humidity);
    }

    buffer[16] = '\0' ;
    
    // write to SD card
    dataFile.println(buffer);


void log_data() {

    char buffer[26] ;
    // timestamp
    int hh = hour();
    int mm = minute();
    int ss = second();
	int yyyy = year();
	int mm = month();
	int dd = day();

	// 18 char excel timestamp
    sprintf(buffer,"%02d-%02d-%02d %02d:%02d:%02d,",yyyy,mm,dd,hh,mm,ss);

    int dht11_code = DHT11.read(DHT11_PIN);
    micro_delay(200);
