I am new in Arduino programming as you will understand from the simple code which i use.
After reading a lot, i'm still confused about the results. My project is to send SMS "W" to the GSM module, and receive an answer that will have the location in url form.
I use:
Arduino Mega 2560
GSM Module SIM900
GPS Module NEO6M
Using the Modules separately, i can send a simple message or get information about GPS in serial.
However, the problem is when i combine them. When i send SMS "G", i receive a blank message. But when the automated message is a string, i receive the string.
I think that i am close to the solution but i can't understand how to modify correclty my code as all my tries had no results.
I appreciate someone's help, as i am stuck and can't make the project more complicated with other componets (For instance addiing a fingerprint sensor, a temperature sensor, upload values on a server etc).
Maybe there are some silly mistakes, so i wait for your help on how the code will work.
You could jump forward ten years, and try the newer chipsets like 5320 and 7600 which have the navigation in the one single chip and command interface.
Depending on where you live, they’ll work for at least three years longer than your 2G solution.
lastchancename:
You could jump forward ten years, and try the newer chipsets like 5320 and 7600 which have the navigation in the one single chip and command interface.
Depending on where you live, they’ll work for at least three years longer than your 2G solution.
Thank you for the answer.
I want to complete my project with Arduino Mega and the two modules. Is there any possibility to make it work?
aarg:
I think running two instances of Software Serial simultaneously could be a problem.
So the code that i provide in my first post would never have the wanted results and is faulty? Or making some changes it might work? If yes, can you help me please?
About a month ago, I started this project with Arduino Uno... After some research in internet, I read that I should use the Arduino Mega which has 4 serial ports. Unfortunately, i can't have any results.
Thank you for your responce, you are right about the letter.
Relying on my project's goals and the code that you suggested me here, I have another problem. I receive a SMS with the google maps link but the Latitude-Longitude are 0. The link that my phone receives is "Google Maps".
The code is working well but as @aarg wrote, these two modules cannot be used simultaneously. As a result, the coordinates are zero.
Can I find any solution for that?
The new code that I tried is:
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#define GSM_Module Serial1
#define GPS_Module Serial2
TinyGPSPlus GPS;
double Latitude;
double Longitude;
char incomingChar; // Create variable to store incoming SMS characters
void setup()
{
Serial.begin(9600);
GSM_Module.begin(9600);
GPS_Module.begin(9600);
Serial.println("Initializing...");
delay(1000);
GSM_Module.print("AT+CMGF=1\r\n");
delay(100);
GSM_Module.print("AT+CNMI=2,2,0,0,0\r\n");
delay(1000);
}
void loop()
{
delay(2000);
if (SMS_Request())
{
SMS_Send();
}
delay(100);
}
void SMS_Send()
{
GPS_Info();
GSM_Module.print("\r");
delay(1000);
GSM_Module.print("AT+CMGF=1\r");
delay(1000);
GSM_Module.println("AT + CMGS = \"+XXXXXXXXXX\"\r");
delay(1000);
GSM_Module.print( "https://maps.google.com/?q=" + String(Latitude) + "," + String(Longitude)); //The text of the message to be sent
delay(1000);
GSM_Module.write(0x1A);
delay(1000);
}
boolean SMS_Request()
{
if (GSM_Module.available() > 0) //If there is stuff in the buffer
{
char textMessage[100] = {};
byte numChars = GSM_Module.readBytes(textMessage, 100);//.readBytes returns number read
textMessage[numChars] = '\0';//null Terminator
Serial.println(textMessage); // Print the new message
char * pch = strchr(textMessage, 'Q'); //pch is pointer to 'Q'
if (pch) //found 'Q', pch is not NULL
{ Serial.println("found 'Q'");
//send outgoing sms
SMS_Send();
}
else
Serial.println("No 'Q' found in message");
}
return false;
}
boolean GPS_Info()
{
while (GPS_Module.available() > 0)
{
GPS.encode(GPS_Module.read());
if (GPS.location.isUpdated())
{
// Latitude in degrees
Serial.print("Latitude= ");
Serial.print(GPS.location.lat(), 6);
Latitude = GPS.location.lat(), 6;
// Longitude in degrees
Serial.print(" Longitude= ");
Serial.println(GPS.location.lng(), 6);
Longitude = GPS.location.lng(), 6;
}
}
}