LoRaWAN

 
 
LoRaWAN (Long Range Wide Area Network) is a specification for a telecommunication network suitable for long-distance communication with little power. The technology is used for machine-to-machine communication (Internet of Things).

The architecture consists of gateways, network servers and application servers. There are RF chips from Semtech used to transmit a spread spectrum.

More information about LoRaWAN can be found at:
https://www.lora-alliance.org/
https://www.thethingsnetwork.org/







Build LoRa gateway using Raspberry Pi 3 model B and Dragino LoRa shield v1.1



Information
none

Operating system used
Windows Vista Home Premium SP 1

Hardware used
  • Raspberry Pi 3 model B with pin diagram

    Raspberry Pi 3 model B with pin diagram

    Note:
    To verify this pin diagram, you need to install raspbian, open a terminal and type: gpio readall

  • Dragino LoRa Shield v1.1 868MHz Arduino Wireless Shield

    Dragino LoRa Shield v1.1 868MHZ Arduino Wireless Shield

    Bottom view. The frequency used in Europe is 868 MHz, for the U.S. 900 MHz and in China, Japan and Korea 433 MHz. Make sure your LoRa shield has the correct frequency.

    Dragino LoRa Shield bottom view

    The LoRa Shield v1.1 is equiped with HopeRF RFM95W-868-S2. This module is marked RF96 which means the chip is using the SX1276 chip.

    Chip marked RF96 is using the SX1276 chip

    Dragino LoRa Shield v1.1 with pin diagram.
    Note: Pin 33, 34 and 35 are located nearest to the RF96 chip

    Dragino LoRa Shield pin diagram

    Dragino LoRa Shield schematic

    Dragino LoRa Shield board design

    More information about the Dragino LoRa Shield v1.1 868MHZ Arduino Wireless Shield:
    Dragino LoRa Shield v1.1 Schematic
    http://wiki.dragino.com/index.php?title=Lora_Shield
    https://github.com/dragino/Lora/tree/master/Lora%20Shield

    Additional information: Dragino LoRa shield, part 1.



  • Samsung EVO micro SDHC card, 32GB, 48MB/s, class 10

    Samsung EVO micro SDHC card, 32GB, 48MB/s, class 10

  • Raspberry pi power supply

    Raspberry pi power supply

  • Jumper wires 20 cm long (5x female-female and 3x male-female)

    Jumper wires

  • Breakable male pin headers (only need 2 pins)

    Breakable male pin headers

  • Optional: Ethernet network cable
    The Raspberry Pi 3 has WIFI thus an Ethernet network cable is not actually needed.

    Ethernet cable

  • Optional: Monitor with HDMI connection
    The Raspberry Pi 3 can be remotely accessed using a PC thus a Monitor and HDMI cable is not actually needed.

  • Optional: HDMI cable
    The Raspberry Pi 3 can be remotely accessed using a PC thus a Monitor and HDMI cable is not actually needed.

    HDMI cable

Software prerequisites
none

Procedure
  1. Install NOOBS (New Out Of the Box Software) version 1.9.2 on the micro SD card.
    You can use the same procedure as described in:
    Installing Raspbian on Raspberry Pi model B using NOOBS

  2. Connect a mouse, keyboard, ethernet cable and monitor cable to the Raspberry Pi.

  3. Connect the power cable, the NOOB install manager is now running.
    Click Yes at the warning dialog.

  4. Select option: Raspbian and press the Install button.

  5. Raspbian is now being installed on the micro SD card.
    After installation press the OK button.

  6. Raspbian is being rebooted into the GUI environment.

  7. Instead of an ethernet cable, the Raspberry Pi can be connected to a router via WIFI.
    In the top right corner, select the network icon (two screen monitors) and select your WIFI network and enter the password authentication.

  8. To see what the Raspberry Pi ip address is, hover your mouse over the network icon (two screen monitors or WIFI symbol). You will see the ip address (eth0, wlan0) which you can use to access the Raspberry Pi remotely, for example: 192.168.1.69

  9. To access the Raspberry Pi GUI from your Windows laptop using Remote Desktop Connection, you need to install the xrdp service on the Raspbian. To install this service, type in the terminal:

    • sudo apt-get install xrdp
    • Type: Y [Enter] to continue
    • The packages are downloaded from internet and installed.
    • Start the Remote Desktop Connection on your laptop, enter the Raspberry Pi ip address, for example: 192.168.1.69 and press the Connect button.

      Connect to the Raspberry Pi using Remote Desktop Connection

    • A warning message is displayed, press Yes button.
    • Log into to xrdp using the default Raspbian default account:

      Select module: sesman-Xvnc
      Enter username: pi
      Enter password: raspberry

      Raspbian default account

      Press OK button and a few seconds later you will see the Raspbian GUI.

      Logged in using the default Raspbian default account

    • Install the Samba package so the Raspberry Pi can be accessed by its hostname from a Windows machine instead of its ip address.
      The ip address can change because the Raspberry Pi gets its ip address via DHCP:
      Type: sudo apt-get -y install samba

    • By default the Raspberry Pi hostname is: raspberrypi
      To change the hostname:
      • Type: sudo raspi-config
      • Select: 9 Advanced Options
      • Select: A2 Hostname
      • Select: Ok
      • Enter your new hostname
      • Select: Ok

    • If you want to access the Raspberry Pi filesystem using the iMac Finder install the Appletalk protocol on the Raspberry Pi. Goto the Raspberry Pi and do the following:

      • Type: sudo apt-get install netatalk
      • Open Finder, type: afp://192.168.1.69

    • Reboot the Raspberry Pi

    • Start the Remote Desktop Connection on your laptop, enter the Raspberry Pi hostname, for example: raspberry and press the Connect button.

      Connect to the Raspberry Pi using Remote Desktop Connection and hostname of Raspberry Pi

  10. Install latest updates, open a terminal:
    Type: sudo apt-get update
    Type: sudo apt-get upgrade

  11. Make sure the GPIO access library "wiringpi" is installed:
    Open a terminal and type: sudo apt-get install wiringpi

  12. Select Menu | Preferences | Raspberry Pi configuration
    Select tab Interfaces and enable SPI

    Raspberry Pi SPI enabled



  13. Install and build the Single Channel LoRaWAN Gateway on your Raspberry Pi:

    • Open a terminal on your Raspberry Pi.
    • Create a directory, type: mkdir lorawan_gateway
    • Goto the directory, type: cd lorawan_gateway
    • Download the Single Channel LoRaWAN Gateway, type:
      git clone https://github.com/tftelkamp/single_chan_pkt_fwd.git
    • Goto the sub directory, type: cd single_chan_pkt_fwd
    • Edit file main.cpp, type:
      sudo nano main.cpp
    • Make changes to the configuration according to your situation (look for: "Configure these values!") :
      /**************************************************************
       *
       * Configure these values!
       *
       *************************************************************/
      
      // SX1272 - Raspberry connections
      int ssPin = 6;
      int dio0  = 7;
      int RST   = 0;
      
      // Set spreading factor (SF7 - SF12)
      sf_t sf = SF7;
      
      // Set center frequency
      uint32_t  freq = 868100000; // in Mhz! (868.1)
      
      // Set location
      float lat=52.4518;
      float lon=4.8119;
      int   alt=10.0;
      
      /* Informal status fields */
      /* platform definition */
      static char platform[24]    = "Single Channel Gateway";
      /* used for contact email */
      static char email[40]       = "[email protected]";
      /* used for free form description */
      static char description[64] = "Mobilefish.com LoraWAN Gateway";
      
      // define servers
      // The Things Network: router.eu.thethings.network
      #define SERVER1 "52.169.76.203"
      // The port on which to send data
      #define PORT 1700
      
    • Write the changes to file, type: CTRL+O
    • Exit the file: CTRL+X
    • In the sub directory "single_chan_pkt_fwd" compile the code, type: make
    • A packet forwarder executable file single_chan_pkt_fwd is created.

  14. Shutdown the Raspberry Pi and remove power from the Raspberry Pi.

  15. Solder the antenna and male pin headers to the Dragino LoRa shield.
    See my YouTube movie: Dragino LoRa shield, part 1

  16. Make the following jumper wire connections, see the pin diagrams, between the Dragino LoRa Shield and the Raspberry Pi 3 model B.

    Dragino LoRa shield v1.1 Raspberry Pi 3 model B
    Pin Description Pin Description
    23 5V 2 5V
    25 GND 6 GND
    33 (DO_A) MISO 21 SPI_MISO
    37 (DI_A) MOSI 19 SPI_MOSI
    34 (CLK_A) SCK 23 SPI_CLK
    10 (CS_A) NSS 22 GPIO6
    SV pin 1 DIO 0 7 GPIO7
    SV pin 7 RESET 11 GPIO0


    Wiring Dragino LoRa Shield v1.1 and Raspberry Pi 3 model B.
    Click on the image for a larger image.

    Wiring Dragino and Raspberry Pi

    Additional information: Connect Dragino LoRa Shield v1.1 to Raspberry Pi 3 model B, part 2.



  17. Make sure the Raspberry Pi has internet access.
    Power up the Raspberry Pi and login to the Raspberry Pi.

  18. Open a terminal and type: cd lorawan_gateway/single_chan_pkt_fwd

  19. Startup the packet forwarder executable, type: sudo ./single_chan_pkt_fwd

    Startup lorawan gateway

    Write down your Gateway ID (for example: b8:27:eb:ff:ff:ca:f2:51). You will need it later.

    If the packet forwarder shows the message: "unrecognized transceiver" the Raspberry Pi can not detect the LoRa shield. Check all your wiring and try it again.

  20. Create an account on The Things Network (TTN)
    Provide your email address, username, first and last name.

    The Things Network signup

  21. Once your account has been activated, log in and goto to The Things Network homepage https://www.thethingsnetwork.org
    If you see the Login button press it and you will see:

    The Things Network my profile

    Select "My Profile"

  22. You can add your website and twitter handle. Press the button "ADD A GATEWAY"

    The Things Network add a gateway

  23. Edit the following:
    • Add your gateway title and location on a map. It will appear on The Things Network map.
    • Set the status to: Active
    • Enter your Gateway EUI, in hexadecimals with no colons, for example: B827EBFFFFCAF251
    • Enable "Automatically update status and coordinates"

    The Things Network gateway added

  24. Now check if The Things Network receives data from your LoRaWAN gateway.
    Open a browser and type: http://thethingsnetwork.org/api/v0/gateways/B827EBFFFFCAF251
    Replace the last part with YOUR gateway id.
    You should see something like this:

    The Things Network gateway status

    Note:
    You can also use:
    http://ha-23.eradus.eu/croft.html

    Additional information: Download, configure and startup single channel LoRa gateway, part 3.



  25. Additional information: The Things UNO beta, part 4.



  26. Additional information: Send data from the Things Uno Beta to The Things Network, part 5.



  27. Additional information: The node and LoRa Gateway measuring RSSI and distance, part 6.



  28. Additional information: Send humidity and temperature data from DHT11 sensor to The Things Network, part 7.



  29. Additional information: Changes made by The Things Network, part 8.