kizniche / ttgo-tbeam-ttn-tracker

TTGO T-Beam Tracker for TTN Mapper and TTN Tracker using US (915 MHz) and EU (868 MHz) frequencies
https://kylegabriel.com/projects/2019/04/lorawan-tracker-and-mapper.html
GNU General Public License v3.0
262 stars 139 forks source link

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

Open muckisg opened 3 years ago

muckisg commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

I had the same problem, solved it by using another decoder, check your source and look if there more versions of the decoder inside 😀

Regards,

Arthur

Verstuurd vanaf mijn iPhone

Op 24 mrt. 2021 om 16:30 heeft Kyle Gabriel @.***> het volgende geschreven:

 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.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

muckisg commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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