0

I'm new to this arduino world. I'm trying to communicate with my arduino nano and SIM800L. I read few things in the internet and found a basic code. I tried copying it and tried to work it out, but I'm not getting the response as expected. I'm posting the code which I tried:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(11, 10); // RX, TX 

void setup()  
{
  // Open serial communication
  Serial.begin(9600);

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);

  delay(1000);
  Serial.println("Testing SIM800L module");
  Serial.println();
  Serial.print("Sizeof(mySerial) = "); Serial.println(sizeof(mySerial));
  Serial.println();

}

void loop() // run over and over
{

  if( mySerial.available() )
  {
    char c = mySerial.read();
    Serial.print(c);
  }

  if(Serial.available())
  {
    String Arsp = Serial.readString();

    Serial.println("Serial available");
    Serial.println(Arsp);
    mySerial.println(Arsp);
    Serial.println("Serial available end");
  }

}

I tried to send AT command and the output I received was:

Testing SIM800L module

Sizeof(mySerial) = 31

Serial available
AT

Serial available end

I don't get OK, which I should receive, it's returning empty.

I don't understand what's going wrong. Can someone help me with it?

  • Have you checked the baudrate of SIM800? – Abel Tom Oct 05 '17 at 09:14
  • Yea, it's 9600. – Electronic Brat Oct 05 '17 at 09:20
  • @AbelTom: I've updated my question. Take a look. – Electronic Brat Oct 05 '17 at 09:22
  • How are you resetting the SIM800L? A link to the SIM800L module that you're using may help, since there are many available. – Steve G Oct 05 '17 at 09:31
  • @SteveG: Hi steve. All I did is, uploaded the above program to Nano. Connected my Nano to my PC using USB. Connected pin-11 of Nano to RX pin of SIM800L, pin-10 of Nano to TX pin of SIM800L. Then provided a 4V supply to SIM800L. First for few seconds, SIM800L's LED blinked continuously, later it started blinking after few seconds. I even tried connecting Nano-TX(10) to SIM800L-RX and Nano-RX(11) to Sim800L-TX, but it continuously printed garbage value. So, I interchanged as told above. What else I should do? – Electronic Brat Oct 05 '17 at 09:38
  • I'm sure you made sure the 5V of SIM800 is cnnected to 5V and not 3.3 or so, and RST to GND. – Abel Tom Oct 05 '17 at 09:43
  • **Grinds teeth** You did not find "a basic code.". You found some example code or a basic program. – JRE Oct 05 '17 at 11:48
  • 1
    @AbelTom As far as I remember sim800 doesn't work @ 5 V. It is some small range around 4V – MaNyYaCk Oct 05 '17 at 13:24

2 Answers2

1

Just include '\r\n' after command AT.

For example (test the code below):

sim800.print("AT\r\n"); 
at_cmd_return = sim800.readString();
Serial.println(at_cmd_return);
delay(4000);

Att,

-2

Use #include <string.h> at the start since you can't use any string without the initialisation. Otherwise, your code should be working.

ThreePhaseEel
  • 8,858
  • 4
  • 26
  • 41