[solved] transer GPS coordinates over RFM12b


im in process of making gps rc car, ability send new waypoints car remote, , have car send current coordinates. i've gotten pretty working, 1 exception. numbers i'm trying send (the gps coordinates) large send. gps numbers 8-9 digits, while in research i've done, looks largest number can send 5 digits (i dont remember exact number).

any idea how this?

everything prints out on transmit side comes out correctly, on recieve side different numbers, , shorter.

here transmitter code (basic gps , rfm12b code):

code: [select]
#include <jeelib.h>

#include <softwareserial.h>

#include <tinygps.h>

tinygps gps;
softwareserial ss(4, 3);
typedef struct
{
 long lat1, long1;
}
payload;
payload test;
long flat, flon;
float lat2, long2;

void setup()
{
 serial.begin(115200);
 ss.begin(4800);
 rf12_initialize(1, rf12_433mhz, 33);

 serial.print("simple tinygps library v. ");
 serial.println(tinygps::library_version());
 serial.println("by mikal hart");
 serial.println();
}

void loop()
{
 bool newdata = false;
 unsigned long chars;
 unsigned short sentences, failed;

 // 1 second parse gps data , report key values
 for (unsigned long start = millis(); millis() - start < 1000;)
 {
   while (ss.available())
   {
     char c = ss.read();
     // serial.write(c); // uncomment line if want see gps data flowing
     if (gps.encode(c)) // did new valid sentence come in?
       newdata = true;
   }
 }

 if (newdata)
 {

   unsigned long age;
   gps.get_position(&flat, &flon, &age);
   serial.print("lat=");
   serial.print(flat == tinygps::gps_invalid_f_angle ? 0.0 : flat, 6);
   serial.print(" lon=");
   serial.print(flon == tinygps::gps_invalid_f_angle ? 0.0 : flon, 6);
 }
 test.lat1 = flat/10;
 test.long1 = -flon/10;
 int i=0;
 lat2 = test.lat1, 5;
 long2 = test.long1, 5;
 lat2= lat2/100000, 5;
 long2 = long2/100000, 5;
 while (rf12_cansend() && i<10) {
   rf12_recvdone();
   i++;
 }
 rf12_sendstart(0, &test, sizeof test);
 serial.print("  ");
 serial.print(test.lat1);
 serial.print("  ");
 serial.print(test.long1);
 serial.print("  ");
 serial.print(lat2, 5);
 serial.print("  ");
 serial.println(long2, 5);
}


reciever code:
code: [select]
#include <jeelib.h>

typedef struct // create structure - neat way of packaging data rf comms
{
 int lat1, long1;
}
payload;      
payload test;  

float lat2, long2;

void setup () {
 serial.begin(115200);
 rf12_initialize(1, rf12_433mhz, 33);

}

void loop () {

 if (rf12_recvdone() && rf12_crc == 0) {
   serial.print("ok ");
   test=*(payload*) rf12_data;
   lat2 = test.lat1;
   long2 = test.long1;
   lat2= lat2/100000, 5;
   long2 = long2/100000, 5;
   serial.print(test.lat1);
   serial.print("  ");
   serial.print(test.long1);
   serial.print("  ");
   serial.print(lat2, 5);
   serial.print("  ");
   serial.println(long2, 5);
   delay(100);
 }

}

quote
the numbers i'm trying send (the gps coordinates) large send.

nonsense. aren't sending values strings. sending them binary data. struct 8 bytes. if radio can send 8 bytes in packet, better radio.

code: [select]
  // 1 second parse gps data , report key values
  (unsigned long start = millis(); millis() - start < 1000;)
  {

which stupid, because typically gps sends data once second.

code: [select]
  if (newdata)
  {
     // send stuff serial port...
  }
  test.lat1 = flat/10;
  test.long1 = -flon/10;
  int i=0;
  lat2 = test.lat1, 5;
  long2 = test.long1, 5;
  lat2= lat2/100000, 5;
  long2 = long2/100000, 5;
  while (rf12_cansend() && i<10) {
    rf12_recvdone();
    i++;
  }
  rf12_sendstart(0, &test, sizeof test);

even if there no new data, send anyway. why?

what nonsense comma operator , lat2 , long2 about?


Arduino Forum > Using Arduino > Project Guidance > [solved] transer GPS coordinates over RFM12b


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support