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 5 '17 at 9:14
  • Yea, it's 9600. – Electronic Brat Oct 5 '17 at 9:20
  • @AbelTom: I've updated my question. Take a look. – Electronic Brat Oct 5 '17 at 9: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 5 '17 at 9:31
  • 1
    @AbelTom As far as I remember sim800 doesn't work @ 5 V. It is some small range around 4V – MaNyYaCk Oct 5 '17 at 13:24

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

  • i mean use #include string.h. – alex mwita Nov 18 '17 at 15:09
  • Its been a while since I did any work with the arduino libraries, but my recollection is that string functions are included automatically without needing a header. – Jules Apr 22 at 19:37

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.