0
\$\begingroup\$
  1. I'm using
  • Arduino IDE software
  • Arduino Uno board
  • GSM SIM800C
  • BSNL 4g SIM card
  1. Interfacing
  • RX (of GSM) to PIN 2 (of Arduino)
  • TX (of GSM) to PIN 3 (of Arduino)
  • GND to GND
  1. Power supply
  • For Arduino - laptop through USB cable
  • For GSM - 3.6 c.v external battery.

Code:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // 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 SIM800C 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);
  }

output:

enter image description here

\$\endgroup\$
0
\$\begingroup\$

You never send anything to the GSM module, so you never receive anything from it.

If I understand what you are trying to do, then you need to read from mySerial in your loop method and write anything you receive to Serial. You must also read from Serial and write to mySerial.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanku, it was a mistake that i didnt copy another below if loop if(Serial.available()) { char c = Serial.read(); Serial.println("Serial available"); Serial.println(c); mySerial.write(c); mySerial.print(c); Serial.println("Serial available end"); } \$\endgroup\$ – Kavya Jun 28 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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