Dual-Chan Gateway with Raspberry PI3 + Dragino Hat v1.4 and Downstream messages

@bauvill
I sent you a message with the sketch I used in the sensor for the test,
maybe he can help you.
Sorry for the comments lines in Italian :sunglasses:

Do I need to make an application to have the gateway to be instructed to forward the messages it get? I made an application and when I register the same gateway it doe not show that it is connected whereas in the Gateway console it shows connected and the gateway does not show any traffic in the console.

Thank you, sir.

No, the gateway will always forward all messages to TTN.

My node is made based on RPI +DRAGINO and the LMIC library for repair the function LMIC_setError is not defined in the LMIC API. Do I need to implement it myself?
Maybe that is why it does not work.

It is actually in the LMIC library just most likely not the version you are using. I have come across this issue a couple times now within the last couple weeks. The LMIC library that is available just by searching through the Arduino IDE Manage libraries option does not have this code setup. Everyone here when they point you to a TTN - LMIC example are using the updated version that includes the ability to implement the setClockError ā€œaddā€ which means youā€™ll need to update your library files to the ones they are referring to.

Note: This is as far as I can tell from my own copy of the Arduino IDE

1 Like

Is it present only in the LMIC library for Arduino?
Asking because I am not using Arduino but Raspberry Pi.
Thanks for the clarification though.

The simplest ways of checking that might just be to open up the LMIC files on your Pi and search if there is a MAX_CLOCK_ERROR set somewhere, in the Arduino libs itā€™s easy to see if itā€™s implemented or not in the LMIC.h file. So for the Pi if itā€™s using similar C++ files you should be able to find it. But if itā€™s not there, thatā€™s not the only place there is probably a bit of code missing relating to that issue which means you might have to do some digging.

Also this clock Error issue is one that is very much more rooted in the Arduino side of things and not the Raspberry Pi (though the different versions have their own issues) because itā€™s been implemented to check the timing crystal and itā€™s variations used in the official and ā€˜off-brandā€™ versions of their boards.

1 Like

@bauvill
raspberry for the gateway, what do you use as a sensor?

I am using RPI 3B + dragino HAT V1.4 running the dual_chan_pkt_fwd ( as Batigolle described in his post related to this topic), as of the end-device ( Lora node) same components ( RPI 3B +Dragino HAT V1.4) are used. It is to be noted that my end device runs the ABP LMIC v1.6 version from ( https://github.com/wklenk/lmic-rpi-lora-gps-hat/blob/master/examples/periodic/main.c). I will give you more details or screenshots of my code, logs of my end device and gateway in the next post.

1 - This is the code running on my end-device




#include <stdio.h>
#include "lmic.h"
#include "debug.h"

// sensor functions
extern void initsensor(void);
//extern u2_t readsensor(void); 


//////////////////////////////////////////////////
// CONFIGURATION (FOR APPLICATION CALLBACKS BELOW)
//////////////////////////////////////////////////

//NOTE: these values are used for testing on my local LoraWAN server
static const u1_t APPEUI[8]  = { 0x6B, 0xF3, 0x00, 0xD0, 0x7E, 0xD5, 0xB3, 0x70 };
static const u1_t DEVEUI[8]  = { 0xFF, 0x85, 0xEF, 0xFF, 0xFF, 0xEB, 0x27, 0xB8 };
static const u1_t DEVKEY[16] = { 0x4A, 0x10, 0xBA, 0x2E, 0x74, 0x3D, 0x28, 0xDF, 0x9C, 0xA9, 0xA2, 0xC2, 0x27, 0xE2, 0xAD, 0x2B };
static const u1_t ARTKEY[16]  ={ 0x36, 0x2F, 0x66, 0x8D, 0x1C, 0xC4, 0x08, 0x5C, 0x11, 0x31, 0x66, 0x91, 0xC4, 0xC1, 0x3D, 0xB3 };
static const u4_t DEVADDR = 0x011793AA; // <-- Change this address for every node!


// provide application router ID (8 bytes, LSBF)
void os_getArtEui (u1_t* buf)
 {
    memcpy(buf, APPEUI, 8);
}

// provide device ID (8 bytes, LSBF)
void os_getDevEui (u1_t* buf) 
{
    memcpy(buf, DEVEUI, 8);
}

// provide device key (16 bytes)
void os_getDevKey (u1_t* buf) 
{
    memcpy(buf, DEVKEY, 16);
}



void setup() 
{
  os_init();
  // Reset the MAC state. Session and pending data transfers will be discarded.
  LMIC_reset();
 
  // by joining the network, precomputed session parameters are be provided.
  LMIC_setSession (0x1, DEVADDR, (u1_t*)DEVKEY, (u1_t*)ARTKEY);
  // Disable data rate adaptation
   LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);    
  LMIC_setAdrMode(0);
  // Disable link check validation
  LMIC.dn2Dr = DR_SF9;
  LMIC_setLinkCheckMode(0);
  // Disable beacon tracking
  LMIC_disableTracking ();
  // Stop listening for downstream data (periodical reception)
  LMIC_stopPingable();
  //LMIC_setClockError(MAX_CLOCK_ERROR * 10 / 100);  <------------------------Not implemented
  // Set data rate and transmit power (note: txpow seems to be ignored by the library)
  LMIC_setDrTxpow(DR_SF7,14);
  
}


//////////////////////////////////////////////////
// UTILITY JOB
//////////////////////////////////////////////////

static osjob_t reportjob;

// report sensor value every minute
static void reportfunc (osjob_t* j) 
{
    // read sensor
    //u2_t val = readsensor();
    u2_t val = 0x0; // This is for testing only. this function will send the state(e.g 0%,30%, or 100%)  of a
   //component it will be connected to.
    debug_val("val = ", val);
    // prepare and schedule data for transmission
    LMIC.frame[0] = val >> 8;
    LMIC.frame[1] = val;
    LMIC_setTxData2(1, LMIC.frame, 2, 0); // (port 1, 2 bytes, unconfirmed)
    // reschedule job in 60 seconds
    os_setTimedCallback(j, os_getTime()+sec2osticks(60), reportfunc);
}




void onEvent (ev_t ev) 
{
    debug_event(ev);
    switch(ev) {
      
      case EV_TXCOMPLETE:
          // switch on LED
          debug_led(1);
          if (LMIC.txrxFlags & TXRX_ACK)
         {
			  fprintf(stdout, "ACK RECEIVED\n");
	  }
          fprintf(stdout, "TX COMPLETE\n");
          if(LMIC.dataLen) 
         { // data received in rx slot after tx
              //debug_buf(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
              fprintf(stdout, "Data Received!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
         }
          break;
    default:
          break;
    }
}
void loop()
 {

reportfunc(&reportjob);

 while(1)
 {
  os_runloop();

  }
}


int main() 
{
  setup();

  while (1) 
  {
    loop();
  }
  return 0;
}


2- The screenshot of logs on the End-device

test

2- The output on my gateway

gateway_out

2 Likes

Can you explain why canā€™t I see any data on the gateway console in TTN?

Not with the information I have available at this moment.

Hi all!
first of all, thanks for your tutorial.
Iā€™m following this tutorial with a RPI3B+ and a Dragino HAT v1.4, everything seems to work, but it shows this at the transceiver version:
Captura
And and I do not receive node data.

Hi WalleM
it seems like a configuration problem, it does not recognize the transmission module ā€¦ this is my output:
image

I restarted it and now itā€™s working, by the way,this setup supports OTAA?

Iā€™ve only tried with ABP,
but all that remains is to try ā€¦ let us know if it works

On the page
/bokse001/dual_chan_pkt_fwd
says nothing about OTAA, try to ask

Hi,
First of all, thank you very much for your post, it has been very helpful for me.
Iā€™m using the same setup and my RPI GWY is already working in TTN, now Iā€™m testing a private lora server using http://loraserver.io
have you tried using a private server? Iā€™ve been searching info about it but for that server they use this library: https://github.com/Lora-net/lora_gateway and I see that is for sx1301 transceiver. I donā€™t know if it works with a dragino shield, if someone already tried it or something, I appreciate any information about it.

that subject donā€™t fit in this topic just like the mentioned serversā€¦ for support on those pls use their forum