Go Down

Topic: Problems with A7 Ai-Thinker  (Read 484 times) previous topic - next topic

Ezequiel1506

Hi, I am working with A7 Ai-thinker Module and Arduino UNO. I have some problems.
When I send AT through Serial Monitor, the module does not respond OK. Its response is AT.
This is mi code

Code: [Select]


#include <SoftwareSerial.h>
SoftwareSerial A7Module(2, 3); //Rx Tx

void setup()
{
  A7Module.begin(19200);
  Serial.begin(19200);
  delay(100);
}

void loop()
{
  //EnvĂ­amos y recibimos datos
  if (Serial.available() > 0) {
    char a;
    a = Serial.read();
    A7Module.print(a);
  }
  if (A7Module.available() > 0) {
    char b;
    b = A7Module.read();
    Serial.print(b);
  }
}


Someone can help me?
The conecctions are:
UTXD ------> RX Arduino
URXD------>TX Aduino.
Thanks

JohnHJ

#1
Feb 17, 2017, 05:53 pm Last Edit: Feb 17, 2017, 05:58 pm by JohnHJ
The default baudrate is set to 115200 bps, and SoftSerial does not provide a reliable UART at this baudrate.

My solution was to start the Soft Serial in 115200, change the baudrate of the module to 9600, then change my Soft Serial to 9600 baud.

And the module does not remember its setting, meaning everytime you reset the module, it goes back to 115200.

Ezequiel1506

Thank you, but I can't solve my problem, it is frustrating.
I wrote this code, for incoming calls and sms and it working very well.
But when I try to communicate with my module sending AT or another command, it doesn't work. I send AT and I hope receive OK but I receive AT.

Code: [Select]

#include <SoftwareSerial.h>


SoftwareSerial A7Module(2, 3); // RX TX
char incoming_char = 0;

void setup() {
  //digitalWrite(9, HIGH); // Uncomment to enable card power by Software
  //delay(1000);
  //digitalWrite(9, LOW);
  delay (5000);  //Turn on GPS and Sim card
  A7Module.begin(19200);
  Serial.begin(19200);

  delay (1000);
  //   A7Module.println("AT + CPIN = \"XXXX\"");  //AT command to enter the PIN of the card
  delay(25000);  //Time to find a network
  A7Module.print("AT+CLIP=1\r");
  delay(1000);
  A7Module.print("AT+CMGF=1\r"); //Set text mode to send and receive messages
  delay(1000);
  A7Module.print("AT+CNMI=2,2,0,0,0\r"); //Set module to print sms
  delay(1000);
  Serial.println("OK");
}

void loop() {

  if (Serial.available() > 0) {
    char a;
    a = Serial.read();
    A7Module.print(a);
  }
  if (A7Module.available() > 0)
  {
    incoming_char = A7Module.read();
    Serial.print(incoming_char);

  }

}

  

JohnHJ

Thank you, but I can't solve my problem, it is frustrating.
I wrote this code, for incoming calls and sms and it working very well.
But when I try to communicate with my module sending AT or another command, it doesn't work. I send AT and I hope receive OK but I receive AT.

You mean you can communicate with the module using 19200 to call and SMS? That is really weird, it is supposed to only communicate in 115200 by default.

Do you have any USB-Serial converter to directly try out the communication?

Ezequiel1506

No, I don't have.
And yes, I can communicate but when  I try to communicate sending AT through Serial Monitor, the module does not respond OK. Its response is AT.

JohnHJ

No, I don't have.
And yes, I can communicate but when  I try to communicate sending AT through Serial Monitor, the module does not respond OK. Its response is AT.

Then can you try changing the

Code: [Select]
A7Module.begin(19200);
in

Code: [Select]

void setup()
{
  A7Module.begin(19200);
  Serial.begin(19200);
  delay(100);
}

 into
 
Code: [Select]
A7Module.begin(115200);
and check the result? But SoftwareSerial in 115200 is really unstable, so anything other than AT might not work reliably

wengkai

Well, actually there are two different issue:
1. The A6/A7 uart has the ability to adapt to your first AT command. That is why you can communicate with 19200. The first time you send AT, the module will catch the baud and adjust its with that.
2. The AT you got from the module is called echo. By default it will echo every character you send. There is an AT command to cancel it: ATE=0

Go Up