Transmission not successful on FSB 1 using Sodaq Universal Tracker v2?

Hi there,

I am trying to use gateways that work in these frequencies:

I tried to make the tracker work by changing the default FSB in the RN2483 library to “1”.

For some reason, sometimes OTAA is successful and sometimes it is not. Even after it is successful, transmission is not successful.

I ran some other test code that is provided by SODAQ, and it worked perfectly:


#include "Arduino.h"
#include <Sodaq_RN2483.h>

#define debugSerial SERIAL_PORT_MONITOR

#if defined(ARDUINO_AVR_SODAQ_MBILI)
#define loraSerial Serial1
#define BEE_VCC 20

#elif defined(ARDUINO_SODAQ_AUTONOMO) || defined(ARDUINO_SODAQ_ONE) || defined(ARDUINO_SODAQ_ONE_BETA)
#define loraSerial Serial1

#elif defined(ARDUINO_SODAQ_EXPLORER)
#define loraSerial Serial2

#else
// please select a sodaq board
debugSerial.println("Please select a sodaq board!!");
#endif

//// ABP
const uint8_t devAddr[4] = { 0x00, 0x00, 0x00, 0x00 };
const uint8_t appSKey[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const uint8_t nwkSKey[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

// OTAA

uint8_t DevEUI[8] = { 0xf2, 0x4b, 0x87, 0x15, 0x97, 0xa3, 0x3c, 0xf6 };
uint8_t AppEUI[8] = { 0x0e, 0xc6, 0x99, 0x18, 0xea, 0xb6, 0xb0, 0xed };
uint8_t AppKey[16] = { 0xc5, 0x83, 0x89, 0x24, 0x64, 0x3b, 0x4a, 0x43, 0x20, 0xc5, 0x32, 0x40, 0x6b, 0x24, 0x7d, 0xf4 };

void setupLoRaABP(){  
  if (LoRaBee.initABP(loraSerial, devAddr, appSKey, nwkSKey, false))
  {
    debugSerial.println("Communication to LoRaBEE successful.");
  }
  else
  {
    debugSerial.println("Communication to LoRaBEE failed!");
  }
}

void setupLoRaOTAA(){
  if (LoRaBee.initOTA(loraSerial, DevEUI, AppEUI, AppKey, false))
  {
    debugSerial.println("Communication to LoRaBEE successful.");
  }
  else
  {
    debugSerial.println("OTAA Setup failed!");
  }
}

void setup() {
  //Power up the LoRaBEE
  #if defined(ARDUINO_AVR_SODAQ_MBILI) || defined(ARDUINO_SODAQ_AUTONOMO)
  pinMode(BEE_VCC, OUTPUT);
  digitalWrite(BEE_VCC, HIGH);
  #endif
  delay(3000);

  while ((!SerialUSB) && (millis() < 10000)){
    // Wait 10 seconds for the Serial Monitor
  }

  //Set baud rate
  debugSerial.begin(57600);
  loraSerial.begin(LoRaBee.getDefaultBaudRate());

  // Debug output from LoRaBee
  // LoRaBee.setDiag(debugSerial); // optional

  //connect to the LoRa Network
  setupLoRa();
}

void setupLoRa(){
  // ABP
//  setupLoRaABP();
  // OTAA
  setupLoRaOTAA();
  LoRaBee.setSpreadingFactor(9);
}

void sendPacket(String packet){
  switch (LoRaBee.send(1, (uint8_t*)packet.c_str(), packet.length()))
    {
    case NoError:
      debugSerial.println("Successful transmission.");
      break;
    case NoResponse:
      debugSerial.println("There was no response from the device.");
      setupLoRa();
      break;
    case Timeout:
      debugSerial.println("Connection timed-out. Check your serial connection to the device! Sleeping for 20sec.");
      delay(20000);
      break;
    case PayloadSizeError:
      debugSerial.println("The size of the payload is greater than allowed. Transmission failed!");
      break;
    case InternalError:
      debugSerial.println("Oh No! This shouldn't happen. Something is really wrong! Try restarting the device!\r\nThe network connection will reset.");
      setupLoRa();
      break;
    case Busy:
      debugSerial.println("The device is busy. Sleeping for 10 extra seconds.");
      delay(10000);
      break;
    case NetworkFatalError:
      debugSerial.println("There is a non-recoverable error with the network connection. You should re-connect.\r\nThe network connection will reset.");
      setupLoRa();
      break;
    case NotConnected:
      debugSerial.println("The device is not connected to the network. Please connect to the network before attempting to send data.\r\nThe network connection will reset.");
      setupLoRa();
      break;
    case NoAcknowledgment:
      debugSerial.println("There was no acknowledgment sent back!");
      // When you this message you are probaly out of range of the network.
      break;
    default:
      break;
    }
}

void loop() {
  // put your main code here, to run repeatedly:
  String packet = "SODAQ";
  sendPacket(packet);

  delay(5000);
}

Can anyone help me with this issue?

Thanks!

To add,

This is the serial output. I modified the code to display the errors in LoRaBee.send as well:

There was an error while transmitting through LoRaWAN.

Error: 1

Error 1 corresponds to “No Response” I am not sure why this would be the case. Thanks!

Hi Gabriel,

I was just actually able to fix my transmit issue by setting the LoRaBee to active before transmitting. However, the OTAA is still unreliable. Sometimes it is succesful and sometimes it is not. If the OTAA is not successful intially, the SODAQ device fails to to initialize upon its retries. Here is my lora_transmit function:

void lora_transmit()
{

	//Check to see if transmitting through LoRa is possible
	debugPrintln("Check to see if transmitting through Lora is possible");
	if (!isLoraInitialized)
	{
		// check for a retry
		debugPrintln("Lora is not initialized");
		if (!params.getShouldRetryConnectionOnSend() || !retryInitLora())
		{
			lora_error = TRUE;
		}
	}

	if (!lora_error)
	{
		setLoraActive(true);
		for (uint8_t i = 0; i < 1 + params.getRepeatCount(); i++)
		{
			uint8_t err = loRaBeeSend(params.getIsAckOn(), params.getLoraPort(), sendBuffer, sendBufferSize);
			if (err != 0)
			{
				debugPrintln("There was an error while transmitting through LoRaWAN.");
				debugPrint("Error: ");
				debugPrintln(err);
				//debugPrint("\n");
				lora_error = TRUE;
			}
			else
			{
				debugPrintln("Data transmitted successfully.");

				uint16_t size = LoRaBee.receive(receiveBuffer, sizeof(receiveBuffer));
				receiveBufferSize = size;

				if (size > 0)
				{
					debugPrintln("Received OTA Configuration.");
					updateConfigOverTheAir();
				}
			}
		}
	}
	setLoraActive(false);
}

Does that original graphic show the upstream channels available on the gateway?
e.g. 902.3, 902.5, 902.7, 902.9 and 903@500?

If so, that is not the complete set for FSB 1, which may explain the loses: http://www.microchip.com/forums/m926581.aspx

Based on the above graphic and the only channels which should be enabled are 0, 1, 2, 3 & 64 (4, 5, 6, & 7 are not available).

When using FSB 1, for your situation, you should be able to fix this by changing line 577 from:

uint8_t last125kHzChannel = fsb > 0 ? first125kHzChannel + 7 : 71;

to:

uint8_t last125kHzChannel = fsb > 0 ? first125kHzChannel + 3 : 71;

Hi Gabriel!

Thank you for this information. I will have to confirm this with the vendor. I will make these changes if necessary.

After enabling the retry for the init process, I am seeing a reliable stream of data transmission.

Thank you!