Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ttn decoded data is different to display/serial console data #37

Open
muckisg opened this issue Mar 24, 2021 · 6 comments
Open

ttn decoded data is different to display/serial console data #37

muckisg opened this issue Mar 24, 2021 · 6 comments

Comments

@muckisg
Copy link

muckisg commented Mar 24, 2021

Hi,

i was asked to start a new issue. I am working with a T-Beam V1.0 and realized all steps from the readme file.
My T-Beam display and serial console show the right gps coordinates but using the decoder script from the readme with ttn show different results.

TTN output:

image

Serial console output:

image

any ideas?

Thanks in advance,

Maurice aka muckisg

@kizniche
Copy link
Owner

kizniche commented Mar 24, 2021

This is a strange issue. I can't immediately think of anything that would cause this. Give me some time to think of potential causes. If you have any ability to debug in the meantime, please do.

@muckisg
Copy link
Author

muckisg commented Mar 24, 2021

Yes, sure i do as far as i can. It is strange to me that the results in ttn differ from packet to packet, so that the payload seems to be interpreted completly wrong but i guess i would not be the first person to find this problem then. Could it be a byte order problem?
Thanks for your quick response by the way! :-)

@askmurphy
Copy link

askmurphy commented Mar 25, 2021 via email

@muckisg
Copy link
Author

muckisg commented Mar 25, 2021

Would you share your decoder? If this is the problem it is a structural one so that every user should have the problem as far as i can tell. Thanks in advance, MuckiSG

@muckisg
Copy link
Author

muckisg commented Mar 31, 2021

@kizniche I tested a bit and here are my results till now:
I made a minimal sketch reading the GPS data, converting them into a payload with your code from the gps.ino and printed the payload to the serial plotter. I took the payload and tested it with the decoder from your README. That worked! So, the decoder is correct.
So i guess the payload gets corrupted somewhre. Here my testcode:

#include <TinyGPS++.h>                       
 
uint32_t LatitudeBinary;
uint32_t LongitudeBinary;
uint16_t altitudeGps;
uint8_t hdopGps;
uint8_t sats;
char t[32]; // used to sprintf for Serial output
uint8_t txBuffer[10];

TinyGPSPlus gps;                            
HardwareSerial GPS_Serial(1);                 

void setup()
{
  Serial.begin(115200);
  GPS_Serial.begin(9600, SERIAL_8N1, 34, 12);   //TX-RX
}

void loop()
{
  Serial.print("Latitude  : ");
  Serial.println(gps.location.lat(),5);
  Serial.print("Longitude : ");
  Serial.println(gps.location.lng(),5);
  Serial.print("Satellites: ");
  Serial.println(gps.satellites.value());
  Serial.print("Altitude  : ");
  Serial.print(gps.altitude.meters());
  Serial.println("M");
  Serial.print("Time      : ");
  Serial.print(gps.time.hour());
  Serial.print(":");
  Serial.print(gps.time.minute());
  Serial.print(":");
  Serial.println(gps.time.second());
  Serial.println("**********************");

    LatitudeBinary = ((gps.location.lat() + 90) / 180.0) * 16777215;
    LongitudeBinary = ((gps.location.lng() + 180) / 360.0) * 16777215;
    altitudeGps = gps.altitude.meters();
    hdopGps = gps.hdop.value() / 10;
    sats = gps.satellites.value();
    
    txBuffer[0] = ( LatitudeBinary >> 16 ) & 0xFF;
    txBuffer[1] = ( LatitudeBinary >> 8 ) & 0xFF;
    txBuffer[2] = LatitudeBinary & 0xFF;
    txBuffer[3] = ( LongitudeBinary >> 16 ) & 0xFF;
    txBuffer[4] = ( LongitudeBinary >> 8 ) & 0xFF;
    txBuffer[5] = LongitudeBinary & 0xFF;
    txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
    txBuffer[7] = altitudeGps & 0xFF;
    txBuffer[8] = hdopGps & 0xFF;
    txBuffer[9] = sats & 0xFF;
    for (int x=0; x < 10; x++)
      {
        if (txBuffer[x] < 16)
        {
          Serial.print("0");
        }
        Serial.print(txBuffer[x], HEX);
        Serial.print(" ");
      }
     Serial.println();  
  smartDelay(1000);                                      

  if (millis() > 5000 && gps.charsProcessed() < 10)
    Serial.println(F("No GPS data received: check wiring"));
}

static void smartDelay(unsigned long ms)                
{
  unsigned long start = millis();
  do
  {
    while (GPS_Serial.available())
      gps.encode(GPS_Serial.read());
  } while (millis() - start < ms);
}

I am not that deep in your code and i am the worst coder on planet earth but i hope it helps to find the error.

sunny greetings,

Maurice

@muckisg
Copy link
Author

muckisg commented Apr 8, 2021

FYI:
Payload within ttn_send: C8 BD 3E 85 09 0B 00 A7 12 06 <-correct
Payload in TTN console: DB DB 7D 33 F7 F0 68 50 F0 84 <- bad

Because of the fact the payload is correct within the ttn_send function, the error has to be somewhere within the trasmission or ttn handling. The payload ttn receives is definitely wrong! When i send the payload "00 01 02 03 04 05 06 07 08 09" i get totaly different resunlts on the ttn end an even changing results.

So, your software seams to be correct but do you have an idea where the error is?

Tried a second board aswell with the same results, so no hardware error.

thx, Maurice

Repository owner deleted a comment from askmurphy Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants