Greetings,
I am kind of a rookie when it comes to this type of modules, but let me explain my project.
Basically I'm trying to send a google maps link to my phone number that contains the current coordinates of my system with the use of a SIM800L GSM & NEO 6M GPS modules.
But for some reason if the message I'm trying to send contains any links, I don't receive it on my phone number even though that there is no errors.
Mind you that my wirings are correct.
Here's my code:
#define BUTTON 5
int BUTTONstate = 0;
boolean button_pressed = false;
/*******************************************************************************
* SIM800L
******************************************************************************/
#define rxPin 3
#define txPin 2
#define RESET_PIN 4
#define gsmindic A4
SoftwareSerial sim800(rxPin,txPin);
//------------------------------------------------------------------------
/*******************************************************************************
* NEO 6M
******************************************************************************/
AltSoftSerial neogps;
TinyGPSPlus gps;
String latitude, longitude;
//------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
sim800.begin(9600);
neogps.begin(9600);
delay(1000);
//Don't mind the unrelated AT commands, I have other features for this project
delay(1000);
sim800.println("AT");
delay(1000);
sim800.println("AT+CMGF=1");
delay(1000);
sim800.println("AT+CLIP=1");
delay(1000);
sim800.println("AT+CNMI=1,2,0,0,0");
delay(1000);
sim800.println("AT+CMGD=1,4");
delay(1000);
sim800.println("AT+CMGDA=DEL ALL");
}
void loop() {
*******************************************************************************
* Button to send SMS
******************************************************************************/
BUTTONstate = digitalRead(BUTTON);
if(digitalRead(BUTTON) == HIGH) {
Serial.println("Getting Coordinates");
getGps();
digitalWrite(buzzer, HIGH); // Arduino will set off a buzzer when the button is pressed
button_pressed = true;
}
if(button_pressed == true) {
digitalWrite(buzzer, LOW);
Serial.println("Sending Messages");
delay(1000);
sendSMS1();
delay(1000);
sendSMS2();
delay(1000);
// sendSMS3() , sendSMS4()......
button_pressed = false;
} // END OF LOOP
/*****************************************************************************************
* getGps() Function
*****************************************************************************************/
void getGps()
{
// Can take up to 60 seconds
boolean newData = false;
for (unsigned long start = millis(); millis() - start < 2000;){
while (neogps.available()){
if (gps.encode(neogps.read())){
newData = true;
break;
}
}
}
if (newData) //If newData is true
{
latitude = String(gps.location.lat(), 6);
longitude = String(gps.location.lng(), 6);
newData = false;
}
else {
latitude = "";
longitude = "";
delay(3000);
}
}
//------------------------------------------------------------------------
// sendSMS1 function doesn't work if the message contains any link
void sendSMS1(){
String tempo = "";
tempo = readFromEEPROM(offsetPhone[0]);
if(tempo == "" || tempo == "Empty" || tempo == "Wrong Format"){
Serial.println("1st number is invalid");
} // Again dont mind this, I'm using the EEPROM of the arduino to store multiple phone numbers
else {
sim800.println("AT+CMGF=1");
delay(500);
sim800.println("AT+CMGS=\""+tempo+"\"\r");
delay(500);
String text = ("http://maps.google.com/maps?q=loc:" + latitude + "," + longitude); // Google map link + coordinates
sim800.println(text);
sim800.write(0x1A);
}
}
// sendSMS2 function works and I receive the message in my inbox
void sendSMS2(){
String tempo = "";
tempo = readFromEEPROM(offsetPhone[0]);
if(tempo == "" || tempo == "Empty" || tempo == "Wrong Format"){
Serial.println("1st number is invalid");
}
else {
sim800.println("AT+CMGF=1");
delay(500);
sim800.println("AT+CMGS=\""+tempo+"\"\r");
delay(500);
String text = ("Sim 1 SMS Test!"); // This sends successfully to my phone number
sim800.println(text);
sim800.write(0x1A);
}
}
sendSMS1 that contains a google maps link executes without any error, it even prints "OK" in the serial but I didn't receive anything in my phone's inbox. With sendSMS2, I do receive an SMS message.
I'm sorry if this is quite confusing, I'll try my best to answer any questions and any help would be greatly appreciated.