Unable to receive message from GSM using Arduino uno to phone

Unable to receive message from GSM using Arduino uno to phone but able to send message from phone to gsm .

shows an error like in the attached snapshot of the serial monitor.

CODE:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10,11);
void setup() {
  mySerial.begin(9600);   // Setting the baud rate of GSM Module  
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);

}

void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
      mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
     delay(1000);  // Delay of 1 second
     mySerial.println("AT+CMGS=\"+919490854138\"\r"); 
     delay(1000);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
     mySerial.println("hey!!!!!!!!");// The SMS text you want to send
     delay(100);
     mySerial.println((char)26);// ASCII code of CTRL+Z for saying the end of sms to  the module 
      delay(1000);
      break;



      
    case 'r':
      mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
      delay(1000);
      break;
  }
  if (mySerial.available()>0)
   Serial.write(mySerial.read());

}

@moh_13, your topic has been moved to a more suitable location on the forum.

Please edit your post, select all code and click the </> button. Next save your post. This will apply so-called code tags which makes it easier to read and copy and prevents possible mangling of your code by the forum software.

1 Like

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