Something Wrong in Code

Hello

i Have GSM A6 Model And i already Maked Code to send SMS and its work 100%

But Now i wana add Code That When GSM receive sms

and No example of this ... Can anyone Help Me

 #include <OneWire.h>
#include <DallasTemperature.h>
#include <SoftwareSerial.h>

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


// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 7

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);


int fan = 3;
int led = 9;
char phone_no[]="+201094483932";
float TempC;
float TempF;
char senderNumber[20];

void setup() {

 Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.println("Goodnight moon!");
  Serial.println("AT+CMGF=1");    
  delay(13000);
  Serial.print("AT+CMGS=\"");
  Serial.print(phone_no); 
  Serial.write(0x22);
  Serial.write(0x0D);  // hex equivalent of Carraige return    
  Serial.write(0x0A);  // hex equivalent of newline
  delay(13000);
  //Serial.print("Welcome ");
  Serial.print(" Welcome To Egetronic Produect ");
  Serial.print(" Produect is Ready !! ");
  delay(10000);
  Serial.println (char(26));//the ASCII code of the ctrl+z is 26

 Serial.println("SMS Messages Receiver");

  }
  /*
Serial.begin(115200);
delay(15000); 
sensors.begin();
delay(10000);
pinMode(3, OUTPUT);
pinMode(9, OUTPUT);
 // Start up the library
 delay(10000);
Serial.println("AT+CMGF=1");    
delay(3000);
Serial.print("AT+CMGS=\"");
Serial.print(phone_no); 
Serial.write(0x22);
Serial.write(0x0D);  // hex equivalent of Carraige return    
Serial.write(0x0A);  // hex equivalent of newline
delay(1000);
//Serial.print("Welcome ");
Serial.print(" Welcome To Egetronic Produect ");
Serial.print(" Produect is Ready !! ");
delay(1000);
Serial.println (char(26));//the ASCII code of the ctrl+z is 26
}*/

void loop(){
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (mySerial.available()) {
    mySerial.write(Serial.read());
  }
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println (sensors.getTempCByIndex(0));
 TempC = sensors.getTempCByIndex(0);
 TempF = sensors.toFahrenheit(TempC);
         if( TempC > 50.00 ){
digitalWrite(3, HIGH);   
delay(2000);
digitalWrite(9, HIGH);   
delay(2000);    
Serial.println("AT+CMGF=1");    
delay(2000);
Serial.print("AT+CMGS=\"");
Serial.print(phone_no); 
Serial.write(0x22);
Serial.write(0x0D);  // hex equivalent of Carraige return    
Serial.write(0x0A);  // hex equivalent of newline
delay(1000);
Serial.print("Tempreatuer iS : ");
Serial.print(TempC);
Serial.print("   C ");
/*Serial.print("Tempreatuer iS : ");
Serial.print(TempF);
Serial.print("   F ");*/
Serial.print("Fan Status is ON ");
Serial.print("LED iS ON ");
delay(1000);
Serial.println (char(26));//the ASCII code of the ctrl+z is 26
delay(10000);

 char c;
  
  // If there are any SMSs available()
  if (mySerial.available() > 0 ) {
    Serial.println("Message received from:");

    // Get remote number

 // Read message bytes and print them
    while (c = mySerial.read()) {
      mySerial.print(c);
    }

    mySerial.println("\nEND OF MESSAGE");

    // Delete message from modem memory
    mySerial.flush();
    Serial.println("MESSAGE DELETED");
  }

  delay(1000);

}
else{
   digitalWrite(3, LOW); 
   delay(1000);  
    digitalWrite(9, LOW);   
 delay(500);  

}
}

And Software serial it`s Not working i did something wrong !!
im New in programing thnx

Don't you need a mySerial.begin() somewhere in setup() to initialize the software serial port?

  Serial.println("Goodnight moon!");
  Serial.println("AT+CMGF=1");

What the hell is the GSM modem supposed to do with "Goodnight moon!"?

PaulS:

  Serial.println("Goodnight moon!");

Serial.println("AT+CMGF=1");



What the hell is the GSM modem supposed to do with "Goodnight moon!"?

This Massage to tell me the gsm is working !!

but when i useing Myserial.println not working idk !!

Can u tell me how i can use My GSM becuse everything in tutorial GSm Shield And i dont have !!

groundFungus:
Don't you need a mySerial.begin() somewhere in setup() to initialize the software serial port?

u Meen The software serial is not working becuse i not initialize !
i must Write Myserial.begin (115200) ; right ?!

can u tell me or give me library GSM A6 Not shield !

Mohamed-Atef:
u Meen The software serial is not working becuse i not initialize !
i must Write Myserial.begin (115200) ; right ?!

SoftwareSerial will not work at 115200 baud. You may be able to get it to work at 38400 but start at 9600 for reliability.

...R

Robin2:
SoftwareSerial will not work at 115200 baud. You may be able to get it to work at 38400 but start at 9600 for reliability.

...R

My GSM Work On (115200 ) Must >>> in his datasheet !! if i change it will not work so i need software serial For him So ?! how can i resolve this problem !!
thnx

Mohamed-Atef:
My GSM Work On (115200 ) Must >>> in his datasheet !! if i change it will not work so i need software serial For him So ?! how can i resolve this problem !!
thnx

Either get a Mega, Leonardo or Micro which have extra HardwareSerial ports

OR

Use HardwareSerial (pins 0 an 1) on your Uno for the GSM device and get a USB-TTL so you can communicate with your PC at 9600 baud using SoftwareSerial. You will probably need to disconnect the GSM device to upload programs

...R

You will probably need to disconnect the GSM device to upload programs

No "probably" about it.