SIM 900 write and read an AT code with SIM900.h

Hi Guys,

I’ve composed this sketch to send the command AT+CSQ but when I open my serial monitor to see the output this is what I get(Please see attached)

See below my sketch

#include "SIM900.h"
#include <SoftwareSerial.h>

int numdata;
String inSerial;
int i=0;

void setup() {
  Serial.begin(9600);
  Serial.println("Serial Data Begin at 9600 baud");
  if(gsm.begin(4800))
    {
      Serial.println("Sim 900 is online");  
    }
  else
    {
      Serial.println("ERROR: Sim 900 not responding");
    }

}

void ATcode()
{
  gsm.SimpleWriteln("AT+CSQ\r");
  
  delay(50);
  
  gsm.SimpleRead();
  
  i=0;
  while(Serial.available() > 0){
    inSerial[i] = Serial.read();
    delay(10);
    i++;
  }
}

void loop() {
  ATcode();

}

What am I doing wrong? :frowning:

  while(Serial.available() > 0){
    inSerial[i] = Serial.read();
    delay(10);
    i++;
  }

While there is serial data available to read, sit around with your thumb up your ass for a while. Why?

After setup(), your code never prints to the serial port, so the garbage is coming from some library function, obviously. Since you didn't post a link to the library, you're on your own.

:confused:

senorcallum: :confused:

Words, not symbols, will get you responses.