Some changes have been made by the TTN network,I have updated this project in January 15th,more info about the changes please check below links:



If you have any problem with this project,you can connact us by support@dragino.com or post the problems on the TTN forum (Special thanks to @CurlyWurly).

Over here,we will use the Lora Shileld,MEGA2560 and Raspberry Pi to build a single channel LoRaWAN gateway.

LoRa Technology is a wireless modulation for long-range, low-power, low-data-rate applications. By achieving a range of more than 15 kilometers in a suburban environment and more than 2 kilometers in a dense urban environment, LoRa technology solutions target multiple application domains, such as Internet-of-Things (IoT), metering, security, and machine-to-machine (M2M).

This single channel LoRaWAN gateway is a proof-of-concept implementation,that can be used for development and node testing. It is not a replacement for a real multi channel/multi SF gateway! It supports some LoRaWAN features, but due to its static nature (single channel) it is not fullyLoRaWAN compatible (and will never be).
By default it works with the TTN backend, for testing and development.
Refer to the summary of Thomas

Step 1: Hardwares

In this project,we use the things as followed list:

  • Two Lora Shields v95-868
  • Raspberry Pi 2(Installed Raspbian)
  • MEGA 2560
  • LED display screen
  • USB cables
  • Antennas(868MHZ)
  • Computer
  • Wireless network card
  • Mouse and keyboard
  • Dupont Lines

Step 2: A Brief Introduction of the Dragino Lora Shield and the Ttn Network

The Dragino Lora Shield is a long range transceiver on a Arduino shield form factor and based on Open source library.The Lora Shield allows the user to send data and reach extremely long ranges at low data-rates.It provides ultra-long range spread spectrum communication and high interference immunity whilst minimising current consumption.

The Lora Shield based on RFM95W/RFM98W targets professional wireless sensor network applications such as irrigation systems, smart metering, smart cities, smartphone detection, building automation, and so on. More info please click here.

The TTN network is based on LoRaWAN,it's a global open crowdsourced Internet of Things data network.We can get more information form http://thethingsnetwork.org/

Step 3: Network Structure

The construction of this network is as the photo above.

Lora Node:

The Mega2560 will get sensor data and control the Lora Shield to send this data to the RPi Lora Gateway via Lora wireless protocol.

Lora Gateway:

The RPi Lora Gateway will receive this data and upload it to the TTN network via the Internet.

TTN Server:

The TTN Server will get the data packets from the RPi Lora Gateway and the data will be stored in the corresponding place,so users can take what they need from the Internet.


We can use the PC to get the data and check the status of this Lora Gateway network.

Step 4: Create an Account on TTN Network

Before we start this project we must have a TTN account,we can create one at this page: http://thethingsnetwork.org/signup/

You have two options to create the register devices in TTN. Firstly you can use the GUI at https://staging.thethingsnetwork.org, which is straightforward. Secondly, you can use the commandline tool ttnctl. When I started documented this, only ttnctl was available. Basically, follow the guide from https://www.thethingsnetwork.org/wiki/Backend/ttnctl/ttnctl. Download ttnctl, sign up, create an application. You can use either the GUI Then, use ttnctl to register a personalized device.The specific operation please check above website.

Step 5: Create a Gateway on TTN Network

NOTE: Create your own lora gateway is not necessary, if there are TTN lora gateway around, you don't have to create your own one. in this instruction, we want to demo the full network structure so we create gateway here.

Login the TTN network by your own account and turn to this page: https://console.thethingsnetwork.org/gateways

Click 'add a gateway' and you will enter a page to type your gateway message(such as the first photo and the second one).In the next step,we will get a Gateway ID after we run the packet forward on the RPi.Then type the Gateway ID to the Gateawy EUI column(In hexadecimal, no colons,uppercase letters).

We can see the ruuning result as the 3rd picture in this step,we get a Gateway ID: b8:27:eb:ff:ff:29:4b:3b,so we type B827EBFFFF294B3B to the Gateway EUI column.

By the way,we also need to modify other settings(Select the Frequency plan,select your gateway address and your can config other settings by clicking the settings button),save it and you will see your profile such as the fourth picture at this step.As you can see,the gateway status is connected,it means we just have created a Gateway for our TTN account.

In addition,you can check all the TTN Gateway status at https://staging.thethingsnetwork.org/gatewaystatus/ (as the last picture)

Step 6: Create an Application on the TTN Network

In this step,we need to create an application on the TTN network.

1.Open this website :https://staging.thethingsnetwork.org/applications,you will see it as the first picture.

2.Click "create application" to create your own applications and name it.

3.You will see your 'Application Info' at the new created page,App EUI....

4.Register device.In this project ,we choose the ABP device type,click 'register device'--'ABP'--'Register'.(For an ABP device, you can set the App Session Key and the Network Session key. Both of these can be randomly generated (recommended).)

5.You will see the 'device info' on the new created page,such as Dev EUI,App EUI,Dev Address,NWKSKEY,APPSKEY,etc.So,you can use them at the following steps.

Back to the Application page,you will see all devices that are registered for this application are displayed on the "Devices" colunm.And the Messages that were sent to all devices that are part of this application

There,you can also use the v2 version to setting your Application and Gateway: https://console.thethingsnetwork.org/

Step 7: Build a Single Channel LoRaWAN Gateway

In this step,we will use the RPi and the Lora Shield to build a single channel LoRaWAN Gateway.We should configure the RPi and connect it with the Lora Shield.Complete the operations as following description:


  • Connect the Raspberry Pi to the Internet;
  • Use 'raspi-config ' to ensure that SPI can be used on RPi ;
  • Use 'sudo apt-get install wiringpi' to install the GPIO access library written in C for the BCM2835 used in the Raspberry Pi;
  • Get the single channel Lora Gateway source code from here;
  • Edit the 'main.cpp' to change configuration (look for: "Configure these values!").


    LoRa: SF7 at 868.1 Mhz

    The server_address depends on the region:

    • router.eu.thethings.network # EU 433 MHz and EU 863-870 MHz
    • router.us.thethings.network # US 902-928 MHz
    • router.cn.thethings.network # China 470-510 MHz and 779-787 MHz
    • router.au.thethings.network # Australia 915-928 MHz

    See more info here

    So,we don't need too change the code here.


    The Dragino Lora Shield ------ Raspberry Pi

    5V ------ 5V(pin#2)

    GND ------ GND(pin#6)

    MISO ------ MISO(pin#21)

    MOSI ------ MOSI(pin#19)

    SCK ------ CLK(pin#23)

    (CS_A)NSS ------ GPIO6(pin#22)

    DIO0 ------ GPIO7(pin#7)

    RST ------ GPIO0(pin#11)

    Connect the Dragino Lora Shield and the RPi as above,run packet forwarder as root. Then we can get a Gateway ID and see the running result on the RPi as the 3rd picture at this step.

    We also can get the Gateway status from https://staging.thethingsnetwork.org/gatewaystatus... . In this URL need to search your own Gateway ID and you will see the uplink&downlink status of your gateway. If you can see the Gateway status is active, it shows the LoRaWAN Gateway is working!

    Note: If the packet forwarder shows the "unrecognized transceiver" message,this mean the RPi can't detect Lora Shield. in this case please further check your pin/wiring configuration.

    Step 8: Connect the Lora Shield and MEGA 2560,upload the Sktech

    Connect the Lora Shield and MEGA 2560,and put the 868MHZ antenna on it.Connect them to the computer via an USB cable.

    Over here,we use the Arduino IDE1.68,we need to install this Arduino-LMIC liabrary.This repository contains the IBM LMIC (LoraMAC-in-C) library, slightly modified to run in the Arduino environment, allowing using the SX1272, SX1276 tranceivers and compatible modules.

    Note:This library requires Arduino IDE version 1.6.6 or above, since it requires C99 mode to be enabled by default.

    After do that,we download the ttn sketch from this link.

    Open and modify this sktech,change the 'DEVADDR' ,'NWKSKEY','APPSKEY' (You can find these device info at Step 6) on line 40th,choose the right port and right board to upload the sktech.We can see the running result on the Serial Monitor if everything is ok.(4th photo)

    At the same time we can also see the corresponding results on RPi.By default,the node is sending at 10 frequencies, the gateway is receiving at only 1, hence the one packet per 10 minutes.

    On a "real" gateway I see all messages (each minute), only with this Single Channel Gateway was this phenomena.
    This is not a real gateway, it is for testing purposes. It is LoRaWAN compatible, but not compliant.

    Refer tohttp://forum.thethingsnetwork.org/t/single-channel-gateway/798/17 and http://forum.thethingsnetwork.org/t/single-channel-gateway/798/19

    If you are using Lora Shield v1.1 version. please wired as below code(such as the last photo at this step):

    // Pin mapping<br>const lmic_pinmap lmic_pins = {
        .nss = 10,// Connected to pin D10
        .rxtx = LMIC_UNUSED_PIN,// For placeholder only, Do not connected on RFM92/RFM95
        .rst = 9,// Needed on RFM92/RFM95? (probably not)
        .dio = {2, 6, 7},// Specify pin numbers for DIO0, 1, 2
    // connected to D2, D6, D7 

    Step 9: Conclusion

    Above all completed,open your Application page,you will see the result as above picture.

    The Lora Shield for RPi will coming soon,For more info about Lora Shield, please refer:http://wiki.dragino.com/index.php?title=Lora_Shield or contact us at info@dragino.com

    By the way,we can get this Lora Shield fromhttp://www.aliexpress.com/store/all-wholesale-products/1390863.html

    Hi,all,<br><br>In this project, you can see how to &quot;Use Lora Shield + Arduino set up a Lora Node&ldquo;,You can also get how to &quot;Use Lora/GPS HAT + RaspberryPi to set up a Lora Node&quot; as below:
    <p><a href="http://wiki.dragino.com/index.php?title=Lora/GPS_HAT#Use_Lora.2FGPS_HAT_.2B_RaspberryPi_to_set_up_a_Lora_Node">http://wiki.dragino.com/index.php?title=Lora/GPS_HAT#Use_Lora.2FGPS_HAT_.2B_RaspberryPi_to_set_up_a_Lora_Node</a></p>
    <p>Hey david,</p><p>Im from thailand.Operating frequency for lora shields is within 920-925 Mhz. But available shields are of only 433,868,915 Mhz. Can we tune 915 ones to 920 which should be compatible with raspberry pi? </p>
    <p>How do I configure the gateway code with 915MHz in Australia?? </p>
    <p>Hi David,</p><p>I just ordered my first three LoRa shield from Dragino (2 for RPi and 1 for Arduino). Before I start the project I just want to ask is it possible that I have 2 nodes sending sensor data (1 RPi + 1 Arduino) to 1 gateway (RPi) and then send the data to the internet (MQTT possibly). I ask this question because you mentioned in this tutorial that this is to develop single channel LoRaWAN gateway.</p><p>Sorry, I'm totally newbie with this LoRa things.</p><p>Thanks in advance :)</p>
    <p>Yes,you can do it as what you said.</p>
    <p>Hi david,</p><p>I already bought the 433MHz version. Do you have any tutorials for this version? Thanks</p>
    <p>Hi, David.</p><p>I have two lora shield and newbie for internet of thing. I would like to know that is that possible to communicate/send the data to one specific Lora shield without using any internet. The lora shield is connect with RPI and sent data to another lora shield connected with arduino. Is it possible and any other methods to achieve it? </p>
    <p>Some of the Gateway connections were not clear to me and without connecting 3.3V on both Shield and RPI and the 5V on both shield and RPI the radio was not recognized. </p><p>So below are the Dragino Shield pins I used to get the Gateway working:</p><p>- ICSP header pins 4, 1 &amp; 3 for MOSI, MISO and SCK (using D11, D12 &amp; D13 on the shield didn't work!)</p><p>- I used both 3.3V as well as 5V, otherwise the PWR LED didn't burn and the shield would not function at all (probably because of the level shifters) </p><p>- RFM header pins 1 and 7 to connect DIO0 and RST</p><p>- D10 for NSS</p><p>- GND for GND</p>
    There,have you installed the wiringpi?
    <p>Yes I've installed wiringpi.</p><p>I don't have any problems, after using the connections as described in my reply, since for me that part of your instructions were not clear.</p><p>You described to use the SPI connections (MOSI, MISO and SCK), but since you can find them on the ICSP header AND on D11, D12 &amp; D13, I found out that only the ICSP worked for me.<br></p><p>You described to use 3.3V, but I found that the level shifters needed both 5V and 3.3V.</p><p>Using the RFM header for DIO0 and RST was obvious.</p><p>NSS on D10 was not clear for me. </p><p>I've added a picture showing the connections I used.</p>
    <p>You can check the hardware resource here:<a href="https://github.com/dragino/Lora" style="">https://github.com/dragino/Lora</a></p>
    <p>Uhm,I think you need to follow the connections as above article and cheeck your wiring ,don't use 3.3V on the LoRa Shield </p>
    <p>Hi David, In my country using 433Mhz, but in the step 5, I can't find this choice. This gateway in TTN for 868 and 915Mhz and don't have the choice for 433Mhz. Can you help me for this problem ? :(</p>
    <p>The LoRaWan protocol doesn't support 433Mhz,you can click <a href="http://www.lora-alliance.org/">http://www.lora-alliance.org/</a> for more informations.</p>
    <p>where can i get global_conf.json or local_conf.js file ?</p>
    <p>Hi,durvesh,what the software are you using in the RPi side ?</p><p>You can find kinds of pkt_fwd on the Github,such as :</p><p><a href="https://github.com/tftelkamp/single_chan_pkt_fwd">https://github.com/tftelkamp/single_chan_pkt_fwd</a></p><p><a href="https://github.com/hallard/single_chan_pkt_fwd">https://github.com/hallard/single_chan_pkt_fwd</a></p><p><a href="https://github.com/TheThingsNetwork/packet_forwarder/tree/master/poly_pkt_fwd">https://github.com/TheThingsNetwork/packet_forwarder/tree/master/poly_pkt_fwd</a></p><p><a href="https://github.com/proffalken/single_chan_pkt_fwd">https://github.com/proffalken/single_chan_pkt_fwd</a></p>
    <p>Hi David, </p><p>is there any source code in C for the GPS module? I am trying to integrate GPS and LoRa module together thanks</p>
    <p><a>http://wiki.dragino.com/index.php?title=Lora/GPS_HAT#Example2_--_Getting_GPS_to_work_on_a_Raspberry_Pi</a> Have you check this link?</p>
    <p>I'll check it out thanks</p>
    <p>Hi, I am trying to use GPS HAT and RPi to join network with OTAA, any sample code for OTAA?? thanks. </p>
    <p>Hi,guys,you can find the examples here:<a href="https://github.com/matthijskooijman/arduino-lmic/tree/master/examples">https://github.com/matthijskooijman/arduino-lmic/tree/master/examples</a></p>
    It look nice!!
    <p>David </p><p>I'm having problems with the TTN web. When I enter to &quot;my profile&quot; isn't the option to add a new gateway, it just say &quot;claim a gateway&quot;, as the picture shows. Some other links that you show in the instructable are broken. </p><p>On another hand, I found the console link on TTN (https://console.thethingsnetwork.org/gateways) where I can add gateways and apps but some features are different, I don't know if it will work with simple gateway software. It doesn't work for me, but I could have another problem. </p><p>Could you help me?</p><p>Thanks!</p>
    Copy that,and I will update this intruction after my vacation
    <p>Hi! I'm working with the libellium sx1272 ans a cooking hacks shield to connect it with the raspi. I'm having Unrecognizer transceiver problems &iquest;any suggestion?</p><p>Thanks!</p>
    <p>Uhm,sorry to reply so late,how is it going?Did you check your wiring?</p>
    <p>I had to chage the pins for the following:</p><p> ssPin=10; </p><p>dio0=0;</p><p>RST=7;</p><p>I have to do more tests, but for now it works</p>
    <p>Ok,too busy these days,good luck!</p>
    <p>Hi David, I am doing a final year project similair to this but using LoRa gateway and waspmote. I am trying to use cutecom to configure the gateway but not recieving any information packet in response to the READ command. any help ??</p>
    <p>Hi,have you finished it ?And I need more details about your project</p>
    <p>Hey, is it possible to run the &quot;Single channel gateway packet forward source&quot; automatic at start?</p>
    <p>Yes,but you need to make sure your gateway settings is ok.</p>
    <p>To make the &quot;unrecognized transceiver&quot; errors go away I had to change</p><blockquote>bool sx1272 = true;</blockquote><p>to</p><blockquote>bool sx1272 = false;</blockquote><p>in main.cpp</p>
    <p>where is that ? </p>
    In the folder single_chan_paket_fwd,there is a file called main.cpp
    <p>Hi, David.<br>I have bought 2 lora shields. I'm a newbie for network thing, want to know that is it possible to make the multiple Lora shields to communicate/send the data to one specific Lora shield through the method introduced as above. (build a LoraWan gateway) And what if my case is without using any internet, is it any other methods to achieve it?</p>
    Hi JesseW78,as what you said,you can do that,bu it's not &quot;LoRaWan&quot; anymore,and you can use the Radiohead.Uhm,tell me you email and I'll send you the sketches,david@dragino.com,hope it help~
    <p>ok, my email-<br><br>jchening@gmail.com</p>
    <p>Hi, there is an error when checking <a href="https://www.thethingsnetwork.org/api/v0/gateways/B827EBFFFFxxxxxxx/" rel="nofollow">https://www.thethingsnetwork.org/api/v0/gateways/B...</a></p><p>using my own ID I get:<br><br> &quot;error&quot;:&quot;Cannot connect to database!&quot;</p><p>what is wrong?</p><p>also, how can I use the lora antennas to transmit from my arduino (shield) to my rpi (hat) without all the hassle of TTN and encryption etc? They are making me run before I walk. </p><p>Thank you very much for you help</p>
    <p>I am new to this , my question is what does it mean by single channel gateway?</p>
    <p>I've a problem with my gateway:</p><p>I can see that the Gateway receives packages at the terminal of the RPI, but I can't see the messages at the TTN dashboard.<br>As a node I use a RN2483.</p><p>Does someone have an idea where the problem could be?</p><p>Thank you.</p>
    <p>I have the same problem, the gateway receives, but i can't see the messages at hte TNN dashboard. Tried as IP but still nothig. Any Ideas?</p>
    Hi FelixKunz,<br>Can you access the server via this IP? Did you have a try?<br>
    <p>Problem solved, use as IP for Europe!</p>
    <p>Good! If there is any problem with this project,you can contact us by e-mail.</p><p>Cheers!</p>
    <p>Hi David</p><p>Thanks for your tutorial. I have one question about setting server. How can I configure my own server? What software do we need for server and also gateway?</p><p>Thanks in advance.</p>
    Hi,sama moh,I think it's better to view the ttn web to get what you need
    <p>Hi David, great tutorial, thanks! Is it possible to increase the rate at which data arrives from the node to the TTN message dashboard? If so, can you explain what code modifications are needed please?</p>

    About This Instructable




    More by David_Dragino:Use the LoRa Kit to build your own IoT network Dragino LoRa GPS Tracker How to get sensor data from a remote Arduino via Wireless Lora Protocol 
    Add instructable to: