Write SD OK ever 10´, If I eject it and insert in btwen the 10´ do not write it

Hello Everyone,

I am quite knew on Arduino and programming is not my strong point, I think I am missing something and maybe some of you can help me on this. I am using a DHT11 and a SD module as I am looking forward to write (temperature & Humidity) on the SD card every 10 minutes for an offline tracking, everything seems to work perfectly, but if I remove the SD and insert it again within the writting intervals, then it stops writting. One solution could be to reset the arduino, but I would prefer another choice. The part of the code about wrtting is this one:

if(multiplo_diez==0 && decimal_min==decimal_min_prox){ //condition to jump in it every 10 min Serial.println("Imprimiendo la memoria"); //Check if the timming conditions works Hum = SD.open("Hum.txt", FILE_WRITE); if (Hum) { Hum.print("Humedad: "); Hum.print(h); Hum.print("% "); Hum.print(hora); //Also print the time the mesure was done. Hum.print(":"); Hum.print(minuto); Hum.close(); } Temp = SD.open("Temp.txt", FILE_WRITE); if (Temp) { Temp.print("Temperatura "); Temp.print(t); Temp.print("° "); Temp.print(hora); Temp.print(":"); Temp.print(minuto); Temp.close(); } decimal_min_prox++; //timming issues for mesuring if(decimal_min_prox==6){ decimal_min_prox=0; } Hum = SD.open("Hum.txt"); //Checking the SD content while (Hum.available()) { Serial.write(Hum.read()); } Hum.close();


Another courius thing about this is that I used a clock by software , and in 2 hours, it goes around 4 min backwards, I assume that I already had too much code (21,3 Kbytes: SD,DHT11 ,LCD, Fan Cooler) for the clock speed of the arduino (16Mhz) , hopefully in few days the RTC module is delivered. And just my personal opinion, next time I will try with a DHT22 since I dont find DHT11 quite stable & slow, but very cheap (in this part of the globe, we say "crocks in the pocket").

Hope this one finds everyone fine, and hope to get this done. Thanks in advance!


As far as I know: when you remove the SD card, you have to start all over with SD.begin() and so.

You can have a clock running with the 16MHz crystal accuracy. That will be not very accurate, but 4 minutes in 2 hours seems a lot. Perhaps something is wrong with the software (the sketch) or the library.

I don't use the DHT11 or DHT22 anymore, the ones I have are totally inaccurate. They say for example 30%, while it is 80% humidity. Use the Honeywell series or the Sensirion. https://www.sparkfun.com/products/11295 https://www.sparkfun.com/products/9569 https://www.sparkfun.com/products/8257