I want to use my android phone to sent continuos precise GPS updates over bluetooth to mu arduino. I have gps coordinates going over bluetooth but the seem to stop and do not change . I have blocks which i can show the entire code included
Arduino code
// Imports
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_HMC5883_U.h>
#include <Servo.h>
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include "./Definitions.h"
// GPS
TinyGPSPlus gps;
#define GPS_BAUD 9600
//Bluetooth
bluetoothSerial.begin(9600);
//Blynk.begin(bluetoothSerial, auth);
}
// Testing
void testDriveNorth() {
float heading = geoHeading();
int testDist = 5;
Serial.println(heading);
while(!(heading < 5 && heading > -5)) {
drive(testDist, heading);
heading = geoHeading();
Serial.println(heading);
delay(500);
}
stop();
}
void loop()
{
// Read all serial data available, as fast as possible
while (bluetoothSerial.available()) {
String a = bluetoothSerial.readString(); // Read the incoming data from Bluetooth
Serial.println(a); // Print the received data for debugging
// Split the received data into latitude and longitude
int commaIndex = a.indexOf(',');
if (commaIndex != -1) {
String latitudeStr = a.substring(0, commaIndex);
String longitudeStr = a.substring(commaIndex+1);
// Convert the latitude and longitude strings to float values
float lat = latitudeStr.toFloat();
float lon = longitudeStr.toFloat();
// Now you have the latitude and longitude as separate variables (latitude and longitude)
}
// Reset for the next packet
started = false;
ended = false;
index = 0;
inData[index] = '\0';
GeoLoc phoneLoc;
phoneLoc.lat = Lat;
phoneLoc.lon = Long;
Serial.print(phoneLoc.lat, 7); Serial.print(", "); Serial.println(phoneLoc.lon, 7);
driveTo(phoneLoc, GPS_WAYPOINT_TIMEOUT);
}
}