Can two gps modules, "ultimate gps breakout board" talk to each other over bluetooth? I want to try and get the distance between the two of them using the gps coordinates, and then send over bluetooth. Can anyone point me in the right direction, maybe a link that might help? I have looked, a lot, and have not found anything yet. Thanks in advance for the help.
Can one of them be a master to control things? Probably not. So no.
Need a master device (i.e. a uC) to query both and do the math. Easier if the master's location is known - like collocated with one of the GPS, but can be at a 3rd location.
SteveRogers:
Can two gps modules, "ultimate gps breakout board" talk to each other over bluetooth?
If you mean "Can I connect two GPS modules to two Arduinos and have those Arduinos communicate with each other over Bluetooth?" then, yes.
SteveRogers:
I want to try and get the distance between the two of them using the gps coordinates, and then send over bluetooth.
I think you have that a little backward. You will have to get both sets of coordinates in one place before you can calculate a distance. You can certainly send the coordinates over Bluetooth and have the receiving Arduino calculate the distance. The coordinates can go in both directions and, after calculating a distance, the Arduinos can share the distance (and heading, if you like) so they can average the two to get a better estimate.
SteveRogers:
Can anyone point me in the right direction, maybe a link that might help? I have looked, a lot, and have not found anything yet.
I'm surprised that Google has not been of help.
Thanks for the replies. Yes, I do mean have two gps's communicate with each other their respective coordinates of bluetooth. I found the distance calculation, but I can't seem to get the serial.read to share over bluetooth. I think the gps is interfering with it some how.
SteveRogers:
I think the gps is interfering with it some how.
I don't know what the problem is, but this is not it.
SteveRogers:
Thanks for the replies. Yes, I do mean have two gps's communicate with each other their respective coordinates of bluetooth. I found the distance calculation, but I can't seem to get the serial.read to share over bluetooth. I think the gps is interfering with it some how.
Show your sketch and your wiring. Perhaps you made a mistake.
One possible problem: It is not practical to use more than one SoftwareSerial port at a time since only one can be receiving. If you are using Serial Monitor for debugging and SoftwareSerial to connect to the GPS you are left with no serial ports to use for the Bluetooth adapter. Using an Arduino Leonardo or Micro would help because they have both Serial and Serial1. Using an Arduino MEGA would give you Serial, Serial1, Serial2, and Serial3.
I got everything working separately. I am using a bluno beetle, it only has one serial. Is there a way to pause serial.read, or use softwareserial to simulate more than one serial port, like serial1, serial2, etc?
I do not know what you mean by pausing serial.read. There are several varieties of SoftwareSerial that will let you have multiple serial ports, but I do not know of any that will let you listen on more than one at a time.
That's good to know. I don't need to listen at the same time, I just need to listen to one at a time, I haven't posted any code because I don't know where to begin with this one. I thought I should ask questions first to give me an idea of where to start.
I have used NewSoftSerial from NewSoftSerial | Arduiniana
but you may want to start with the SoftwareSerial that is included with your Arduino IDE (and which may now be NewSoftSerial).
You may also consider using AltSoftSerial from AltSoftSerial Library, for an extra serial port
Each has advantages and disadvantages which are described on their web pages. There may be others as well.
So, I did get the GPS working, and the data to be sent over bluetooth. But the new problem I am having is that the master module can't seem to do anything with the data it receives. It prints to the serial monitor, but it doesn't seem to recognize it in an If statement, so it can do something. Here is the code below. float a, is sent to the slave just fine, the slave then adds that to another number on the slave MCU, then sends it back to the master. the master prints the total sum, when I use serial.read, or serial.parsefloat, it just can't do anything with the received info, i'm not sure why. Thanks for any help, i'm really stuck.
#define pin 5
float a = 3.14;
"
void setup()
{
Serial.begin(115200);
pinMode(pin, OUTPUT);
}
void loop()
{
Serial.println(a);
delay(2000);
if(Serial.available()>0)
{
int c = Serial.read();
Serial.println(c);
if(c==1){
Serial.println("yes");
digitalWrite(pin, HIGH);
}
else if(c<0){
Serial.println("no");
digitalWrite(pin, LOW);
delay(1000);
}
}
}
"
is c text, or the actual value 0x01?
it's the value, would text be better?
Not necessarily, just making sure you weren't comparing 0x01 to '1'.
The trouble is that it is not printing the "yes" or "no" on the serial monitor, it prints everything else, just not that.
Show us the slave code which is sending the 1. Use [ code ] tags please, otherwise the forum software eats some of your code and turns it into smileys. 8)
Here is the slave code:
[ code ]
float b = -2.14;
float myString;
float d;
void setup()
{
Serial.begin(115200);
}
void loop()
{
if(Serial.available()>0)
{
myString = Serial.parseFloat();
d = myString + b; // equals 1
Serial.println(d);
delay(500);
}
}
[ code ]
I type [ code ] tags with spaces because then the forum software doesn't think I'm actually typing code. Edit your post to remove the spaces inside []
First, even for simple test code, myString is a terrible name for a float. Call it userInputNumber or something that describes the purpose of this variable. If we want to know the type, we can look at the declaration. Then your one-letter variable names should also be changed to match their intended use.
Serial.println() formats the output in a way that makes it possible for a human to read it. It won't ever output just a 0x01 byte, which was what the previous code was looking for. It prints a string of bytes, ending in the carriage-return + line-feed sequence. Those bytes - in this case - will be the ascii codes for the symbols '0', '1', '2'... They do not equal 0, 1 or 2.
Actually, it should look more like this:
[ code]
...your code goes here...
[ /code]
NOTE THE SLASH
but, as MorganS wrote, without the spaces.
I hope that your web page provides the </> button to make this easier.
Master Code
void setup()
{
Serial.begin(115200);
sschild_gps.begin(9600);
pinMode(pin, OUTPUT);
}
void loop(){
if(Serial.available()){
float g = Serial.parseFloat();
float h = g+a;
Serial.print(h);
delay(100);
}
}
Slave Code
void setup()
{
Serial.begin(115200);
sschild_gps.begin(9600);
}
void loop(){
Serial.print(1.235,3);
Serial.println("");
delay(1000);
}