I am trying to communicate with SIM908 module with Arduino mega 2560.
Module i am using has 232 port,so i am using 232 to TTL convertor to communicate..
My circuit connections are as follows:
Rx-Tx-0, Tx-Rx-0, GND-GND.
my code for making a call from sim908
int flag=0;
int flag2=0;
void setup()
{
Serial.begin(9600);
delay(1000);
flag=sendATcommand("AT","OK",10000);
if(flag)
{
flag2=sendATcommand("ATD07354335501;","OK",10000);
}
if (flag2)
{
delay(10000);
sendATcommand("ATH","OK",10000);
}
}
void loop() {
}
int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){
uint8_t x=0, answer=0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // Initialice the string
delay(100);
while( Serial.available() > 0) Serial.read(); // Clean the input buffer
if (ATcommand[0] != '\0')
{
Serial.println(ATcommand); // Send the AT command
}
Serial.print(Serial.read());
x = 0;
previous = millis();
// this loop waits for the answer
do{
if(Serial.available() != 0){ // if there are data in the UART input buffer, reads it and checks for the asnwer
response[x] = Serial.read();
// Serial.print(response[x]);
x++;
if (strstr(response, expected_answer) != NULL) // check if the desired answer (OK) is in the response of the module
{
answer = 1;
}
}
}while((answer == 0) && ((millis() - previous) < timeout)); // Waits for the asnwer with time out
return answer;
}
OUTPUT
AT
-1
I have sucessfully made call and send sms read gps NMEA data by sending command directly from computer using PuTTY software..
i have tried 2-3 convertors(232 to TTL)
since i am not using software serial i am uploading program by disconnecting module from arduino but still unsucessfull.
But i am not able to communicate it with it using arduino...
please help me finding what could be the possible mistake i am making... i am in the middle of a project but m stuck in this problem..
please help..
Thank you very much in advance....
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.