0
0
Drone-programmingHow-ToBeginner · 4 min read

How to Set Up a LoRaWAN Gateway: Step-by-Step Guide

To set up a LoRaWAN gateway, first connect the gateway hardware to the internet and power it on. Then configure the gateway software with your network server details using the packet_forwarder configuration files. Finally, register the gateway on a LoRaWAN network server to start receiving sensor data.
📐

Syntax

Setting up a LoRaWAN gateway involves configuring the packet_forwarder software which forwards LoRa packets to the network server. The main configuration file is global_conf.json, where you specify:

  • Gateway ID: Unique identifier for your gateway.
  • Server address: IP or hostname of the LoRaWAN network server.
  • Ports: UDP ports for uplink and downlink communication.
  • Frequency plan: Defines the radio frequencies your gateway listens on.
json
{
  "gateway_conf": {
    "gateway_ID": "AA555A0000000000",
    "server_address": "router.eu.thethings.network",
    "serv_port_up": 1700,
    "serv_port_down": 1700,
    "radio_0": {
      "frequency": 868100000,
      "bandwidth": 125000,
      "spreading_factor": 7
    }
  }
}
💻

Example

This example shows how to configure and start the packet_forwarder on a Raspberry Pi-based LoRaWAN gateway connected to The Things Network (TTN).

bash
# Install dependencies
sudo apt update && sudo apt install git build-essential libusb-1.0-0-dev -y

# Clone packet forwarder repository
git clone https://github.com/Lora-net/packet_forwarder.git
cd packet_forwarder

# Build the packet forwarder
make

# Edit global_conf.json to set your gateway ID and TTN server
nano global_conf.json

# Start the packet forwarder
./lora_pkt_fwd
Output
INFO: Starting packet forwarder INFO: Gateway ID: AA555A0000000000 INFO: Server: router.eu.thethings.network:1700 INFO: Radio configured on 868.1 MHz INFO: Packet forwarder running...
⚠️

Common Pitfalls

Common mistakes when setting up a LoRaWAN gateway include:

  • Incorrect Gateway ID: Must be unique and match the registered ID on the network server.
  • Wrong server address or ports: Using incorrect network server details prevents packet forwarding.
  • Frequency mismatch: Using a frequency plan not supported in your region causes no data reception.
  • Firewall blocking UDP ports: Ensure ports 1700 (default) are open for UDP traffic.
json
Wrong configuration example:
{
  "gateway_conf": {
    "gateway_ID": "AA555A0000000000",
    "server_address": "wrong.server.address",
    "serv_port_up": 1700,
    "serv_port_down": 1700
  }
}

Correct configuration example:
{
  "gateway_conf": {
    "gateway_ID": "AA555A0000000000",
    "server_address": "router.eu.thethings.network",
    "serv_port_up": 1700,
    "serv_port_down": 1700
  }
}
📊

Quick Reference

StepDescription
1Connect gateway hardware to power and internet.
2Install and configure packet_forwarder software.
3Set gateway ID and network server in global_conf.json.
4Open UDP ports 1700 on your firewall/router.
5Register gateway on LoRaWAN network server (e.g., TTN).
6Start packet_forwarder to begin forwarding packets.

Key Takeaways

Always use a unique gateway ID matching your network server registration.
Configure the correct server address and UDP ports in packet_forwarder.
Ensure your gateway uses the correct frequency plan for your region.
Open necessary UDP ports (usually 1700) on your network firewall.
Register your gateway on a LoRaWAN network server to receive data.