I got lately a project and I got struggle to understand something, I didn't tried yet code because
I don't have any ideas how it could work. So what's that? I got a GPS and as a GPS you got Latitude
and Longitude what I wanna do is to make the Compas saw me in which direction is the exact coordinate location that i picked.
I got Lat, Long and Compas in Angle degree which i made a simple code to get some readings in actual
letters sawing north,south,east,west.
Serial.print("Heading (degrees): "); Serial.println(headingDegrees);
int deg = headingDegrees;
if ((deg > 345 && deg < 360) || (deg > 0 && deg < 15))
{
Serial.print("Heading Compas:");Serial.println(" North ");
}
else {delay(1);}
if (deg > 25 && deg < 55)
{
Serial.print("Heading Compas:");Serial.println(" North East ");
}
else {delay(1);}
if (deg >80 && deg < 100)
{
Serial.print("Heading Compas:");Serial.println(" East ");
}
else if (deg >120 && deg < 140)
{
Serial.print("Heading Compas:");Serial.println(" South East ");
}
else {delay(1);}
if (deg >165 && deg < 195)
{
Serial.print("Heading Compas:");Serial.println(" South ");
}
else if (deg >210 && deg < 235)
{
Serial.print("Heading Compas:");Serial.println(" South West ");
}
else {delay(1);}
if (deg >260 && deg < 280)
{
Serial.print("Heading Compas:");Serial.println(" West ");
}
else if (deg >310 && deg < 330)
{
Serial.print("Heading Compas:");Serial.println(" North West ");
}
else {delay(1);}
delay(500);
So i got from North to East > South > West angle degree from 0 to 360.
For the GPS side using TinyGPS Lib.
I picked the parts that calculate and saw me the distance between 2 Locations
Is there an formula or something to combine the compas with the GPS data and the compas to saw me in which direction is the 2nc location that i picked?
Domino60:
Is there an formula or something to combine the compas with the GPS data and the compas to saw me in which direction is the 2nc location that i picked?
It would be much easier without a compass module but with moving the GPS module instead.
Every GPS module has the ability to calculate course bearing and speed from a "last position" (one second ago) and the "current position" (now).
So if your speed is above some threshold value (perhaps 1 knot = ca. 0.5 m/s, maybe less), the GPS module will return your actual course and speed in the $GPRMS NMEA sentence, which can be evaluated by your library.
And if you have your "actual course bearing" from GPS you are driving and the "course bearing to destination" from your calculation, you then can decide whether to steer left, right or straight.
Every GPS module has the ability to calculate course bearing and speed from a "last position" (one second ago) and the "current position" (now).
The GPS only reports position information. It is up to the processor to use two different positions to compute a heading. If the GPS is not moving that is not possible.
In the case of a GPS connected to an Arduino, it is up to the Arduino to compute the heading. But, of course, that can only be done if the GPS reports different position information. Which, of course, means that the GPS needs to be moving.
If you use the TinyGPSPlus library (TinyGPS++ | Arduiniana) you can use the courseTo() function to determine the heading to your destination coordinates.
Every GPS module has the ability to calculate course bearing and speed from a "last position" (one second ago) and the "current position" (now).
So if your speed is above some threshold value (perhaps 1 knot = ca. 0.5 m/s, maybe less), the GPS module will return your actual course and speed in the $GPRMS NMEA sentence, which can be evaluated by your library.
And if you have your "actual course bearing" from GPS you are driving and the "course bearing to destination" from your calculation, you then can decide whether to steer left, right or straight.
Well i need the combination of GPS and Compoas for my test vehicle and would be easier for me
to program the moving motors by the angle degree / direction instead of just left and right from the GPS.
The formula you use for distance is only valid (<1%) for relative short distances (less 1 degree)
Yes I understand, i just wrote a fast code to test the module, what I'm gonna really use is the actual degrees but as a output LCD interface i'm gonna use the letters to describe the destination.
If you use the TinyGPSPlus library (TinyGPS++ | Arduiniana) you can use the courseTo() function to determine the heading to your destination coordinates.
Looks intresting, I may try the code but let's say we don't have that and anyway i have a Compas how could I combine the compas with the gps?
I think you need to look at the various GPS libraries, and the examples that they provide to see the facilities that exist.
I have used TinyGPS and the plus, both are excellent, BUT you need to look at the examples, you will be surprised how much work has already been done.
Even if you do not have a GPS unit, the examples are well commented.
Domino60:
Looks intresting, I may try the code but let's say we don't have that and anyway i have a Compas how could I combine the compas with the gps?
You know the location of your destination. You get your current location from the GPS. Those two points will allow you to calculate the heading to your destination. The compass will tell you the direction it is pointed. You could combine the two to determine which direction to turn the compass (left or right) to point at the destination.
What you asked for was heading to the destination. You don't need the compass for that.
I think you need to look at the various GPS libraries, and the examples that they provide to see the facilities that exist.
I have used TinyGPS and the plus, both are excellent, BUT you need to look at the examples, you will be surprised how much work has already been done.
I just came to comment
I had the old TinyGPS lib and just downloaded the TinyGPS Plus the new beta version, looking the Full Example
"example" It's really impressive comparing with the old version that i had and the old version had max storage
25kb the new version 15kb full data. wow
The "course.deg" it saw me the angle degree Compas destination ?