Gsm/gps sim module at commands always respond -1

Hello everyone,

I am on a project with Arduino Mega and other stuff. I read some values with sensor and send sms the data. I tried several sim modules like sim808, sim800l, sim900, siemens mc35i and all of them are sent sms correctly! But I want to check if my sim module is ready for send a sms, and then send data. And i know which AT command is usefull for me or not. But i never get any response from sim module to serial monitor.

For example if i send AT commands from arduino, i want to see "OK" or "ERROR" ob the serial monitor. I know the DEC codes etc so i would not shock if see some numbers on the monitor BUT SERIALSIM.avaiable RETURNS ONLY -1 although i send some AT commands to module! I looked for all topics, watched all videous on youtube etc about this issue. People can get some values when they try to getting response BUT i never got. I will share with you some simple code for example and what returns on Serial monitor. What it's wrong? Please help me...

Thank you everyone...

#include <SoftwareSerial.h>

SoftwareSerial cell(17, 16); 
int i=0;

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

}

void loop(){
  
  Serial.print("Loop: ");
  Serial.println(i);            //number of this loop
  cell.println("AT\r\n");
  delay(300);
  Serial.println(cell.read());
  delay(300);

  Serial.println("End loop.");
  i++;
  delay(3000);  
}

Serial.read() return -1 if not data is available to read

try a simple test where you enter text on the keyboard and see if there is a response

// SIM900 GSM modem test - working 13 March 2022

// connect SIM900 TXD to Mega pin 19  RXD to pin 18

// AT+CGMI  returns the manufacturer's name
// AT+CGMM returns the MODEM model number
// AT+CGMR returns details of the software and model revision level
// AT+CGSN returns the MODEM's serial number

#define mySerial Serial1  

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {  }
  Serial.println("SIM900 test!");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);//115200);//115200);
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  while (Serial.available()) {
    char ch;
    mySerial.write(ch=toupper(Serial.read()));
  }
}

you may need to change the baudrate

1 Like

Try changing that to:
Serial.println(cell.readString());

1 Like

Thank you. It works. Now i should figure out how can i send AT command into codes, not by on serial monitor. I will try this :slight_smile:

Thank you, but it does not works :frowning:

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