1656Views3Replies

Author Options:

Arduino Uno R3 connected to adh8066 GSM? Answered

I'm trying to have my Arduino Uno R3 send SMS texts to my phone with latitude/longitude coordinates with use of the GTPA013 GPS unit. The GPS is working fine but I'm having trouble with the AT codes sent to the GSM module. I keep getting errors and not the "OK" I should be getting. Below is the code I am using if that helps. Thanks for any help!!

Greg.

#include <string.h>
#include <ctype.h>

int PWON = 13; // the pin to switch on the module (without press on button)
int rxPin = 0;                    // RX PIN
int txPin = 1;                    // TX TX

char data[256];
int x;

void setup()
{
  Serial.begin(115200);
  delay(2000);
  pinMode(PWON, OUTPUT);      // sets the digital pin as output
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  PowerModuleOn();
  delay(3000);
  InitializeGSM();
}

void loop()
{

}

void PowerModuleOn()
{
  digitalWrite(PWON, LOW); //Pull PWON low
  delay(2000);  //Delay 300 ms
  digitalWrite(PWON, HIGH);  // Pull PWON high, Powers up GSM Module
}

void InitializeGSM()
{
  Serial.println("AT");
  Serial.flush();
  for (x=0;x < 255; x++){
    data[x]='\0';
  }
  /*if(Serial.available() > 0)
  {
    Serial.println("Data Available");
  }
  else{
    Serial.println("No data coming from GSM Module");
  }*/
  x=0;
  do{
    while(Serial.available()==0);
    data[x]=Serial.read();
    x++;
    if(data[x-1]==0x0D&&data[x-2]=='"'){
      x=0;
    }
  }while(Serial.available()>0);
  Serial.println(data);
  delay(10000);
}

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
steveastrouk
steveastrouk

8 years ago

First thing: check your codes and interface setup are correct. Use a terminal emulator and talk to the GSM directly, to see how it replies to your interface calls.

Odds on, you've got handshaking turned on on the phone, or the baudrate isn't defaulting to the one you think it is.

Only certain configurations of AT commands yield a plain text "OK" on successful reception.

0
gregs1992
gregs1992

Answer 8 years ago

I am a noob when it comes to this stuff. I tried downloading a terminal emulator but I cannot figure out how to work it. Can you suggest something that is user friendly?

0
steveastrouk
steveastrouk

Answer 8 years ago

There's one in most standard Windows - go to Accessories|communications|hyperterminal