Waveshare SIM7600G-H AT Commands on Serial Port

Hello,

I am trying to learn more about GSM modules so I can eventually use them for my IOT projects. I have a Waveshare SIM7600G-H Module.

I managed to get the UART between Arduino UNO and the GSM module established by following the instructions on the wiki.

I did change a small part in the library SoftwareSerial mySerial(3,4);//RX=3,TX=4 as in the orginal library the pins are 2 and 3 which clash with the pwr pin, being 2.

Here's my code

#include "Waveshare_SIM7600.h"

// Pin definition
int POWERKEY = 2;

char phone_number[] = "7380XXXXXX";      //********** change it to the phone number you want to call
char text_message[] = "www.waveshare.com";      //

void setup() {
  sim7600.PowerOn(POWERKEY);
  sim7600.SendingShortMessage(phone_number,text_message);
  sim7600.ReceivingShortMessage();
}


void loop() {

}

Here what I get on the serial monitor: -

I want to send AT commands from my Serial Monitor to debug, however thats on USB which would go to Serial, and GSM Module communicates via myserial, is there a way to echo data to and fro?

Added the following code in the loop:-

void loop() {
    while(Serial.available()){
      sim7600.sendATcommand(Serial.read(), “OK”, 1000);
    }
}

this should work, but it doesn't I don't know what I am missing

Serial.read() returns a single character... so you are currently sending multiple single character commands to the SIM7600... that won't work.

Try...

      sim7600.sendATcommand(Serial.readString(), “OK”, 1000);
1 Like

You are right, i figured that and tried to send string that threw an error

Cause in the header the function declaration is

uint8_t sendATcommand(const char* ATcommand, const char* expected_answer, unsigned int timeout);

Here's the error:

Compilation error: no matching function for call to ‘Sim7x00::sendATcommand(String, const char [3], int)’

Try converting to a C string...
sim7600.sendATcommand(Serial.readString().c_str(), “OK”, 1000);

Compiles now :slight_smile:

However, Can't use Serial.avaliable() in the loop() cause the SIM7600 responses are on the Serial Bus as well.

OKAT+CMGR=1

+CMGR:AT

OKAT+CREG?

+CREG: 0,1Setting SMS mode...
AT+CMGF=1

OKSending Short Message
AT+CMGS="7380xxxxxx"

>
+CMS ERROR: Unknown error
error 
Setting SMS mode...
AT+CMGF=1

OKAT+CPMS="QM","SM","SM!


+ChS*'�b��b�b��b�b��j

OKAT+CMGR=1

+CMGR:

I use the following sketch for sending commands to my SIM7600 (different module). You might need to set the power on pin on yours.

#include <SoftwareSerial.h>

#define BAUD 9600

SoftwareSerial softSerial (3, 4);  // Rx, Tx as required.


void setup()
{
  Serial.begin(BAUD);
  softSerial.begin(BAUD);

  Serial.print("Ready @ ");
  Serial.print(BAUD);
  Serial.println(" baud");
}


void loop()
{
  while (Serial.available() > 0)
  {
    char c = Serial.read();

    if (c == '*')
        softSerial.write(0x1A);  
      else
        softSerial.write(c);
  }

  while (softSerial.available() > 0)
    Serial.write(softSerial.read());
}

Thanks for your help, this should work, I dont understand whats up with this module, NET LED is flashing quickly so its connected to the network, I managed to send myself an SMS if I hardcode it. Nothing works on serial tho.

I added PowerOn to your sketch

#include <SoftwareSerial.h>

#define BAUD 115200
#define POWERKEY 2
SoftwareSerial softSerial (3, 4);  // Rx, Tx as required.
void PowerOn();

void setup()
{
  Serial.begin(BAUD);
  softSerial.begin(BAUD);
  PowerOn();
  Serial.print("Ready @ ");
  Serial.print(BAUD);
  Serial.println(" baud");
}


void loop()
{
  while (Serial.available() > 0)
  {
    char c = Serial.read();

    if (c == '*')
        softSerial.write(0x1A);  
      else
        softSerial.write(c);
  }

  while (softSerial.available() > 0)
    Serial.write(softSerial.read());
}

void PowerOn() {
    pinMode(POWERKEY, OUTPUT); // power on pulse
    digitalWrite(POWERKEY, HIGH);
    delay(500);
    digitalWrite(POWERKEY, LOW);

}

I dont get any response to AT

Software serial won't work at anything more than about 38400.

Do you know what baud rate is the module currently set to?

Its set to 115200, hold on let me try and change that.

@red_car I changed the module Baud to 9600, still can't get it to respond to me on Serial

image

Only Seems to respond to sim7600.sendATcommand()

Not sure why. Try powering on before you open the serial connection.

If power on before openning the terminal I get the auto responses on power on.

image

but no response to the AT commands

Ok that's something... looks like you are at least receiving messages. I presume if you send an SMS to the SIM7600 you also receive messages?

What line ending are you using in the Serial Monitor? Try "Both NL & CR".

1 Like

Sweet! That did it, Cheers. Thanks for the help. :smiley:

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