Using AT command in arduino to communicate with module SIM7600G

Hi arduino forum. I have a small project that used Arduino uno communicate with module SIM7600G.

First of all, about the wiring, I connect pin TX (pin 1 in Arduino Uno) to RXD in the module, pin RX (pin 0 in Arduino) to TXD in the module, pin GND in Arduino connect to pin GND in the module. Finally, I connect another source to my module. This means that I used two sources for two devices (Arduino uno and module), and they connect the GND pin together.
The purpose of my code is to use At the command to send data from Arduino to my server. When I test AT command in this code (I used AT command in another program), it run perfectly. However, when I used Arduino, it returned nothing. The code has no error and my server has no connection from my module.

Please review my code and feel free to provide me with any insights or suggestions that may help me solve this problem. Thank you!

#include <SoftwareSerial.h>
SoftwareSerial mySerial(1,0); //TX-RX
void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
  delay(5000);;
  mySerial.println("AT+CMQTTSTART");
  delay(100);
  mySerial.println("AT+CMQTTACCQ=0,\"Esp2\"");
  delay(100);
  mySerial.println("AT+CMQTTCONNECT=0,\"tcp://projectiottest1.cloud.shiftr.io:1883\",90,1,\"projectiottest1\",\"XXXXX\"");
}
void loop()
{ int numberValue=0
  mySerial.println("AT+CMQTTTOPIC=0,5");
  delay(200);
  mySerial.println("Thanh");
  mySerial.println("AT+CMQTTPAYLOAD=0,1");
  mySerial.println(numberValue);
  mySerial.println("AT+CMQTTPUB=0,1,60");
  Serial.println(numberValue);
}

very bad idea to use same pins for two serial devices

I don't quite understand much, can you explain more clearly please

change pins

1 Like

Do software serial on different pins e.g. 2 & 3.

Pins 0 & 1 are used for Serial on the Arduino Uno board.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.