Build a LoRaWAN Gateway with Raspberry Pi: Joining The Things Network
This site's ESP32 LoRa sensor node guide covers the end device side of a LoRa network — a battery-powered sensor talking point-to-point back to a receiver. LoRaWAN is a different animal: a proper wide-area network protocol where dozens of low-power end devices report to a shared gateway, which forwards their packets to the internet over a standard network connection. A Raspberry Pi with a Semtech-based concentrator HAT makes a genuinely capable LoRaWAN gateway, and joining it to The Things Network (TTN) — a free, community-run LoRaWAN network server — gives you a real, internet-connected sensor network with essentially no ongoing cost beyond the hardware.
Gateway vs Node: What's Different
- A LoRa sensor node transmits on one frequency channel at a time and typically talks to one receiver.
- A LoRaWAN gateway uses a concentrator chip (Semtech SX1301/SX1302/SX1303 depending on the HAT) that listens to eight or more channels simultaneously, demodulating many devices' transmissions in parallel regardless of spreading factor, and forwards every valid packet to a network server over the internet. The gateway itself doesn't decrypt payloads or make routing decisions — it's a dumb, high-fidelity radio bridge; all the intelligence lives in the network server (TTN, in this case) and the application decoding the data.
Choosing the Right Frequency Plan
This is the single most important decision before ordering hardware, and it's easy to get wrong: LoRaWAN frequency plans are region-specific and not interchangeable.
RegionFrequency plan United States, CanadaUS915 European Union, UKEU868 AustraliaAU915 Most of AsiaAS923 (with country-specific sub-variants)Buy the concentrator HAT and antenna matched to your region's plan — a US915 gateway physically cannot hear an EU868 end device, and vice versa, since they use non-overlapping frequency bands.
Setting Up the Gateway OS
- Flash Raspberry Pi OS Lite (64-bit) to the SD card, enabling SSH and WiFi credentials in Raspberry Pi Imager's advanced options if not using Ethernet.
- Physically attach the concentrator HAT to the Pi's 40-pin header, and connect the antenna to the HAT's SMA connector before powering on — running a concentrator without an antenna attached can damage the RF front end.
- Boot the Pi, SSH in, and update: sudo apt update && sudo apt full-upgrade -y.
- Install the manufacturer's gateway software. RAK-based HATs ship a straightforward installer script (sudo ./install.sh from their GitHub repo) that sets up the Semtech UDP packet forwarder and a configuration menu.
- Alternatively, for a more modern and maintainable setup, flash ChirpStack Gateway OS directly to the SD card instead of Raspberry Pi OS — it's a purpose-built image with the concentrator drivers, packet forwarder, and a local web UI already integrated, and is the currently recommended path for new RAK2287/SX1302-based gateways.
Registering on The Things Network
- Create a free account at The Things Network and select the Things Stack Community Edition cluster nearest your region.
- In the console, register a new gateway, entering the Gateway EUI — a unique identifier derived from the concentrator's identity, displayed by the gateway software during setup or found via the HAT's configuration utility.
- Select the matching frequency plan (must match the hardware exactly) and confirm the gateway's approximate location for the network map.
- Configure the gateway software with TTN's server address (*.thethings.network or the region-specific endpoint shown in the console) and the generated API key or gateway ID, then restart the packet forwarder service.
- Within a minute or two of a correct configuration, the TTN console's gateway page should show "Connected" with a live traffic indicator, even with zero end devices sending data yet.
Verifying with a Test Node
The fastest way to confirm the gateway actually works is registering a LoRaWAN end device on TTN and watching its uplinks arrive in the console's Live Data view. An ESP32 with an SX1276-based LoRa module and a library like MCCI LMIC (or the newer RadioLib) configured for OTAA (Over-The-Air Activation) with a TTN-issued AppEUI/AppKey will join the network and start reporting through this gateway within range — typically several kilometers line-of-sight, or a few hundred meters to a kilometer in a suburban environment with obstructions.
Antenna Placement and Legal Limits
Gateway range depends heavily on antenna height and line of sight, far more than on the Pi or concentrator itself — a gateway mounted high (attic, roofline, or an outdoor enclosure on a mast) will dramatically outperform the same hardware sitting on a desk. Transmit power and duty cycle limits are set by regional regulation (FCC Part 15 in the US, ETSI in the EU) and are enforced by the frequency plan configuration itself in compliant gateway software — you generally can't accidentally violate them through the standard TTN setup, but modifying transmit power settings outside the provided configuration options can put you outside legal limits, particularly in the EU868 band's stricter duty-cycle rules.
Troubleshooting
SymptomLikely cause Gateway never shows "Connected" in TTN consoleWrong server address/region, firewall blocking outbound UDP, or Gateway EUI mismatch Connected but no uplinks ever arriveFrequency plan mismatch between gateway and end device, or antenna not properly connected Very short range compared to expectationsAntenna mounted low/indoors, or a suboptimal (non-matched) antenna for the frequency plan Gateway drops offline periodicallyUnstable network connection, or SD card corruption on a Pi without power-loss protection — consider PoE and a quality SD cardA single Pi-based gateway can realistically cover a whole property and, mounted well, a fair amount of surrounding area — making it a genuinely different scale of sensor network than point-to-point ESP32 LoRa links, at a total hardware cost well under most commercial LoRaWAN gateways.
Related Guides
- ESP32 LoRaWAN and The Things Network: OTAA Join, Payload Decoding, and Downlinks
- How to Install Klipper on Any 3D Printer: Complete Setup Guide
- How to Set Up OpenCV Machine Vision on a Raspberry Pi
- Raspberry Pi: Complete Headless Setup Guide (No Monitor Needed)
- Raspberry Pi: Headless OS Setup
- How to Set Up a Raspberry Pi Headless with SSH and WiFi
- How to Install and Configure Pi-hole on Raspberry Pi
- How to Control GPIO Pins on Raspberry Pi with Python