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.
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");
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...
okay i think i will try it with a RTC. a good idea!
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?