Hello guys, I am using Gsm and fingerprint on my device. So I have been using Serial1 and Serial 2 and I need to add gps device therefore I need one more Serial. How can I use Gps device?
Project Subject: I want to do send gps data to the server from gsm every 5 seconds while the fingerprint is waiting. If finger comes I check on the server for match then continue to send gps data.
Thanks for answers..
while (p != FPM_OK) {
p = finger.getImage(); //finger check
Serial.println(count);
if (count == 500) {
gps.encode(SerialGPS.read());
gpssocket.beginMessage(TYPE_TEXT);
char sz[32];
sprintf(sz, "%02d/%02d/%02d ", gps.date.month(), gps.date.day(), gps.date.year());
char tz[32];
sprintf(tz, "%02d:%02d:%02d ", gps.time.hour(), gps.time.minute(), gps.time.second());
String date=String(sz)+String(tz);
if (gps.location.isUpdated())
{//Gsm Socket
gpssocket.print("[{gps:true,loc_lati:" + String(gps.location.lat(), 6) + ",loc_long:" + String(gps.location.lng(), 6) + ",lastLocationDate:\""+date+"\"}]");
Serial.println("[{gps:true,loc_lati:" + String(gps.location.lat(), 6) + ",loc_long:" + String(gps.location.lng(), 6) + ",lastLocationDate:\""+date+"\"}]");
}
int messageSize = gpssocket.parseMessage();
if (messageSize > 0) {
Serial.println("Received a message:");
Serial.println(gpssocket.readString());
}
count = 0;
gpssocket.endMessage();
}
count++;
}
Answer:
You can use SoftwareSerial like Arduino ;
#include <SoftwareSerial.h>
TinyGPSPlus gps;
SoftwareSerial ss(19,21);
ss.begin(9600);