I would like to be able to send a command via serial to initiate an action for the software serial.
i.e.
I send "SENDPOSIT" via serial, the board recognizes the specific String, then encodes and sends it's GPS lat/long/elevation information to my software serial port to be transmitted via the attached LoRa module.
I have been successful at getting it to send a location, but I've consistently run into two issues.
It reacts to ANY incoming String, regardless of the content, not just the intended "SENDPOSIT"
It is only sending lat/long to the second one-hundredths (DD.DD), which is not accurate enough.
So, let me rephrase #1, and you tell me if it's correct:
It reacts to ANY incoming String, regardless of the content. How can I add code so that it only responds to "SENDPOSIT"?
Question: Does the display library support 6 decimal digit printing of a float? Check the library documentation. Is it at the screen edge? Maybe you wrote off the end.
I guess I don't understand why I can adjust how many decimal places print to my display, but not in the other portion of the sketch.
The String class does that by default when it converts a float to a string. The print class does not. Edit - well it does actually. But the String class has a different mechanism for specifying digits.
Here's an example of what I was using that was giving the proper result, but reacting to ANY incoming String:
while(Serial.available()){
if(Serial.readString() == "SENDPOSIT"){
gps.encode(gpss.read());
latSend = gps.location.lat();
lngSend = gps.location.lng();
eleSend = gps.altitude.feet();
locSend = callSign+latSend+lngSend+eleSend;
locSize = locSend.length();
Serial.println("Sending your position...");
display.clearDisplay();
display.setCursor(0,16);
display.println("Sending your position...");
display.display();
loras.println("AT+SEND=0,"+locSize+","+locSend);
delay(500);
}
}