Hi everyone,
I am trying to send imei number of gsm device to phone via sms. How should i do it? Can anyone help me in this please?
after AT+CMGF=1(text mode), i am writing my number AT+CMGS="+91xxxxxxxxxx"\r" and then i am sending imei number with the help of AT+GSNcommand. But it is taking this as string and i am getting AT+GSN as massage coz i set it to text mode. Can anyone help in which way it should take it as command so that i can get the value of imei number as message.
</> #include <SoftwareSerial.h>
SoftwareSerial gsmSerial(10, 11);
void setup()
{
//Start serial communication
Serial.begin(9600);
gsmSerial.begin(9600);
Serial.println("AT+CNMI=2,2,0,0,0");
delay(1000);
gsmSerial.println("AT+CMGF=1");
delay(500);
gsmSerial.println("AT+CMGS=\"+XXXX\"\r"); // Replace x with mobile number
delay(1000);
gsmSerial.println("AT+GSN"); //READ IMEI
updateSerial();
gsmSerial.println("AT+CGSN"); //READ IMEI
updateSerial();
gsmSerial.write(26);
}
void loop()
{
//Nothing to do with the loop in this code
}
//Method for serial communications
void updateSerial()
{
delay(500);
while (Serial.available())
{
gsmSerial.write(Serial.read());
}
while(gsmSerial.available())
{
Serial.write(gsmSerial.read());
}
} </>