Hi there,
Very new to Arduino and the forum. I am having trouble with a project I am working on. I just want a simple device that when it receives an sms with a specific command, it responds to the sender with the current GPS longitude and latitude values. I am using an SM5100B and an EM408 GPS module. The SM5100B is connected to D2, D3 and the EM408 is connected to D12, D13 both via NewSoftSerial. I understand that you can't use 2 software serials at once, so I am polling each every 10 seconds. The reason I am not using the Tx and Rx pins is because I would like to use those pins for debugging/learning since this project is to help me learn I want to see "inside" what's going on. Also it is expensive to send many sms' to test Here is my setup and loop:
void setup()
{
cell.begin(9600);
gps.begin(4800);
Serial.begin(9600);
Serial.println("Setup Complete");
}
char c = 0;
String line = "";
String SenderNumber = "";
String SenderMessage = "";
String Data = "";
int flag = 0;
void loop()
{
if ((millis() / 500) % 2 == 0) { //poll every 10 seconds
if (cell.available() > 0) {
c = cell.read();
while ((c != '\n') && (c != '\r')) { //look for new lines from SM5100
line = line + c;
c = cell.read();
}
if (line == "+SIND: 4") {
cell.println("AT+CNMI=3,3,0,0");
delay(20);
cell.println("AT+CMGF=1");
delay(20);
cell.println("AT+CMGD=1,4");
delay(1000);
}
if (line.substring(0,4) == "+CMT") {
SenderNumber = ("0" + line.substring(10,19));
line = "";
}
if ((line.substring(0,4) == "#LOC")) { //#LOC is sms command from sender
SenderMessage = (line);
line = "";
flag = 1;
}
line = "";
}
}
else {
if (gps.available() > 0) {
c = gps.read();
while ((c != '
The SM5100B code is working like I want it to, although there may be a better way to do it I am open for suggestions. I can receive the sms, save the senders number, and locate the command #LOC. The GPS code however is returning nothing. If I just print the line value without the substring filter I get gibberish aswell as pieces of the GPRMC. Probably have to redo all of this I just need some help. I am also able to sms from the SM5100B and grab the values needed from the GPRMC string so that shouldn't be a problem.
Thanks very much
) && (c != '*')) { //look for GPS lines
line += c;
c = gps.read();
}
if (line.substring(0,5) == "GPRMC") { //only want GPRMC line to be displayed
Serial.println(line);
}
line = "";
}
}
}
The SM5100B code is working like I want it to, although there may be a better way to do it I am open for suggestions. I can receive the sms, save the senders number, and locate the command #LOC. The GPS code however is returning nothing. If I just print the line value without the substring filter I get gibberish aswell as pieces of the GPRMC. Probably have to redo all of this I just need some help. I am also able to sms from the SM5100B and grab the values needed from the GPRMC string so that shouldn't be a problem.
Thanks very much