GPS SS data to HC-05 to Mobile Device

I have an HC-05 Bluetooth module and a GP-20u7 GPS unit connected to my Arduino. At the moment, the GPS is connected to the software serial, and is printing data into the serial monitor. Is it possible to send that serial data to the HC-05, which will then send that data to a mobile device?
I was told that making an app is the only way. Is that true?
P.S. I am not too familiar with Arduino

You can do all of the above.
The issue is what happens to the data when it gets to the mobile device, ie what do you do with it?

YoYoGavri: I have an HC-05 Bluetooth module and a GP-20u7 GPS unit connected to my Arduino. At the moment, the GPS is connected to the software serial, and is printing data into the serial monitor. Is it possible to send that serial data to the HC-05, which will then send that data to a mobile device? I was told that making an app is the only way. Is that true? P.S. I am not too familiar with Arduino

If you just want to see the information from the HC-05, all you need is a Bluetooth Terminal app on your smartphone.

Anything more complicated than that will require you learning how to program in Java or learn how to use MIT App Inventor to write an app.

YoYoGavri: I was told that making an app is the only way. Is that true?

Not true. You can do that if you want to, or feel a compulsive need to re-invent the wheel, but you can send the data to a standard bluetooth terminal. And, since you ask, I would suggest you do that first anyway, before you start bashing your head against the wall. You may find that that is all you need.

You might find the following background notes useful.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

The code you have working now is all you need.

mauried: You can do all of the above. The issue is what happens to the data when it gets to the mobile device, ie what do you do with it?

I would want to read the GPS serial data on my phone. I was told by someone to make 2 separate software serials, but I don't know how to make them communicate with each other.

YoYoGavri: I would want to read the GPS serial data on my phone. I was told by someone to make 2 separate software serials, but I don't know how to make them communicate with each other.

Bluetooth transmit ---> Arduino ---> GPS receive GPS transmit ---> Arduino ---> Bluetooth receive

Bluetooth RX is needs voltage divider don't know about GPS since I don't have one

.

ieee488: If you just want to see the information from the HC-05, all you need is a Bluetooth Terminal app on your smartphone.

Anything more complicated than that will require you learning how to program in Java or learn how to use MIT App Inventor to write an app.

So I did try to make an MIT app, but for some reason my bluetooth module doesn't want to connect to my factory android bluetooth client. Any ideas?

ieee488: Bluetooth transmit ---> Arduino ---> GPS receive GPS transmit ---> Arduino ---> Bluetooth receive

Bluetooth RX is needs voltage divider don't know about GPS since I don't have one

.

So the GPS I ordered comes with 3 pins (VCC, GND, TX), which isn't the traditional 4 pin. Anyway, I could work around that?

I connected the GPS to Bluetooth Rx, but I'm getting $GPGSA etc. data onto my phone. Is there a way that I could sort out that data such as Speed, MPH, etc.

I managed to do that between GPS and Serial monitor. Is it possible to do the same on phone?

Is there a way that I could sort out that data such as Speed, MPH, etc. I managed to do that between GPS and Serial monitor. Is it possible to do the same on phone?

Yes. It sounds like you already have a library and program to parse the GPS data on the Arduino and to send the pieces you want by serial to the monitor.

Follow the same model for the phone. Collect and parse the data on the Arduino. Send what you want to the phone instead of the monitor. That sounds a lot easier than writing a phone app to parse the raw GPS data. ;-)

Your problem will be with trying to use two software serial instances. One for the gps to arduino, and one for the HC 05 to arduino. If you are not going to use the Serial monitor, you could move the HC05 onto the hardware serial pins after you download the program.

In the long run, you will be far better off with an Arduino like the Mega which has multiple hardware serial connections. You can have the monitor, the gps, and the bluetooth all on hardware serial.

Thanks @cattledog. What would the code look like for hardware serial for gps, Bluetooth, and serial monitor?

Thanks @cattledog. What would the code look like for hardware serial for gps, Bluetooth, and serial monitor?

https://www.arduino.cc/reference/en/language/functions/communication/serial/

The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). To use these pins to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega’s USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device’s RX pin, the RX to your device’s TX pin, and the ground of your Mega to your device’s ground.

Serial.print();//use pins 0 and 1 for the computer/monitor
Serial.read();

Serial1.print();
Serial2.print(),
Serial3.print();

Serial1.read();
Serial2.read();
Serial3.read();
#include <SoftwareSerial.h>
#include <TinyGPS.h>



SoftwareSerial mySerial(11, 12); // RX, TX
TinyGPS gps;

void gpsdump(TinyGPS &gps);
float printFloat(double f, int digits = 2);
float mph;
float alt;
long lat, lon;
float flat, flon;
unsigned long age, date, time, chars;
byte month, day, hour, minute, second, hundredths;
int level;
int year;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);


}

void loop() // run over and over
{

  mySerial.print("Long ");
  mySerial.print(flon);
  mySerial.print("Lat ");
  mySerial.print(flat);
  mySerial.print("Speed (mph)");
  mySerial.print(mph);
  mySerial.print("Date: "); mySerial.print(static_cast<int>(month)); mySerial.print("/");
  mySerial.print(static_cast<int>(day)); mySerial.print("/"); mySerial.print(year);
  mySerial.print("Time: "); mySerial.print(static_cast<int>(hour)); mySerial.print(":");
  mySerial.print(static_cast<int>(minute)); mySerial.print(":"); mySerial.print(static_cast<int>(second));
  mySerial.print("."); mySerial.print(static_cast<int>(hundredths));
  mySerial.print("Altitude");
  mySerial.print(alt);
  mySerial.print("Level");
  mySerial.print(level);








bool newdata = false;
unsigned long start = millis();

// Every 5 seconds we print an update
while (millis() - start < 5000) {
  if (mySerial.available()) {
    char c = mySerial.read();
    // Serial.print(c);  // uncomment to see raw GPS data
    if (gps.encode(c)) {
      newdata = true;
      
    }
  }
}

if (newdata) {
  mySerial.println("Acquired Data");
  mySerial.println("-------------");
  gpsdump(gps);
  mySerial.println("-------------");
  mySerial.println();
}

}

void gpsdump(TinyGPS &gps)
{
  //long lat, lon;
  //float flat, flon;
  //unsigned long age, date, time, chars;
  //int year;
  //byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  mySerial.print("Lat/Long(10^-5 deg): "); mySerial.print(lat); mySerial.print(", "); mySerial.print(lon);
  mySerial.print(" Fix age: "); mySerial.print(age); mySerial.println("ms.");

  // On Arduino, GPS characters may be lost during lengthy Serial.print()
  // On Teensy, Serial prints to USB, which has large output buffering and
  //   runs very fast, so it's not necessary to worry about missing 4800
  //   baud GPS characters.

  gps.f_get_position(&flat, &flon, &age);
  mySerial.print("Lat/Long(float): "); printFloat(flat, 5); mySerial.print(", "); printFloat(flon, 5);
  mySerial.print(" Fix age: "); mySerial.print(age); mySerial.println("ms.");

  gps.get_datetime(&date, &time, &age);
  mySerial.print("Date(ddmmyy): "); mySerial.print(date); mySerial.print(" Time(hhmmsscc): ");
  mySerial.print(time);
  mySerial.print(" Fix age: "); mySerial.print(age); mySerial.println("ms.");

  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  mySerial.print("Date: "); mySerial.print(static_cast<int>(month)); mySerial.print("/");
  mySerial.print(static_cast<int>(day)); mySerial.print("/"); mySerial.print(year);
  mySerial.print("  Time: "); mySerial.print(static_cast<int>(hour)); mySerial.print(":");
  mySerial.print(static_cast<int>(minute)); mySerial.print(":"); mySerial.print(static_cast<int>(second));
  mySerial.print("."); mySerial.print(static_cast<int>(hundredths));
  mySerial.print("  Fix age: "); mySerial.print(age); mySerial.println("ms.");

  mySerial.print("Alt(cm): "); mySerial.print(gps.altitude()); mySerial.print(" Course(10^-2 deg): ");
  mySerial.print(gps.course()); mySerial.print(" Speed(10^-2 knots): "); mySerial.println(gps.speed());
  mySerial.print("Alt(float): "); printFloat(gps.f_altitude()); mySerial.print(" Course(float): ");
  printFloat(gps.f_course()); mySerial.println();
  mySerial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); mySerial.print(" (mph): ");
  printFloat(gps.f_speed_mph());
  mySerial.print(" (mps): "); printFloat(gps.f_speed_mps()); mySerial.print(" (kmph): ");
  printFloat(gps.f_speed_kmph()); mySerial.println();

  mph = printFloat(gps.f_speed_mph());
  alt = printFloat(gps.f_altitude());


  gps.stats(&chars, &sentences, &failed);
  mySerial.print("Stats: characters: "); mySerial.print(chars); mySerial.print(" sentences: ");
  mySerial.print(sentences); mySerial.print(" failed checksum: "); mySerial.println(failed);



}

float printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0) {
    mySerial.print('-');
    number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i = 0; i < digits; ++i)
    rounding /= 10.0;

  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  mySerial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    mySerial.print(".");

  // Extract digits from the remainder one at a time
  while (digits-- > 0) {
    remainder *= 10.0;
    int toPrint = int(remainder);
    mySerial.print(toPrint);
    remainder -= toPrint;
  }
}

So that’s my code so far. I connected GPS TX to Arduino RX, and Bluetooth RX to Arduino TX. Am I doing this right? Is my code wrong?

Using:
Arduino Mega
HC-05 Bluetooth Module
GP-20u7 GPS unit

So that's my code so far. I connected GPS TX to Arduino RX, and Bluetooth RX to Arduino TX.

SoftwareSerial mySerial(11, 12); // RX, TX

Why are you still using Software Serial? What is connected to Arduino pins 11 and 12?

I connected GPS TX to Arduino RX, and Bluetooth RX to Arduino TX.

What pins are you calling Arduino RX and Arduino TX? 0 and 1? This might work for the GPS and the Bluetooth, but I thought you wanted to use the serial monitor as well.

I'm not sure you understand the architecture. Th gps module spits out serial data on its TX pin. The Arduino needs to read that data and break the sentences down into pieces. You are using the Tiny GPS library to do this job. The Arduino can read this data from the gps module over hardware or software serial. The Arduino then sends data to the Bluetooth transmitter. It can send this data over hardware or software serial. Hardware serial is preferred in both cases.

So that's my code so far. I connected GPS TX to Arduino RX, and Bluetooth RX to Arduino TX. Am I doing this right? Is my code wrong?

What is the code doing? What do you want it to do?

I think that you should have the Arduino print to the serial monitor over usb with the standard commands Serial.begin(9600);//faster baud rate OK here Serial.print();//in the code where the Arduino is sending data to the Serial monitor

Let the Arduino read the gps data stream over Serial1. Connect the gps TX pin to the Serial1 RX pin 19. For this channel use Serial1.begin(9600);//default baud rate of GP-20u7 GPS module Serial1.read();//in the code where the Arduino is reading gps data frm the module

Let the Arduino talk to the Bluetooth Module over Serial2. Connect the Serial2 TX pin16 to the Bluetooth RX pin. For this channel use Serial2.begin(9600);//default baud rate of HC 05 Serial2.print();//in the code where the Arduino is sending data to the Bluietooth module for transmission to the phone.

cattledog: Why are you still using Software Serial? What is connected to Arduino pins 11 and 12?

Still using it because my GPS Tx connects to Arduino RX (11), and Bluetooth Rx connects to Arduino Tx (12).

cattledog: What pins are you calling Arduino RX and Arduino TX? 0 and 1? This might work for the GPS and the Bluetooth, but I thought you wanted to use the serial monitor as well.

I wanted to use the serial monitor to test the sorted output from the GPS. For example, when I plugged in GPS Tx to pin 3 (on a different code) I would get Lat: Long: Speed: etc. So basically I want that data to send to the bluetooth module instead of the serial monitor/Lcd screen.

cattledog: What is the code doing? What do you want it to do?

All in all, I want the sorted out data to send to the bluetooth module instead of the serial monitor.

cattledog: I think that you should have the Arduino print to the serial monitor over usb with the standard commands Serial.begin(9600);//faster baud rate OK here Serial.print();//in the code where the Arduino is sending data to the Serial monitor

Let the Arduino read the gps data stream over Serial1. Connect the gps TX pin to the Serial1 RX pin 19. For this channel use Serial1.begin(9600);//default baud rate of GP-20u7 GPS module Serial1.read();//in the code where the Arduino is reading gps data frm the module

Let the Arduino talk to the Bluetooth Module over Serial2. Connect the Serial2 TX pin16 to the Bluetooth RX pin. For this channel use Serial2.begin(9600);//default baud rate of HC 05 Serial2.print();//in the code where the Arduino is sending data to the Bluietooth module for transmission to the phone.

Do both serial ports communicate with each other?

Do both serial ports communicate with each other?

All the 4 serial ports on the Mega are independent.

Still using it because my GPS Tx connects to Arduino RX (11), and Bluetooth Rx connects to Arduino Tx (12).

Can this be changed?

So basically I want that data to send to the bluetooth module instead of the serial monitor/Lcd screen.

I think the posted code you last posted will do that, using Software Serial on 10 and 11 instead of Hardware Serial on any of the RX/TX hardware pin sets (0/1) (19/18) (17/16) (15/14)

 mySerial.begin(4800);

I do not think this baud rate is correct for either the gps module or the bluetooth module unless you have changed default settings. Try 9600.

You are sending alot of data over bluetooth. Does your bluetooth terminl app handle it correctly? You might try sending a reduced set of data until you have everything working.

Do you have a voltage divider on the Bluetooth RX which is seeing the Arduino TX?

cattledog: Can this be changed? Sure. What should I change it to?

cattledog: You are sending alot of data over bluetooth. Does your bluetooth terminl app handle it correctly? You might try sending a reduced set of data until you have everything working.

The app is reading all the data if I connected my GPS tx to Bluetooth Rx

cattledog: Do you have a voltage divider on the Bluetooth RX which is seeing the Arduino TX?

Don't have a voltage divider, but Arduino Tx sees Bluetooth rx

With the software serial baud rate changed to 9600, what is the last program you posted doing?

How do I send serial data from hardware serial to hardware serial1? While using the mega.

https://www.arduino.cc/en/Tutorial/MultiSerialMega

#include <SoftwareSerial.h>
#include <TinyGPS.h>

SoftwareSerial mySerial(11, 12); // RX, TX GPS
SoftwareSerial mySerial2(4,3); // RX, TX BLE
TinyGPS gps;

void gpsdump(TinyGPS &gps);
float printFloat(double f, int digits = 2);
float mph;
float alt;
long lat, lon;
float flat, flon;
unsigned long age, date, time, chars;
byte month, day, hour, minute, second, hundredths;
int level;
int year;

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
 //mySerial2.begin(9600);
  
}

void loop() // run over and over
{                 
  bool newdata = false;
  unsigned long start = millis();

  // Every 5 seconds we print an update
  while (millis() - start < 5000) {
    if (mySerial.available()) {
      char c = mySerial.read();
      // Serial.print(c);  // uncomment to see raw GPS data
      if (gps.encode(c)) {
        newdata = true;
         break;  // uncomment to print new data immediately!
      }
    }
  }
  
  if (newdata) {
    Serial.println("Acquired Data");
    Serial.println("-------------");
    gpsdump(gps);
    Serial.println("-------------");
    Serial.println();
  }
  
    gps.f_get_position(&flat, &flon);
  Serial.print("Latitude: "); Serial.print(flat); Serial.println();
  Serial.print("Longitude: ");Serial.print(flon); Serial.println();
  Serial.print("Altitude: "); Serial.print(gps.f_altitude()); Serial.println();
  Serial.print("Speed(MPH): "); Serial.print(gps.f_speed_mph()); Serial.println();
    
}

void gpsdump(TinyGPS &gps)
{
  //long lat, lon;
  //float flat, flon;
  //unsigned long age, date, time, chars;
  //int year;
  //byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;


 /* gps.f_get_position(&flat, &flon, &age);
  Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
  

  Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): ");
    printFloat(gps.f_course()); Serial.println();
  Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): ");
    printFloat(gps.f_speed_mph());
  Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): ");
    printFloat(gps.f_speed_kmph()); Serial.println();
    
    mph=printFloat(gps.f_speed_mph());
    alt=printFloat(gps.f_altitude());
    */



}

float printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0) {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0) {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint;
  }
}

This code sends the sorted out GPS data to the Serial monitor. I’ve established a second software serial. But when I changed all Serial to mySerial2, nothing outputed. Any pointers?