Send temp via sms "Sagem Hilo"

Hello all,

i want to send temperature via sms to my mobilephone two time a day.
I know how i can send a sms, here the code:

void loop(){

while (count < timesToSend){
delay(1500);
Serial.print("AT+CMGS="); // send the SMS the number
Serial.print(34,BYTE); // send the " char
Serial.print("*********"); // send the number (change ********* by the actual number)
Serial.println(34,BYTE); // send the " char
delay(1500);
Serial.print("Hola caracola..."); // the SMS body
delay(500);
Serial.print(0x1A,BYTE); // end of message command 1A (hex)

delay(5000);

count++

but if i want to send for example temperature which I have previously recorded, how looks the code therefor.

I hope you understand what i mean.
Sorry for the bad english.

allp

but if i want to send for example temperature which I have previously recorded, how looks the code therefor.

You have this code:

      Serial.print("Hola caracola...");     // the SMS body

Replace that literal string with a variable:

char *buffer = "Hey, there";
Serial.print(buffer);

to print data that is in a variable.

Now, you can create an array, instead:

char buffer[128];
sprintf(buffer, "Temp is %d degrees C", tempC);
Serial.print(buffer);

where it is assumed that tempC is an int variable containing the temperature.

The sprintf function for the Arduino does not support the %f format specifier, so formatted printing of floats is a bit more of a challenge.

However, the Serial instance derives from the Print class, whose print method is overloaded to print floats, so, if tempC is a float (or double), you could do this:

Serial.print("Temp is ");
Serial.print(tempC);
Serial.print(" degrees C");

Hey PaulS,

thanks for the code and the good explanation, you are the best! :wink:
It sounds really easy!

Serial.print("Temp is ");

Serial.print(tempC);
Serial.print(" degrees C");

but that means that i send 3 sms a time, or not?

whats about to send a sms at a certain time, e.g. at 11.00am? how can i realize this, with a loop? or is there a better way?

allp

but that means that i send 3 sms a time, or not?

Not. Look back at your original code.

      Serial.print(0x1A,BYTE);    // end of message command 1A (hex)

Nothing actually gets sent until this function is called.

whats about to send a sms at a certain time, e.g. at 11.00am?

Do you know when it is 11:00 AM? If so, then, when it is that time, or the next pass through loop when it is after that time, send the message.

If not, you need either an RTC (real time clock) or a way to get the time - a permanent USB connection to a PC or an ethernet shield. The RTC is a lot cheaper...

thx for the fast answer.

okay i think i will try it with a RTC. a good idea! :wink:

now i will also query the temp at any time, for example i send a sms with a code to the shield and get so the temp from the shield. is so what feasible? can you help me in this case?

is so what feasible?

Yes.

can you help me in this case?

No, sorry.

No Problem. :wink:
Perhaps you have any Links where i can get some info how i can do this?

allp