Hi I have a problem I bought the arduino mega 2560 with SIM800C shield because here was no more stock on arduino SMS shield and I taught that it use similar code using arduino SEND SMS sample. Bellow is a sample that I found online
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8);
int sender = 1;
char phone1[] = "+639*********";
char phone2[] = "+639*********";
void setup()
{
mySerial.begin(19200); //Default serial port setting for the GPRS modem is 19200bps 8-N-1
/*mySerial.print("\r");
delay(1000); //Wait for a second while the modem sends an "OK"
mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(1000);
//mySerial.print("AT+CSCA=\"+63**********"\r"); //Setting for the SMS Message center number,
//delay(1000); //uncomment only if required and replace with
//the message center number obtained from
//your GSM service provider.
//Note that when specifying a tring of characters
// " is entered as \"
mySerial.print("AT+CMGS=\"+639105680132\"\r"); //Start accepting the text for the message
//to be sent to the number specified.
//Replace this number with the target mobile number.
delay(1000);
mySerial.print("hello!!!\n"); //The text for the message
mySerial.print("inches"); //The text for the message
delay(1000);
mySerial.write(0x1A); //Equivalent to sending Ctrl+Z
*/
}
void loop()
{ if(sender == 1){
SendMessage(phone1);
delay(2000);
SendMessage(phone2);
}
sender = 2;
//We just want to send the SMS only once, so there is nothing in this loop.
//If we put the code for SMS here, it will be sent again and again and cost us a lot.
}
void SendMessage(char cell[]){
mySerial.print("\r");
delay(1000); //Wait for a second while the modem sends an "OK"
mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(1000);
//mySerial.print("AT+CSCA=\"+919032055002\"\r"); //Setting for the SMS Message center number,
//delay(1000); //uncomment only if required and replace with
//the message center number obtained from
//your GSM service provider.
//Note that when specifying a tring of characters
// " is entered as \"
mySerial.print("AT+CMGS=\"");
mySerial.print(cell);
mySerial.print("\"");
mySerial.print("\r"); //Start accepting the text for the message
//to be sent to the number specified.
//Replace this number with the target mobile number.
delay(1000);
mySerial.print("This is a Test\n"); //The text for the message
mySerial.print("inches"); //The text for the message
delay(1000);
mySerial.write(0x1A); //Equivalent to sending Ctrl+Z
}
and I need to make it like the basic send SMS code. because I am a total newbie on programming arduino
The SEND SMS sample
/*
SMS sender
This sketch, for the Arduino GSM shield,sends an SMS message
you enter in the serial monitor. Connect your Arduino with the
GSM shield and SIM card, open the serial monitor, and wait for
the "READY" message to appear in the monitor. Next, type a
message to send and press "return". Make sure the serial
monitor is set to send a newline when you press return.
Circuit:
* GSM shield
* SIM card that can send SMS
created 25 Feb 2012
by Tom Igoe
This example is in the public domain.
http://arduino.cc/en/Tutorial/GSMExamplesSendSMS
*/
// Include the GSM library
#include <GSM.h>
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;
void setup()
{
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("SMS Messages Sender");
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
}
void loop()
{
Serial.print("Enter a mobile number: ");
char remoteNum[20]; // telephone number to send sms
readSerial(remoteNum);
Serial.println(remoteNum);
// sms text
Serial.print("Now, enter SMS content: ");
char txtMsg[200];
readSerial(txtMsg);
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(txtMsg);
// send the message
sms.beginSMS(remoteNum);
sms.print(txtMsg);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
}
/*
Read input serial
*/
int readSerial(char result[])
{
int i = 0;
while(1)
{
while (Serial.available() > 0)
{
char inChar = Serial.read();
if (inChar == '\n')
{
result[i] = '\0';
Serial.flush();
return 0;
}
if(inChar!='\r')
{
result[i] = inChar;
i++;
}
}
}
}