RAK5146 Modul und Pi-HAT-Trägerplatine für ein Raspberry Pi LoRaWAN-Gateway auf einer grauen Werkbankmatte

Raspberry Pi LoRaWAN Gateway: How Do You Build One With the RAK5146 Pi HAT?

You have a handful of LoRaWAN sensors, no public gateway reaches your basement or your property, and there is a spare Raspberry Pi 4 in a drawer. The short answer: with the RAK5146 Pi HAT, that Raspberry Pi becomes a full eight-channel LoRaWAN gateway that connects to The Things Network or to your own ChirpStack server. You plug the concentrator card into the carrier board, seat the board on the 40-pin header, attach the antenna and install gateway software. If you stick to a supported setup, a working Raspberry Pi LoRaWAN gateway is an afternoon project.

The assembly is rarely the hard part. The decisions before it are: SPI or USB, which Pi generation, which software, and which protocol to the network server. Follow a guide written for the wrong variant and you can spend hours chasing what looks like a hardware fault but is really a configuration mismatch.

RAK5146 card and Pi HAT carrier board for a Raspberry Pi LoRaWAN gateway on a gray workbench mat
The mini PCIe concentrator card and the Pi HAT carrier board before assembly. For a DIY build, the Raspberry Pi, power supply and memory card come separately.

What is a Raspberry Pi LoRaWAN HAT?

HAT stands for “Hardware Attached on Top”: an add-on board that plugs straight onto the Raspberry Pi’s 40-pin header and takes power, GPIOs and interfaces such as SPI from it. Two very different kinds of boards are sold under that name, and this is where most wrong purchases happen.

The first kind carries a single LoRa transceiver, typically an SX1262 or SX1276. That lets the Pi act as an end device or as a so-called single-channel gateway. A single-channel setup only listens on one channel and one spreading factor at a time, while your sensors hop across several channels. Most packets simply never arrive, and The Things Network explicitly discourages connecting such setups to its network.

The second kind carries a gateway concentrator. The RAK5146 is built around the Semtech SX1303 baseband processor, which according to RAKwireless watches eight channels, decodes spreading factors from SF5 to SF12 in parallel and can demodulate up to 16 packets at the same time. That is the radio architecture of commercial gateways, and it turns a Raspberry Pi into a real LoRaWAN gateway that the network server treats like any other. How a concentrator module works internally is a topic of its own; for a DIY build, all you need to know is that you need one.

What’s in the RAK5146 Pi HAT kit?

The kit covered here is the EU868 version with an SPI interface and no GPS (RAKwireless SKU 815024). The box contains four items:

  • 1× RAK5146 concentrator card, SPI version, EU868, mini PCIe form factor
  • 1× RAK5146/RAK2287 Pi HAT, the carrier board with a mini PCIe slot and a 40-pin socket
  • 1× LoRa antenna with an MHF connector
  • 1× set of standoffs and nuts

It does not include a Raspberry Pi, power supply, microSD card or enclosure. That is the point of a kit like this rather than a gap: you pick the host yourself and decide how the finished build gets packaged.

According to the datasheet, the RAK5146 transmits at up to 27 dBm and reaches a receive sensitivity of −139 dBm at SF12 with 125 kHz bandwidth. The 27 dBm figure is the module’s hardware ceiling; in Europe, the gateway software caps transmit power at what the EU868 band allows. Sensitivity matters more for coverage anyway, because a gateway spends almost all its time listening and only transmits for acknowledgments and downlinks.

“No GPS” means there is no GNSS receiver on this card. For normal operation with Class A sensors, you don’t need one. GPS only becomes relevant if you want to run Class B devices with scheduled receive windows or locate transmitters using precise timestamps. Without it, you simply enter the gateway’s location by hand in the network server console.

What else do you need to build a LoRaWAN gateway?

Besides the kit and the Pi, you need four more things, and each of them causes more failed DIY gateways than the radio itself.

First, a proper power supply. For a Raspberry Pi 4, the official 5.1 V, 3 A USB-C supply is the safe choice; for a Pi 3B+, use a 5.1 V, 2.5 A micro USB supply. The concentrator draws from the same supply through the HAT. An old phone charger often sags under load; the Pi then reports undervoltage and the concentrator drops out now and then, which shows up in the logs looking like a software bug.

Second, a name-brand microSD card of at least 16 GB, ideally one rated for continuous use. A gateway writes logs around the clock, and cheap cards tend to give up after a few months. An image that keeps logs in RAM extends card life considerably.

Third, a network connection. Ethernet is the most robust option, though Wi-Fi works fine for an indoor gateway. What matters is that no firewall blocks outgoing connections to the network server.

Fourth, an enclosure with room for the HAT and a clean antenna path. The MHF connector on the card is tiny and rated for only a few dozen mating cycles. If the antenna should sit outside the case, you need a short pigtail to SMA that is strain-relieved. A bare Pi build without a weatherproof enclosure is not an option outdoors.

SPI or USB: which RAK5146 version do you need?

The RAK5146 comes in several versions: SPI or USB interface, with or without GPS, some with Listen Before Talk, and for bands ranging from EU868 to US915 and AS923. The cards look almost identical, but the software treats them completely differently.

With the SPI version, the Raspberry Pi talks directly to the SX1303 over the SPI lines on the header, and a GPIO pin drives the concentrator’s reset. On a Pi HAT, that is the natural path: short traces, no extra cable and broad support in every common gateway program. The USB version instead shows up as a USB device on the host and uses a different driver path. It mainly makes sense when the host has no exposed SPI interface or when the card goes into a mini PCIe slot in a different computer.

For a Raspberry Pi with a HAT, SPI is the obvious choice, and it is the version in the kit described here. The classic mistake afterward is following a guide written for the USB version, or picking the wrong model in an installer menu. The software then looks on the wrong interface, finds nothing, and the packet forwarder quits at startup with a concentrator initialization error.

The frequency band is just as fixed. An EU868 card has filters and tuning for 863 to 870 MHz; changing a config file to US915 does not turn it into a North American gateway. EU868 is the right band for Germany and the rest of the EU.

Parts for a Raspberry Pi LoRaWAN gateway: RAK5146 card, Pi HAT board, screws and an EU868 SPI label
Band and interface are set in hardware: this kit is built for EU868 and SPI and ships with standoffs for mounting on the Pi.

Which Raspberry Pi works with the RAK5146?

In its RAK5146 quick start guide, RAKwireless names the Raspberry Pi 3B+ and the Raspberry Pi 4. Both are supported by all common gateway images. A packet forwarder uses only a few percent of the CPU and little memory, so a Pi 4 with 2 GB is more than enough for a gateway on its own. More RAM only pays off if the same device also runs a full ChirpStack network server with its database.

Be careful with the Raspberry Pi 5. It handles its GPIOs through a new peripheral chip, and that changed how the pins are numbered under Linux. As a result, older reset scripts for SX1302 and SX1303 concentrators can miss their target: the concentrator never gets reset and refuses to start. Newer software releases have partly caught up. Before you buy, check that the software you plan to use explicitly supports the Pi 5 together with an SPI concentrator. If a Pi 5 is all you have, ChirpStack Gateway OS is a good starting point, since it offers Pi 5 images.

A Pi Zero also has the 40-pin header, but it is much smaller than the HAT and on the weak side for a gateway that runs around the clock. Other single-board computers with a Pi-compatible header can work, but only if the pinout, SPI driver and reset pin match exactly what your software expects. For a first build, a Pi 3B+ or Pi 4 with an official image is the shortest route to a working gateway.

Which software runs a Raspberry Pi LoRa gateway?

A gateway needs two pieces of software: a driver for the SX1303 and a program that forwards received packets to a network server. In practice, there are three ready-made routes that bundle both.

The easiest is RAKwireless’s precompiled gateway image based on Raspberry Pi OS. You flash it to the microSD card with a tool such as balenaEtcher, boot the Pi and configure everything from the sudo gateway-config menu: choose the network server, choose the frequency plan, done. sudo gateway-version shows you the gateway EUI.

The second route is a fresh Raspberry Pi OS Lite install where you set things up yourself. You first enable SPI with raspi-config, then install either the Semtech packet forwarder from the sx1302_hal package or LoRa Basics Station. It takes more work but gives you full control.

The third route is ChirpStack Gateway OS, a lean system based on OpenWrt. Its ChirpStack Concentratord component supports the RAK5146 for EU868 as the model “rak_5146.” In the web interface, you pick the chipset, model and channel plan, then forward data either over MQTT to a ChirpStack server or through the UDP forwarder to another network server. The “Full” image even runs a complete ChirpStack network server on the Pi itself, which is handy for a test lab without the cloud.

Whichever image you use, you also pick a protocol to the server. The classic Semtech UDP protocol is simple but sends data unencrypted and without authentication. Basic Station opens a TLS-secured WebSocket connection and authenticates the gateway with a key. For a new installation on The Things Network, Basic Station is the cleaner choice; UDP remains the quick option for testing and for servers that speak nothing else.

How do you connect a Raspberry Pi gateway to The Things Network?

Connecting to The Things Network takes three steps: find the gateway EUI, register the gateway in the console, and point the software at the right server.

The gateway EUI is your gateway’s 64-bit identifier. The images display it, and it is usually derived from the Ethernet MAC address by inserting FFFE in the middle. Copy it exactly, because a single swapped character is the most common reason a gateway never shows up as connected.

In The Things Stack console, choose the European cluster eu1, add a new gateway, enter the EUI and select the frequency plan “Europe 863-870 MHz (SF9 for RX2 – recommended).” That plan has to match what you configured on the gateway.

If you use UDP, set the server address on the gateway to eu1.cloud.thethings.network with port 1700 for both uplink and downlink. With Basic Station, the address is wss://eu1.cloud.thethings.network:8887. You also create an API key in the console with the right to write uplinks and read downlinks and store it on the gateway. Copy the key right away; the console only shows it once.

Within minutes, the console shows the gateway as “Connected,” and packets from a nearby sensor appear under Live Data. If the status stays “Disconnected,” check the EUI, the cluster and outbound firewall ports in that order, and only then look at the radio side.

Raspberry Pi vs ready-made LoRaWAN gateway: which is better?

On the radio side, both perform the same, because a DIY gateway with the RAK5146 uses the same SX1303 concentrator as many off-the-shelf units. The difference lies in everything around it. The table shows where the two approaches part ways.

Criterion Raspberry Pi with RAK5146 Pi HAT Ready-made LoRaWAN gateway
Setup Assemble it yourself, pick and configure an image Unbox, connect, set up in the web interface
Enclosure and mounting Your job, involved for outdoor use Indoor or weatherproof outdoor housings from the factory
Software Your choice, full access to the Linux system Vendor firmware, open or closed depending on the model
Power The Pi’s USB power supply Often PoE or 12 V, some with surge protection
Maintenance OS, memory card and updates are on you Firmware updates from the vendor
Typical use Lab, prototype, learning project, your own ChirpStack server Continuous operation, outdoor sites, customer installations

The pattern is clear: the Raspberry Pi wins on flexibility and learning, the ready-made gateway on ruggedness and maintenance effort. If you want to understand what a gateway does internally, try different software or run ChirpStack locally, the DIY build is ideal.

For installations that should run for years without anyone touching them, hang outdoors or operate at customer sites, a ready-made unit is usually the better choice. Its enclosure, power supply and firmware have already been tested and certified as one device; with a DIY build, you are the integrator. Cost-wise, the kit, Pi, power supply, card and enclosure together often land in the same range as an entry-level indoor gateway, so a DIY build is rarely just a way to save money.

Where can you buy a Raspberry Pi LoRaWAN HAT?

Before you order, run through the key points once more. First, make sure the HAT carries a real gateway concentrator such as the SX1303 rather than a single LoRa transceiver, because only then does it receive on eight channels in parallel. Next, check the band: for Germany and the EU it has to be EU868, and you cannot switch it in software. For the interface, SPI is the simplest path on a Pi HAT; a USB version needs a different configuration. You only need GPS for Class B or timestamp-based location. Pick a Raspberry Pi that your software explicitly supports, with a Pi 3B+ or Pi 4 as the safest bet, and plan for the power supply, microSD card and enclosure from the start.

If you’re putting together the parts for your Raspberry Pi LoRaWAN gateway, you’ll find the RAK5146 Pi HAT kit and other gateway concentrators in our RF modules category.

Our latest news

Scroll to top