A6 GSM wemos d1 or arduino mega

Hi

I want to send a message to the arduino by serial or by udp. This message contains a telephone and a text.

After receiving it, the arduino sends an SMS through an A6 gsm card and also that the arduino makes a call to the telephone of the message.

this example works well for the call and the sending of sms

char phone_no[]="8293353345";
char caracter;
String comando;


void setup() {
Serial.begin(9600);

delay(300); 
Serial.println("AT+CMGF=1");    
delay(2000);
Serial.print("AT+CMGS=\"");
Serial.print(phone_no); 
Serial.write(0x22);
Serial.write(0x0D);  // hex equivalent of Carraige return    
Serial.write(0x0A);  // hex equivalent of newline
delay(2000);
Serial.print("GSM A6 test message!");
delay(500);
Serial.println (char(26));//the ASCII code of the ctrl+z is 26

delay(10000);
Serial.println("AT");
delay(1000);
Serial.print("ATD");
Serial.println(phone_no);
//Serial.println(";");
delay(20000);
Serial.println("ATH");

}


void loop()
{

}

I want to use other pins for the connection of the A6 gsm module, but I can not get it to work. I have tried with this code:

#include <SoftwareSerial.h>

SoftwareSerial A6Module(18,19); //RX,TX
char input='\0';

void setup() {
  A6Module.begin(115200);
  Serial.begin(9600);
  delay(500);

}

void loop()
{
  if (Serial.available() > 0) {
    input = Serial.read();
  }
  if (input == 't') {
    sendMSM();
    input = '\0';
  } else if (input == 'c') {
    makeCall();
    input = '\0';
  }

}

void sendMSM() {
  A6Module.println("AT+CMGF=1");
  delay(2000);
  A6Module.print("AT+CMGS=\"8293353345");
  A6Module.print(char(34));  // "
  A6Module.print(char(13));  // CR
  A6Module.print('\r');  // hex equivalent of newline
  delay(2000);
  A6Module.print("Prueba Compu");
  delay(500);
  A6Module.println (char(26));  //ctrl_z

}

void makeCall() {
  A6Module.println("ATD+8293353345");
  delay(20000);
  A6Module.println("ATH");  //end call

}

I can use a mega arduino with an ethernet shield or a wemos d1.

Some idea of how to do what I need.

the connections of the module A6 gsm with the arduino are:

RX from A6 to TX from arduino
TX from the A6 to the RX of the arduio
GND from A6 to GND from arduino
PWR from A6 to vcc from A6

I hope you can help me

this is my A6 gsm

connection_thumb.jpg

Using software serial at 115200 is not a good idea - 38400 is the fastest you can sensibly use.

Your A6 device is connected to hardware serial so no amount of software serial on pins 18,19 will work. Also, using software serial on the hardware serial pins, even if correctly called, will not work. And what are pins 18,19 anyway? Well, on a MEGA, they are hardware serial, so the same applies.

IF it is essential that A6 runs at 115200, it is OK to have it do so with hardware serial, i.e. leave it connected to pins 0,1, on a Uno and use standard serial commands for it. All you need do is disconnect it while you upload your programme. On a Mega, you can have it on 18,19 and use serial1.

thanks for your help.

I have modified the code following your advice and it works well

//#include <SoftwareSerial.h>

//SoftwareSerial A6Module(19,18); //RX,TX
char input='\0';
const byte Led = 13;
void setup() {
  pinMode(Led, OUTPUT);
  Serial1.begin(9600);
  //A6Module.begin(9600);
  Serial.begin(9600);
  delay(500);

}

void loop()
{
  if (Serial.available() > 0) {
    input = Serial.read();
  }
  if (input == 't') {
    digitalWrite(Led, HIGH);
    sendMSM();
    
    input = '\0';
  } else if (input == 'c') {
    digitalWrite(Led, LOW);
    makeCall();
    input = '\0';
  }

}

void sendMSM() {
  Serial1.println("AT+CMGF=1");
  delay(2000);
  Serial1.print("AT+CMGS=\"8293353345");
  Serial1.print(char(34));  // "
  Serial1.print(char(13));  // CR
  Serial1.print('\r');  // hex equivalent of newline
  delay(2000);
  Serial1.print("Prueba Compu");
  delay(500);
  Serial1.println (char(26));  //ctrl_z
}

void makeCall() {
  Serial1.println("AT");
  delay(1000);
  Serial1.print("ATD");
  Serial1.println("8293353345");
  //Serial.println(";");
  delay(20000);
  Serial1.println("ATH");
}

I have put led 13 for control.

Now I just need to handle the strings that arrive with the phone number and the message to make the call and send the sms.

Thanks again