Hi Guys,
Iam having issue with Interfacing arduiino uno with SIM5215E board.
I dumber the demo code into arduino as suggested from the below website.
When i type AT commands from the Serial monitor am not receiving an reply from board.
Can u tell me if there any setting i need to change.
I need an basic code to send and SMS and make a call.
#include <SoftwareSerial.h>
SoftwareSerial mySerial{2,3);
int8_t SendATCommand(char *ATcommand,char *expected_answer,unsigned int timeout)
{
uint8_t x=0,answer=0;
char response[200];
unsigned long previous;
memset(response,'\0',sizeof(response));
delay(100);
while(Serial.available() > 0) Serial.read();
Serial.println(ATcommand);
x=0;
previous = millis();
do
{
if(Serial.available() != 0)
{
response[x] = Serial.read();
x++;
if(strstr(response,expected_answer) != NULL)
{
answer = 1;
}
}
}while((answer == 0)&&((millis() - previous) < timeout));
return answer;
}
int8_t answer;
char aux_str[30];
char phone_number[] = "xxxxxxxx";//Modify your want to send information.
void setup()
{
Serial.begin(115200);
Serial.println("Starting.....");
delay(3000);
SendATCommand("AT+CPIN=****","OK",2000);
delay(3000);
Serial.println("Connecting to the network...");
while(SendATCommand("AT+CREG?","+CREG: 0,1",500) ||
SendATCommand("AT+CREG?","+CREG: 0,5",500));
Serial.println("Seting SMS mode....");
SendATCommand("AT+CMGF=1","OK",1000);//set the sms mode to text
Serial.println("Sending SMS");
sprintf(aux_str,"AT+CMGS="%s"",phone_number);
answer = SendATCommand(aux_str,">",2000);//send the sms number
if(answer == 1)
{
Serial.println("welcome to elecfreaks!!!!!!");
Serial.write(0x1A);
// answer = SendATCommand("","OK",20000);
// if(answer == 1)
// {
// Serial.println("Send message success!!");
// }
// else
// {
// Serial.println("Send message false!!");
// }
}
else
{
Serial.print("error: ");
Serial.println(answer,DEC);
}
}
void loop()
{
}