Temperature SMS alarm SIM 900 (FONA library) + SD card storage Problem


I'm working on a project where I use two LM35 sensors to register the temperature of two different objects. Then the difference between the two objects is analyzed by subtraction. If the difference is smaller or greater by 2C the SIM 900 module send a Warning message to my phone.

I'm having trouble storing the DATA on an SD card to later export it to Excel and run statistical analysis.

I can do it separately: I store the information or I get the warning message. But I'm failing in spotting my error in the code.

Maybe you guys can help me to make it work.

I will attach you the sketch, I hope somebody could help.

Have a nice day.

TemperatureSMSalarmSIM900_FONA_librarySDcardstorage.ino (4.26 KB)

There's a much greater chance that someone will take an interest and look at your code if you post it in-line using code tags as described in Item #6 here:

Which Arduino are you running this on? A 328-based Arduino, like the UNO, has 2048 bytes of SRAM. The SD class needs 1/4 of that for each open file. You have a char array that uses 1/8th of that. The hardware and software serial instances need SRAM for the incoming and outgoing serial data.

char buf1(20);

That's a strange way to set buf1 to 20. At least, it's not the normal way.

int pinCS = 10; // el pin del SD card

Do you have plans to move the SD card to pin 12654 some day? Using 2 bytes to hold a 1 byte value is a waste of memory.


{What} {are} {those} {curly} {braces} {for}?

    Serial.println("SD card is ready tu use"); // en caso de encontrar el modulo y la SD card imprime esta frase

That text does NOT need to be copied to SRAM, but it will be.

  Serial.println ("SD card initialization failed"); // si falla da este string
  // break;// si falla finaliza el programa

More useless curly braces and more waste of SRAM.

// display 1 
// display 2
// display 3

What are these about? You have ONE instance of the U8GLIB_SH1106_128X64 class.

  int sendto ("3338152872");

Does that value LOOK like an int value? Doesn't to me.

  int message = "";
  message = " Warning the diferential temperature is not nominal, Check the flap!!!!";

That doesn't either.