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