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

**URL:** <https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284>\
**Category:** \[obsolete\] SCPF\
**Created:** [March 29, 2018, 12:00pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284 "2018-03-29T12:00:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Batigolle](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/batigolle/32/38442_2.png) [@Batigolle](https://www.thethingsnetwork.org/forum/u/Batigolle)\
**Post date:** [March 29, 2018, 12:00pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/1 "2018-03-29T12:00:49Z")

</div>

Hi all  
I realized a gateway with Raspberry PI3 and Dragino Hat v1.4 in which I verified  
the possibility to send downstream message to the node

I summarize all the steps in this topic

Original reference links ( where I took the suggestion 😉 )  
[forum/t/dragino-problems-and-solutions-topic](https://www.thethingsnetwork.org/forum/t/dragino-problems-and-solutions-topic/8951/13)

After assembling the Dragino Hat in the Raspberry, install the code  
[/bokse001/dual\_chan\_pkt\_fwd](https://github.com/bokse001/dual_chan_pkt_fwd/tree/dual_chan_pkt_fwd_up_down)

**IMPORTANT NOTE:**  
This code was developed to use it with a gateway equipped with two RFM85s,  
in our case we use only one RFM95 for which it is necessary  
to make some modifications to the code after installation

**PREREQUISITES**  
. Installation command git  
sudo apt-get install git  
. SPI needs to be enabled on the Raspberry Pi  
. Installation wiringpi (GPIO access library )  
sudo apt-get install wiringpi

**INSTALLATION**

```
 cd /home/pi 
 git clone -b dual_chan_pkt_fwd_up_down https://github.com/bokse001/dual_chan_pkt_fwd 
 cd dual_chan_pkt_fwd 

```

Modify configuration global\_conf.json

```
 Pins for Dragino hat are: 
   "pin_nss": 6, 
   "pin_dio0": 7, 
   "pin_nss_2": 6, 
   "pin_dio0_2": 7, 
   "pin_rst": 3, 

 The other pins can remain untouched. 

```

Change the LoraModem.c file, comment out line 552

```
 // Die("Unrecognized transceiver"); 

```

Complete the installation with command

```
 make      
 sudo make install  

```

The last command ,activates the gateway as a service ( start automatically ) each time the Raspberry is started

**NOTE:**  
The global\_conf.json file, is read every time the service is started,  
after each change it is sufficient to restart the service

For the test I used a sensor with the code ttn-abp.ino taken from the examples folder of matthijskooijman/arduino-lmic subsequently modified, to transmit, only on channel 868100000

The default installation on the raspberry, / bokse001 / dual\_chan\_pkt\_fwd  
receive the messages only on channel 868300000, so I modified the global\_conf.json file  
by inverting the values of the two freq and freq\_2 fields

```
from
{ “freq”: 868100000,
  “freq_2”: 868300000,
   …
to
{ “freq”: 868300000,
  “freq_2”: 868100000,
  …

```

Finally,  
in the sensor code, to receive the DownStream message,  
I added the following line of code, inside the setup () function, before do\_send (& sendjob);

// Let LMIC offset for +/- 10% clock error

```
 LMIC_setClockError (MAX_CLOCK_ERROR * 10/100);	

```

**AS I VERIFIED SENDING THE MESAGE TO THE NODE**  
For the test i used the TTN Console, send bytes message 00 01 02  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/7/7be779b1d8272ff501f8c02a6dd59cdacddf7e90.png)

From Application Data Console

![image](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/1/1d66ea9b73d0eb82467340fd76d0e2735bac5789.jpg)

In the node I received

![image](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/d/d58bf357fcfd70855d78062b864c29171694d6a4.png)

---

<div class="post-metadata">

**Author:** ![glbaum](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/glbaum/32/12895_2.png) [@glbaum](https://www.thethingsnetwork.org/forum/u/glbaum)\
**Post date:** [April 21, 2018, 2:14am UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/2 "2018-04-21T02:14:16Z")

</div>

Assuming this will work as well with the 915Mhz bands, will have to do some testing this weekend if I can.

---

<div class="post-metadata">

**Author:** ![Nanne118](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nanne118/32/13340_2.png) [@Nanne118](https://www.thethingsnetwork.org/forum/u/Nanne118)\
**Post date:** [May 10, 2018, 4:11pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/4 "2018-05-10T16:11:57Z")

</div>

So I was able to succesfully install the dual channel package from the repo (thanks for the instructions 🙂 ), but I am failing to understand how I forward it to the things network as a gateway. I think I am supposed to input a gateway ID that corresponds to TTN and my RPI with LoraHat, but I cannot find this Gateway ID anywhere on the RPI. The examples that use the (now deprecated) single channel package list the gateway ID as soon as the program starts running: ![gateway](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/5/5215229eb64591d42c730b46547f95436f79acb0.PNG)

---

<div class="post-metadata">

**Author:** ![glbaum](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/glbaum/32/12895_2.png) [@glbaum](https://www.thethingsnetwork.org/forum/u/glbaum)\
**Post date:** [May 10, 2018, 4:28pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/5 "2018-05-10T16:28:55Z")

</div>

Did you check what is being reported in the log file?

```bash
sudo journalctl -f -u dual_chan_pkt_fwd

```

Since you are running it as a service you don’t see the output like you saw from the Single Channel examples.

---

<div class="post-metadata">

**Author:** ![Nanne118](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nanne118/32/13340_2.png) [@Nanne118](https://www.thethingsnetwork.org/forum/u/Nanne118)\
**Post date:** [May 10, 2018, 4:32pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/6 "2018-05-10T16:32:38Z")

</div>

![gateway2](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/8/8b3e39d41211a150e2228b873cf4be0679c83c8c.PNG)

This is most likely because I have not been able to understand how to configure it in TTN

---

<div class="post-metadata">

**Author:** ![glbaum](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/glbaum/32/12895_2.png) [@glbaum](https://www.thethingsnetwork.org/forum/u/glbaum)\
**Post date:** [May 10, 2018, 4:44pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/7 "2018-05-10T16:44:47Z")

</div>

The stat update information is normal unless you have a node that is running somewhere trying to send data to your gateway. When you bring up the log file like that you aren’t seeing the entire log file, so what you were trying to look for, the Gateways ID, should be listed in the log file time stamped when you started the service. I’m also still a little bit confused as to why you need to see your Gateway ID? It is just going to be your devices MAC address if you are trying to figure out it’s ID from just running the code.

---

<div class="post-metadata">

**Author:** ![Nanne118](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nanne118/32/13340_2.png) [@Nanne118](https://www.thethingsnetwork.org/forum/u/Nanne118)\
**Post date:** [May 10, 2018, 4:47pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/8 "2018-05-10T16:47:08Z")

</div>

I am trying to register the gateway on the things network so that I can and send receive data from it, similarly to what one would do with the single package forwarder, but I am failing to understand how to do it. I can follow the tutorial perfectly, that is not the problem, but I fail to understand how I can communicate to and from the RPI.

---

<div class="post-metadata">

**Author:** ![Batigolle](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/batigolle/32/38442_2.png) [@Batigolle](https://www.thethingsnetwork.org/forum/u/Batigolle)\
**Post date:** [May 10, 2018, 4:55pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/9 "2018-05-10T16:55:29Z")

</div>

Hi @Nanne118  
I did not understand some things …

1. Did you register the gateway on the TTN server?
2. Do you have a sensor that transmits data to the gateway?
3. if answer 2 is positive, have you created an application on the TTN server?
4. have you installed the gateway service, which will start automatically?

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [May 10, 2018, 5:02pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/10 "2018-05-10T17:02:41Z")

</div>

Not receiving packets has nothing to do with the gateway being registered on TTN.

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [May 10, 2018, 5:06pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/11 "2018-05-10T17:06:35Z")

</div>

> [@Nanne118](#):
>
> I fail to understand how I can communicate to and from the RPI.

You node just sends data. It does not specifically talk to the RPi. (This is not WIFI where a device talks to one access point) A node broadcasts a packet. A gateway within reach will receive the data and forward it to TTN where you can find it in your application. Just keep the browser open on the application data page for the node that is sending data.

The ID you are looking for is the first 6 numbers/letters from the RPi MAC address, followed by FFFF followed by the remaining 6 characters of the MAC.

---

<div class="post-metadata">

**Author:** ![Nanne118](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nanne118/32/13340_2.png) [@Nanne118](https://www.thethingsnetwork.org/forum/u/Nanne118)\
**Post date:** [May 10, 2018, 5:14pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/12 "2018-05-10T17:14:59Z")

</div>

Is that just ‘ffff’ to enter, eg ‘b827faffff92fc50’?

---

<div class="post-metadata">

**Author:** ![Nanne118](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nanne118/32/13340_2.png) [@Nanne118](https://www.thethingsnetwork.org/forum/u/Nanne118)\
**Post date:** [May 10, 2018, 5:20pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/13 "2018-05-10T17:20:31Z")

</div>

Hey @Batigolle

1. I have not been able to setup my RPI as a gateway in the TTN site yet, as I can / could not get the gateway ID to work for me. @Kersing just informed me that I am apperantly doing it wrong (there’s a first :P) and as such the gateway keeps listing as not connected.

2/3. The idea after this is to use a secondary pi with the LORA hat to transmit data, or use a different LORA capable board to transmit the data: for me to do this I would need to create an application similarly to how I would create the gateway as far as I understand it.

1. I followed the tutorial / steps above, so AFAIK the gateway service should be installed. I do not think it runs automatically yet on startup (?), but I can remedy that by adding it to the /init.d list

---

<div class="post-metadata">

**Author:** ![Batigolle](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/batigolle/32/38442_2.png) [@Batigolle](https://www.thethingsnetwork.org/forum/u/Batigolle)\
**Post date:** [May 10, 2018, 5:33pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/14 "2018-05-10T17:33:54Z")

</div>

let’s try a rate one step at a time

try to register the gateway on the TTN server, you need the gateway ID.  
If you followed my instructions, the gateway service should start automatically when the PI3 starts.  
try to stop the service with the command  
systemctl stop dual\_chan\_pkt\_fwd  
and restart it by hand with the command (run from within the dual\_chan\_pkt\_fwd folder)  
sudo ./dual\_chan\_pkt\_fwd

as an ouput, in the first lines, the gateway ID will appear  
copy it and use it to register the gateway on the TTN server

---

<div class="post-metadata">

**Author:** ![Nanne118](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nanne118/32/13340_2.png) [@Nanne118](https://www.thethingsnetwork.org/forum/u/Nanne118)\
**Post date:** [May 10, 2018, 5:38pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/15 "2018-05-10T17:38:20Z")

</div>

So I just did that, and now the gateway ID does indeed appear 😃  
However, the gateway id presents itself as 00:00:00:ff:ff:00:00:00 : I either seem to have received the first device with a MAC address in the world, or something is off here. I ran it again to be sure it was not a fluke and it again comes up with the same MAC address.  
 ![gateway3](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/e/e45140cb2d8cf6e249ede76d57e912dcc120b6f7.PNG)

---

<div class="post-metadata">

**Author:** ![Batigolle](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/batigolle/32/38442_2.png) [@Batigolle](https://www.thethingsnetwork.org/forum/u/Batigolle)\
**Post date:** [May 10, 2018, 5:43pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/16 "2018-05-10T17:43:49Z")

</div>

00:00:00:ff:ff:00:00:00 😱  
what version of raspberry do you use?  
looking in the forum I found …  
[https://www.thethingsnetwork.org/forum/t/cannot-get-the-correct-eui/6745](https://www.thethingsnetwork.org/forum/t/cannot-get-the-correct-eui/6745)  
try to follow their instructions

---

<div class="post-metadata">

**Author:** ![glbaum](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/glbaum/32/12895_2.png) [@glbaum](https://www.thethingsnetwork.org/forum/u/glbaum)\
**Post date:** [May 10, 2018, 5:50pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/17 "2018-05-10T17:50:52Z")

</div>

Also a reminder to make sure that the interface (eth0 or wlan0) is set correctly in the json file.

---

<div class="post-metadata">

**Author:** ![Nanne118](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nanne118/32/13340_2.png) [@Nanne118](https://www.thethingsnetwork.org/forum/u/Nanne118)\
**Post date:** [May 10, 2018, 6:20pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/18 "2018-05-10T18:20:50Z")

</div>

Succes!

![gateway4](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/3/3cfae62191c17349de840c466ec1ffa482ca5f60.PNG)

Thanks to all of you for giving me all this help, I really wish I was a bit better at doing this stuff so that it would not churn out all these random errors ☹

So I can now do the same thing with my ‘node / client’ device in the applications \> devices tab, correct? So that I can send data from one and receive it on the other (or use half duplex on both)?

---

<div class="post-metadata">

**Author:** ![Batigolle](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/batigolle/32/38442_2.png) [@Batigolle](https://www.thethingsnetwork.org/forum/u/Batigolle)\
**Post date:** [May 10, 2018, 7:52pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/19 "2018-05-10T19:52:59Z")

</div>

> [@Nanne118](#):
>
> So I can now do the same thing with my ‘node / client’ device in the applications \> devices tab, correct? So that I can send data from one and receive it on the other (or use half duplex on both)?

yes, the next step is to register the sensor in the application

> [@Nanne118](#):
>
> Thanks to all of you for giving me all this help, I really wish I was a bit better at doing this stuff so that it would not churn out all these random errors ☹

I, too, at the beginning, but even now, I find it difficult to understand the functioning of Lorawan  
I suggest you use the forum with the ‘search’ function, many solutions have already been published 👍

---

<div class="post-metadata">

**Author:** ![Nanne118](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nanne118/32/13340_2.png) [@Nanne118](https://www.thethingsnetwork.org/forum/u/Nanne118)\
**Post date:** [May 15, 2018, 8:04pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/20 "2018-05-15T20:04:59Z")

</div>

I scoured the forums trying to find more information regarding the Dragino GPS + Lora Shield, but I was not able to find too much stuff that I can work with directly. I did try to implement the verification of sending the data via the simulated downlink on the TTN console itself, but I cannot get the Raspberry Pi Gateway to acknowledge the transmission of data (via downlink):

preparing a downlink package

![transmission1](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/7/722e4a6b9302a7638b16bcfabceb5008e34ca6f0.PNG)

downlink package scheduled, but does not want to transmit. I notice that after a while it disappears from the data list despite it not being sent / received on the Rpi.

![transmission2](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/3/3ac648c23a3abfc09bd30a5b25a65ac84e79e309.PNG)

no downlink package received in the raspberry pi itself; it does update periodically, which is nice

![transmission3](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/3/3eeb135beaf94ea13dbbcd6b11efd070378e3a6c.PNG)

//////////////////////////////////////////////////////////////////////////

Alternatively, I tried to implement the LMIC method as described on the Dragino wiki, but this also does not bear fruit. Although I can install and alter the necessary files (specifically, alter the Device Address/ Network Key and App Key according to the key(s) from TTN Console) I cannot get the LMIC to succesfully transmit:

![lmic2](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/e/e47dd77fb63c6e2562f4faee6bf969d74ef8dee1.PNG)

![lmic1](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/b/b040f4cced858a25ff76af9b023423e85a1331dc.PNG)

Although it claims that pin 4 cannot be found, this is not referenced in the pin mapping below as I have changed the pin mapping to what is recommended on the Dragino wiki.

![lmic3](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/6/679dd2f5bff5efdbc291094e1a12be61652792b7.PNG)

![lmic4](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/5/517f901cc929e4339ba39270da60ddc4f4b40488.PNG)

---

<div class="post-metadata">

**Author:** ![Batigolle](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/batigolle/32/38442_2.png) [@Batigolle](https://www.thethingsnetwork.org/forum/u/Batigolle)\
**Post date:** [May 15, 2018, 8:26pm UTC](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284/21 "2018-05-15T20:26:24Z")

</div>

Hi @Nanne118  
for downstream message , did you follow my instructions ?

[Next page](https://www.thethingsnetwork.org/forum/t/dual-chan-gateway-with-raspberry-pi3-dragino-hat-v1-4-and-downstream-messages/13284.md?page=2)
