GPS_Tracker Example not sending datat to ChirpStack

I have a Wisblock Rak5005-0 with a WicBlock GNSS Location Module, 3-axis acceleration sensor and a light sensor (this is not used here soI might just take if off)

I’ve uploaded the GPS_Tracker example that I have customized by adding my own nodeDeviceEUI[8] and nodeAppKey[16] values as show in the ChirpStack Device configuration dashboard.

While the WisBlock is still connected to my PC I can see such data in the Arduno’s Serial Port monitor:

11:06:01.681 → check acc!
11:06:01.681 → X = 252.20mg Y = -5.00mg Z =992.81mg
11:06:11.689 → check acc!
11:06:11.689 → X = 255.21mg Y = -6.00mg Z =996.81mg
11:06:21.697 → check acc!
11:06:21.697 → X = 255.21mg Y = -5.00mg Z =1000.81mg
11:06:31.705 → check acc!
11:06:31.705 → X = 254.21mg Y = -10.01mg Z =993.81mg
11:06:41.668 → check acc!
11:06:41.668 → X = 251.20mg Y = -5.00mg Z =992.81mg
11:06:51.677 → check acc!
11:06:51.677 → X = 252.20mg Y = -4.00mg Z =995.81mg

but nothing in the “Device Data” tab on the ChirpStack.

The only thing I was able to notice was that I did receive the following in the “Lorawan Frames” tab:

I’ve also added a short video showing my current settings: Recording #2

The question is why I don’t get any Device Data?

Hi @digib

First, I see the Join Accept, so all is good with the EUI’s and Keys.

There is a check in the example code that is only sending data if the device is in a specific orientation:

if( abs(x-z) < 400)

It is in the function void tx_lora_periodic_handler(void).
If you comment out that line, the device will send data independent of the orientation of the device.

Other option is to (if I remember correct) to change the orientation of the WisBlock so that the USB port is pointing up.

I’ve removed the if/else condition and now getting Device Data like this:

and like this on the serial monitor:

so now I have 2 more questions:

  1. Where are the GPS coordinates?
  2. What should I use in my COdec (Custom Javascript codec functions) to be able to receive readable data?

I really appreciate your support and quick response @beegee !

Didn’t use the custom packet encoding of the example for a long time, but it should be something like:

function Decode(fPort, bytes, variables) {
	// Decode an uplink message from a buffer
	// (array) of bytes to an object of fields.
	var decoded = {};
	if (bytes[0] == 0x09) {
		// GPS data
		decoded.latitude = (bytes[4] | bytes[3] << 8 | bytes[2] << 16 | bytes[1] << 24 | (bytes[1] & 0x80 ? 0xFF << 24 : 0)) / 100000.0;
		decoded.longitude = (bytes[9] | bytes[8] << 8 | bytes[7] << 16 | bytes[6] << 24 | (bytes[6] & 0x80 ? 0xFF << 24 : 0)) / 100000.0;
		decoded.e_w = bytes[5];
		decoded.n_s = bytes[10];
	}
	return decoded;
}

I’ve got this result where the longitude is missing:

On the other hand, can you please show me what exactly needs to be done in order to get the DecodeDataHex to the objectJSON values? How exactly is the Decode function built? I’m not familiar with javascript but I can understand almost anything as I do some python programming myself.

And what about this type of 3-axis data? 11:06:51.677 → X = 252.20mg Y = -4.00mg Z =995.81mg Why this was not sent?

Which example are you using? This GPS Tracker Example is not sending the accelerometer data:

      m_lora_app_data.port = gAppPort;
      m_lora_app_data.buffer[0] = 0x09;
      //lat data
      m_lora_app_data.buffer[1] = (ilat & 0xFF000000) >> 24;
      m_lora_app_data.buffer[2] = (ilat & 0x00FF0000) >> 16;
      m_lora_app_data.buffer[3] = (ilat & 0x0000FF00) >> 8;
      m_lora_app_data.buffer[4] =  ilat & 0x000000FF;
      if(direction_S_N == 0)
      {
        m_lora_app_data.buffer[5] = 'S';    
      }
      else
      {
        m_lora_app_data.buffer[5] = 'N';    
      }
      //lon data
      m_lora_app_data.buffer[6] = (ilon & 0xFF000000) >> 24;
      m_lora_app_data.buffer[7] = (ilon & 0x00FF0000) >> 16;
      m_lora_app_data.buffer[8] = (ilon & 0x0000FF00) >> 8;
      m_lora_app_data.buffer[9] =  ilon & 0x000000FF;
      if(direction_E_W == 0)
      {
        m_lora_app_data.buffer[10] = 'E';
      }
      else
      {
        m_lora_app_data.buffer[10] = 'W';
      }
      m_lora_app_data.buffsize = 11;
      send_lora_frame();

It is putting only the Lat and Long into the packet.

@digib

I have to apologize, just found out that the example that comes with the RAK-nRF52-Arduino was not updated. The old example was sending the location as a string and it was very difficult to parse it on the LNS side.

Please use the updated example GPS_Tracker.ino from our WisBlock repo.
The packet sent by this updated example can be decoded with the Javascript I sent you.

Regarding the values from the accelerometer, they are not included in the packet.

Sorry for the inconvenience with the old example code. We will update it in the next release of the BSP.

I have used the code you mentioned here GPS_Tracker.ino and only modified the uint8_t nodeDeviceEUI[8], uint8_t nodeAppEUI[8] and uint8_t nodeAppKey[16] values from my previous code and now I do get this into the Serial Monitor window:

10:22:37.771 → =====================================
10:22:37.771 → Welcome to RAK4630 LoRaWan!!!
10:22:37.771 → Type: OTAA
10:22:37.771 → Region: EU868
10:22:37.771 → =====================================
10:22:37.771 → Sensor at 0x18 started.
10:22:39.969 → gps uart init ok!
10:22:45.207 → OTAA Mode, Network Joined!
10:22:56.187 → check acc!
10:22:56.187 → X = 48.04mg Y = 16.01mg Z =1008.82mg
10:23:06.184 → check acc!
10:23:06.184 → X = 48.04mg Y = 16.01mg Z =1008.82mg
10:23:16.186 → check acc!
10:23:16.186 → X = 32.03mg Y = 32.03mg Z =1024.83mg

but nothing in the Device Data or Lorawan Frames tabs from the ChirpStack dashboard.

The codec used is still the one you exposed above:

function Decode(fPort, bytes, variables) {
	// Decode an uplink message from a buffer
	// (array) of bytes to an object of fields.
	var decoded = {};
	if (bytes[0] == 0x09) {
		// GPS data
		decoded.latitude = (bytes[4] | bytes[3] << 8 | bytes[2] << 16 | bytes[1] << 24 | (bytes[1] & 0x80 ? 0xFF << 24 : 0)) / 100000.0;
		decoded.longitude = (bytes[9] | bytes[8] << 8 | bytes[7] << 16 | bytes[6] << 24 | (bytes[6] & 0x80 ? 0xFF << 24 : 0)) / 100000.0;
		decoded.e_w = bytes[5];
		decoded.n_s = bytes[10];
	}
	return decoded;
}

So bottom line, if with the earlier code I was only getting the Longitude, now I’m not getting anything. :slight_smile:

Update: Just double-checked and indeed with the earlier code, same settings I am getting data without Longitude as described in my earlier post.

Did you take out the line with

if( abs(x-z) < 400)

?

@digib
And in addition, you need to be outside. The GNSS antenna cannot get a location inside the house.
If the code doesn’t have a location, it does not send the packet.

Just tried the code and put the WisBlock into my frontyard. Getting this output from the encoder:
image

Found a mistake in the encoder, here is the corrected one, that gives the correct N/S/E/W data.

function Decode(fPort, bytes, variables) {
	// Decode an uplink message from a buffer
	// (array) of bytes to an object of fields.
	var decoded = {};
	if (bytes[0] == 0x09) {
		// GPS data
		decoded.latitude = (bytes[4] | bytes[3] << 8 | bytes[2] << 16 | bytes[1] << 24 | (bytes[1] & 0x80 ? 0xFF << 24 : 0)) / 100000.0;
		decoded.longitude = (bytes[9] | bytes[8] << 8 | bytes[7] << 16 | bytes[6] << 24 | (bytes[6] & 0x80 ? 0xFF << 24 : 0)) / 100000.0;
		decoded.n_s = String.fromCharCode(bytes[5]);
		decoded.e_w = String.fromCharCode(bytes[10]);
	}
	return decoded;
}

I sure did, so my code looks like this:

/**
 * @file GPS_Tracker.ino
 * @author rakwireless.com
 * @brief This sketch demonstrate a GPS tracker that collect location from a uBlox M7 GNSS sensor
 *    and send the data to lora gateway.
 *    It uses a 3-axis acceleration sensor to detect movement of the tracker
 * @version 0.2
 * @date 2021-04-30
 * 
 * @copyright Copyright (c) 2020
 * 
 * @note RAK4631 GPIO mapping to nRF52840 GPIO ports
   RAK4631    <->  nRF52840
   WB_IO1     <->  P0.17 (GPIO 17)
   WB_IO2     <->  P1.02 (GPIO 34)
   WB_IO3     <->  P0.21 (GPIO 21)
   WB_IO4     <->  P0.04 (GPIO 4)
   WB_IO5     <->  P0.09 (GPIO 9)
   WB_IO6     <->  P0.10 (GPIO 10)
   WB_SW1     <->  P0.01 (GPIO 1)
   WB_A0      <->  P0.04/AIN2 (AnalogIn A2)
   WB_A1      <->  P0.31/AIN7 (AnalogIn A7)
 */

#include <Arduino.h>
#include <LoRaWan-RAK4630.h> //http://librarymanager/All#SX126x
#include <SPI.h>
#include "SparkFunLIS3DH.h" //http://librarymanager/All#SparkFun-LIS3DH
#include "Wire.h"
#include <TinyGPS.h>        //http://librarymanager/All#TinyGPS

LIS3DH SensorTwo(I2C_MODE, 0x18);

TinyGPS gps;

String tmp_data = "";
int direction_S_N = 0;  //0--S, 1--N
int direction_E_W = 0;  //0--E, 1--W

// RAK4630 supply two LED
#ifndef LED_BUILTIN
#define LED_BUILTIN 35
#endif

#ifndef LED_BUILTIN2
#define LED_BUILTIN2 36
#endif

bool doOTAA = true;   // OTAA is used by default.
#define SCHED_MAX_EVENT_DATA_SIZE APP_TIMER_SCHED_EVENT_DATA_SIZE /**< Maximum size of scheduler events. */
#define SCHED_QUEUE_SIZE 60                     /**< Maximum number of events in the scheduler queue. */
#define LORAWAN_DATERATE DR_0                   /*LoRaMac datarates definition, from DR_0 to DR_5*/
#define LORAWAN_TX_POWER TX_POWER_5             /*LoRaMac tx power definition, from TX_POWER_0 to TX_POWER_15*/
#define JOINREQ_NBTRIALS 3                      /**< Number of trials for the join request. */
DeviceClass_t gCurrentClass = CLASS_A;          /* class definition*/
LoRaMacRegion_t gCurrentRegion = LORAMAC_REGION_EU868;    /* Region:EU868*/
lmh_confirm gCurrentConfirm = LMH_UNCONFIRMED_MSG;          /* confirm/unconfirm packet definition*/
uint8_t gAppPort = LORAWAN_APP_PORT;                      /* data port*/

/**@brief Structure containing LoRaWan parameters, needed for lmh_init()
 */
static lmh_param_t lora_param_init = {LORAWAN_ADR_ON, LORAWAN_DATERATE, LORAWAN_PUBLIC_NETWORK, JOINREQ_NBTRIALS, LORAWAN_TX_POWER, LORAWAN_DUTYCYCLE_OFF};

// Foward declaration
static void lorawan_has_joined_handler(void);
static void lorawan_join_failed_handler(void);
static void lorawan_rx_handler(lmh_app_data_t *app_data);
static void lorawan_confirm_class_handler(DeviceClass_t Class);
static void send_lora_frame(void);

/**@brief Structure containing LoRaWan callback functions, needed for lmh_init()
*/
static lmh_callback_t lora_callbacks = {BoardGetBatteryLevel, BoardGetUniqueId, BoardGetRandomSeed,
                                        lorawan_rx_handler, lorawan_has_joined_handler, lorawan_confirm_class_handler, lorawan_join_failed_handler
                                       };
                                       
//OTAA keys !!!! KEYS ARE MSB !!!!
uint8_t nodeDeviceEUI[8] = {0x8A, 0xF3, 0xA6, 0xA8, 0xD1, 0x9F, 0xDF, 0x35};
uint8_t nodeAppEUI[8] = {0x00, 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 0x00};
uint8_t nodeAppKey[16] = {0xA1, 0x2C, 0xCB, 0x9C, 0x80, 0xAA, 0x5B, 0x6D, 0xC7, 0x62, 0x4E, 0x86, 0xA2, 0x71, 0xD5, 0x98};

// ABP keys
uint32_t nodeDevAddr = 0x260116F8;
uint8_t nodeNwsKey[16] = {0x7E, 0xAC, 0xE2, 0x55, 0xB8, 0xA5, 0xE2, 0x69, 0x91, 0x51, 0x96, 0x06, 0x47, 0x56, 0x9D, 0x23};
uint8_t nodeAppsKey[16] = {0xFB, 0xAC, 0xB6, 0x47, 0xF3, 0x58, 0x45, 0xC7, 0x50, 0x7D, 0xBF, 0x16, 0x8B, 0xA8, 0xC1, 0x7C};

// Private defination
#define LORAWAN_APP_DATA_BUFF_SIZE 64                     /**< buffer size of the data to be transmitted. */
#define LORAWAN_APP_INTERVAL 10000                        /**< Defines for user timer, the application data transmission interval. 10s, value in [ms]. */
static uint8_t m_lora_app_data_buffer[LORAWAN_APP_DATA_BUFF_SIZE];        //< Lora user application data buffer.
static lmh_app_data_t m_lora_app_data = {m_lora_app_data_buffer, 0, 0, 0, 0}; //< Lora user application data structure.

TimerEvent_t appTimer;
static uint32_t timers_init(void);
static uint32_t count = 0;
static uint32_t count_fail = 0;

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  // Initialize Serial for debug output
  time_t timeout = millis();
  Serial.begin(115200);
  while (!Serial)
  {
    if ((millis() - timeout) < 5000)
    {
      delay(100);
    }
    else
    {
      break;
    }
  }

  // Initialize LoRa chip.
  lora_rak4630_init();

  Serial.println("=====================================");
  Serial.println("Welcome to RAK4630 LoRaWan!!!");
  if (doOTAA)
  {
    Serial.println("Type: OTAA");
  }
  else
  {
    Serial.println("Type: ABP");
  }

  switch (gCurrentRegion)
  {
    case LORAMAC_REGION_AS923:
      Serial.println("Region: AS923");
      break;
    case LORAMAC_REGION_AU915:
      Serial.println("Region: AU915");
      break;
    case LORAMAC_REGION_CN470:
      Serial.println("Region: CN470");
      break;
  case LORAMAC_REGION_CN779:
    Serial.println("Region: CN779");
    break;
    case LORAMAC_REGION_EU433:
      Serial.println("Region: EU433");
      break;
    case LORAMAC_REGION_IN865:
      Serial.println("Region: IN865");
      break;
    case LORAMAC_REGION_EU868:
      Serial.println("Region: EU868");
      break;
    case LORAMAC_REGION_KR920:
      Serial.println("Region: KR920");
      break;
    case LORAMAC_REGION_US915:
      Serial.println("Region: US915");
    break;
  case LORAMAC_REGION_RU864:
    Serial.println("Region: RU864");
    break;
  case LORAMAC_REGION_AS923_2:
    Serial.println("Region: AS923-2");
    break;
  case LORAMAC_REGION_AS923_3:
    Serial.println("Region: AS923-3");
    break;
  case LORAMAC_REGION_AS923_4:
    Serial.println("Region: AS923-4");
      break;
  }
  Serial.println("=====================================");

  //lis3dh init
  if (SensorTwo.begin() != 0)
  {
    Serial.println("Problem starting the sensor at 0x18.");
  }
  else
  {
    Serial.println("Sensor at 0x18 started.");
  // Set low power mode
  uint8_t data_to_write = 0;
  SensorTwo.readRegister(&data_to_write, LIS3DH_CTRL_REG1);
  data_to_write |= 0x08;
  SensorTwo.writeRegister(LIS3DH_CTRL_REG1, data_to_write);
  delay(100);

  data_to_write = 0;
  SensorTwo.readRegister(&data_to_write, 0x1E);
  data_to_write |= 0x90;
  SensorTwo.writeRegister(0x1E, data_to_write);
  delay(100);
  }
  //gps init

  pinMode(WB_IO2, OUTPUT);
  digitalWrite(WB_IO2, 0);
  delay(1000);
  digitalWrite(WB_IO2, 1);
  delay(1000);
  
  Serial1.begin(9600);
  while (!Serial1);
  Serial.println("gps uart init ok!");
  
  //creat a user timer to send data to server period
  uint32_t err_code;

  err_code = timers_init();
  if (err_code != 0)
  {
    Serial.printf("timers_init failed - %d\n", err_code);
    return;
  }

  // Setup the EUIs and Keys
  if (doOTAA)
  {
    lmh_setDevEui(nodeDeviceEUI);
    lmh_setAppEui(nodeAppEUI);
    lmh_setAppKey(nodeAppKey);
  }
  else
  {
    lmh_setNwkSKey(nodeNwsKey);
    lmh_setAppSKey(nodeAppsKey);
    lmh_setDevAddr(nodeDevAddr);
  }

  // Initialize LoRaWan
  err_code = lmh_init(&lora_callbacks, lora_param_init, doOTAA, gCurrentClass, gCurrentRegion);
  if (err_code != 0)
  {
    Serial.printf("lmh_init failed - %d\n", err_code);
    return;
  }

  // Start Join procedure
  lmh_join();
}

void loop()
{
  // Put your application tasks here, like reading of sensors,
  // Controlling actuators and/or other functions. 
}

/**@brief LoRa function for handling HasJoined event.
 */
void lorawan_has_joined_handler(void)
{
  if(doOTAA == true)
  {
  Serial.println("OTAA Mode, Network Joined!");
  }
  else
  {
    Serial.println("ABP Mode");
  }

  lmh_error_status ret = lmh_class_request(gCurrentClass);
  if (ret == LMH_SUCCESS)
  {
    delay(1000);
    TimerSetValue(&appTimer, LORAWAN_APP_INTERVAL);
    TimerStart(&appTimer);
  }
}
/**@brief LoRa function for handling OTAA join failed
*/
static void lorawan_join_failed_handler(void)
{
  Serial.println("OTAA join failed!");
  Serial.println("Check your EUI's and Keys's!");
  Serial.println("Check if a Gateway is in range!");
}
/**@brief Function for handling LoRaWan received data from Gateway
 *
 * @param[in] app_data  Pointer to rx data
 */
void lorawan_rx_handler(lmh_app_data_t *app_data)
{
  Serial.printf("LoRa Packet received on port %d, size:%d, rssi:%d, snr:%d, data:%s\n",
          app_data->port, app_data->buffsize, app_data->rssi, app_data->snr, app_data->buffer);
}

void lorawan_confirm_class_handler(DeviceClass_t Class)
{
  Serial.printf("switch to class %c done\n", "ABC"[Class]);
  // Informs the server that switch has occurred ASAP
  m_lora_app_data.buffsize = 0;
  m_lora_app_data.port = gAppPort;
  lmh_send(&m_lora_app_data, gCurrentConfirm);
}

void send_lora_frame(void)
{
  if (lmh_join_status_get() != LMH_SET)
  {
    //Not joined, try again later
    return;
  }

  lmh_error_status error = lmh_send(&m_lora_app_data, gCurrentConfirm);
  if (error == LMH_SUCCESS)
  {
    count++;
    Serial.printf("lmh_send ok count %d\n", count);
  }
  else
  {
    count_fail++;
    Serial.printf("lmh_send fail count %d\n", count_fail);
  }
  TimerSetValue(&appTimer, LORAWAN_APP_INTERVAL);
  TimerStart(&appTimer);
}

/**@brief Function for analytical direction.
 */
void direction_parse(String tmp)
{
    if (tmp.indexOf(",E,") != -1)
    {
        direction_E_W = 0;
    }
    else
    {
        direction_E_W = 1;
    }
    
    if (tmp.indexOf(",S,") != -1)
    {
        direction_S_N = 0;
    }
    else
    {
        direction_S_N = 1;
    }
}

/**@brief Function for handling a LoRa tx timer timeout event.
 */
String data = "";
void tx_lora_periodic_handler(void)
{ 
  float x = 0;
  float y = 0;
  float z = 0;

  bool newData = false;
  
  Serial.println("check acc!");
  x = SensorTwo.readFloatAccelX() * 1000;
  y = SensorTwo.readFloatAccelY() * 1000;
  z = SensorTwo.readFloatAccelZ() * 1000;
  data = "X = " + String(x) + "mg" + " Y = " + String(y) + "mg" + " Z =" + String(z) + "mg";
  Serial.println(data);
  data = "";
//  if( abs(x-z) < 400)
//  {
    // For one second we parse GPS data and report some key values
    for (unsigned long start = millis(); millis() - start < 1000;)
    {
      while (Serial1.available())
      {
        char c = Serial1.read();
        // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
        tmp_data += c;
        if (gps.encode(c))// Did a new valid sentence come in?
          newData = true;
      }
    }
    direction_parse(tmp_data);
    tmp_data = "";
    float flat, flon;
    int32_t ilat, ilon;
    if (newData)
    {
      unsigned long age;  
      gps.f_get_position(&flat, &flon, &age);
      flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat;
      ilat = flat * 100000;
      flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon;
      ilon = flon * 100000;
      memset(m_lora_app_data.buffer, 0, LORAWAN_APP_DATA_BUFF_SIZE);
      m_lora_app_data.port = gAppPort;
      m_lora_app_data.buffer[0] = 0x09;
      //lat data
      m_lora_app_data.buffer[1] = (ilat & 0xFF000000) >> 24;
      m_lora_app_data.buffer[2] = (ilat & 0x00FF0000) >> 16;
      m_lora_app_data.buffer[3] = (ilat & 0x0000FF00) >> 8;
      m_lora_app_data.buffer[4] =  ilat & 0x000000FF;
      if(direction_S_N == 0)
      {
        m_lora_app_data.buffer[5] = 'S';    
      }
      else
      {
        m_lora_app_data.buffer[5] = 'N';    
      }
      //lon data
      m_lora_app_data.buffer[6] = (ilon & 0xFF000000) >> 24;
      m_lora_app_data.buffer[7] = (ilon & 0x00FF0000) >> 16;
      m_lora_app_data.buffer[8] = (ilon & 0x0000FF00) >> 8;
      m_lora_app_data.buffer[9] =  ilon & 0x000000FF;
      if(direction_E_W == 0)
      {
        m_lora_app_data.buffer[10] = 'E';
      }
      else
      {
        m_lora_app_data.buffer[10] = 'W';
      }
      m_lora_app_data.buffsize = 11;
      send_lora_frame();
    }
    else
    {
      TimerSetValue(&appTimer, LORAWAN_APP_INTERVAL);
      TimerStart(&appTimer);
    }
//  }
//  else
//  {
//    TimerSetValue(&appTimer, LORAWAN_APP_INTERVAL);
//    TimerStart(&appTimer);
//  }
}

/**@brief Function for the Timer initialization.
 *
 * @details Initializes the timer module. This creates and starts application timers.
 */
uint32_t timers_init(void)
{
  TimerInit(&appTimer, tx_lora_periodic_handler);
  return 0;
}

My codec is this one:

function Decode(fPort, bytes, variables) {
	// Decode an uplink message from a buffer
	// (array) of bytes to an object of fields.
	var decoded = {};
	if (bytes[0] == 0x09) {
		// GPS data
		decoded.latitude = (bytes[4] | bytes[3] << 8 | bytes[2] << 16 | bytes[1] << 24 | (bytes[1] & 0x80 ? 0xFF << 24 : 0)) / 100000.0;
		decoded.longitude = (bytes[9] | bytes[8] << 8 | bytes[7] << 16 | bytes[6] << 24 | (bytes[6] & 0x80 ? 0xFF << 24 : 0)) / 100000.0;
		decoded.n_s = String.fromCharCode(bytes[5]);
		decoded.e_w = String.fromCharCode(bytes[10]);
	}
	return decoded;
}

All the other configs are the same as the initial.

As noted earlier, if I use the previous code (from Arduino - Examples - WisBlock Examples … ) I am getting data but without the Longitude whenever I use the sensor indoor or outdoor while keeping your latest Decode function.

Moreover, I guess it should be a great addition to also output the GPS coordinates into the Serial Monitor just to verify that it is indeed getting GPS data.

@digib

I took your code as is, just changed the DevEUI, AppEUI and ApKey, put the whole thing into my frontyard and it works as expected:

18:18:14->gps uart init ok!
18:18:20->OTAA Mode, Network Joined!
18:18:31->check acc!
18:18:31->X = 96.08mg Y = -32.03mg Z =-944.77mg
18:18:42->check acc!
18:18:42->X = 64.05mg Y = -32.03mg Z =-992.81mg
18:18:53->check acc!
18:18:53->X = 96.08mg Y = -32.03mg Z =-992.81mg
18:19:04->check acc!
18:19:04->X = 80.07mg Y = -32.03mg Z =-992.81mg
18:19:15->check acc!
18:19:15->X = 80.07mg Y = -32.03mg Z =-992.81mg
18:19:26->check acc!
18:19:26->X = 80.07mg Y = -32.03mg Z =-992.81mg
18:19:37->check acc!
18:19:37->X = 80.07mg Y = -32.03mg Z =-992.81mg
18:19:48->check acc!
18:19:48->X = 80.07mg Y = -32.03mg Z =-992.81mg
18:19:59->check acc!
18:19:59->X = 80.07mg Y = -32.03mg Z =-992.81mg
18:20:10->check acc!
18:20:10->X = 80.07mg Y = -16.01mg Z =-992.81mg
18:20:21->check acc!
18:20:21->X = 80.07mg Y = -16.01mg Z =-992.81mg
18:20:32->check acc!
18:20:32->X = 80.07mg Y = -32.03mg Z =-992.81mg
18:20:43->check acc!
18:20:43->X = 80.07mg Y = -32.03mg Z =-992.81mg
18:20:54->check acc!
18:20:54->X = 80.07mg Y = -16.01mg Z =-992.81mg
18:20:55->lmh_send ok count 1
18:21:05->check acc!
18:21:05->X = 64.05mg Y = -16.01mg Z =-992.81mg
18:21:06->lmh_send ok count 2
18:21:16->check acc!
18:21:16->X = 80.07mg Y = -32.03mg Z =-992.81mg
18:21:17->lmh_send ok count 3

As you can see, it took a long time before I got a location fix. From there on it sends the data packets.
On Chirpstack the received data looks like:
image

Steps I did,

  • test outside
  • be patient, it can take 90 seconds or more from a cold start to get a location
  • make sure your device is connected to the LNS