Skip to content

Build a Raspberry Pi LoRaWAN Gateway with ChirpStack

LoRa provides a long-range low-bit-rate radio link; LoRaWAN adds device identities, encryption, gateways, network servers, and managed uplink/downlink scheduling. A single-channel LoRa transceiver is not a standards-compliant multi-channel LoRaWAN gateway. Use an SX1302/SX1303 concentrator designed for your legal frequency region.

Architecture

flowchart LR N[Battery sensor node] -->|LoRaWAN uplink| G[Raspberry Pi + SX1302 gateway] G -->|MQTT over TLS| C[ChirpStack network server] C --> A[Application integration] A --> D[Dashboard or database]

ChirpStack Gateway OS is the shortest reproducible route because it supports Raspberry Pi gateway hardware in two variants:

  • Base: gateway software forwarding to an external ChirpStack server.
  • Full: gateway plus a local ChirpStack network server.

See the official ChirpStack Raspberry Pi quickstart.

Hardware Checklist

  • Raspberry Pi model supported by the selected ChirpStack Gateway OS image
  • SX1302/SX1303 concentrator HAT or mPCIe module with a compatible carrier
  • Antenna tuned for the purchased frequency band
  • Reliable power supply and microSD card
  • Outdoor-rated enclosure, lightning protection, and grounding when installed outside
  • Separate LoRaWAN end device for validation

Never transmit without the correct antenna

Attach the antenna before powering the concentrator. Use only the frequency plan permitted in your country. EU868, US915, AU915, AS923, and other plans are not interchangeable.

LoRa vs LoRaWAN Hardware

Device Channels Suitable as gateway? Typical role
SX1262/SX127x transceiver One channel at a time No Sensor node or point-to-point radio
SX1302/SX1303 concentrator Multi-channel Yes LoRaWAN gateway
Commercial Basics Station gateway Multi-channel Yes Managed production gateway

Do not advertise a cheap single-channel receiver as a gateway benchmark. It cannot listen to the normal combination of LoRaWAN channels and spreading factors.

Install ChirpStack Gateway OS

  1. Download the current image matching the Raspberry Pi and concentrator from ChirpStack.
  2. Verify the published checksum.
  3. Write it with Raspberry Pi Imager.
  4. With power disconnected, seat the concentrator and attach the correct antenna.
  5. Boot, connect through Ethernet for the first setup, and open the documented gateway configuration interface.
  6. Select the exact concentrator model and regional frequency plan.

Use the Full image for a self-contained lab. Use Base when an existing ChirpStack deployment already provides MQTT, the Gateway Bridge, and network services.

Register the Gateway

Record the gateway ID/EUI shown by the concentrator software. In ChirpStack:

  1. Create or select a tenant.
  2. Add a gateway using the exact ID.
  3. Select the same region configured on the gateway.
  4. Confirm that the last-seen time and packet counters update.

For remote deployments, prefer an on-gateway MQTT forwarder with per-gateway credentials and TLS. ChirpStack explains that MQTT over TCP adds authentication and encryption compared with an unauthenticated Semtech UDP connection in its Gateway Bridge deployment guide.

Register an End Device with OTAA

Create a device profile matching the regional parameters and LoRaWAN MAC version, then register:

  • DevEUI: unique device identifier
  • JoinEUI: join-server/application identifier
  • AppKey: secret root key

Use Over-the-Air Activation (OTAA) for normal deployments. Keep AppKey out of screenshots, source repositories, and dashboards. Reset the device and look for:

  1. join request received by the gateway
  2. join accept scheduled
  3. device session created
  4. application uplink decoded

If uplinks appear but joins fail, check regional plan, RX1/RX2 parameters, DevEUI byte order, JoinEUI, AppKey, and gateway downlink capability.

Decode and Forward Sensor Data

Keep radio payloads compact. For example, encode temperature as a signed 16-bit integer in hundredths of a degree instead of sending JSON over LoRaWAN. Decode it at the application layer, then forward normalized JSON over MQTT or HTTP.

Example decoded application record:

1
2
3
4
5
6
{
  "device_id": "garden-sensor-01",
  "temperature_c": 18.42,
  "battery_v": 3.71,
  "frame_counter": 384
}

Validate frame counters and reject duplicated application events before writing a database.

Secure the Gateway

  • Change all default passwords.
  • Restrict the administration interface to a management network or VPN.
  • Use unique MQTT credentials and TLS.
  • Back up ChirpStack configuration, database, device keys, and gateway IDs.
  • Disable unused services and keep Gateway OS updated.
  • Rate-limit dashboard logins and monitor repeated reconnects.
  • Never expose the legacy UDP packet-forwarder port broadly to the internet.

Measure Range Reproducibly

“15km range” is not a useful result without radio context. Record:

  • country and frequency plan
  • antenna model, gain, cable loss, height, and orientation at both ends
  • transmit power and spreading factor/data rate
  • bandwidth and coding rate
  • terrain, line of sight, weather, and gateway location class
  • packet interval, sample count, packet-delivery ratio
  • RSSI and SNR percentiles, not only the best packet
  • node energy per transmission and sleep current

Use a fixed route and send at least 100 sequence-numbered packets per test point. Calculate packet-delivery ratio from unique sequence numbers. Follow local duty-cycle and transmit-power rules; a benchmark does not exempt radio operation from regulation.

Troubleshooting

Gateway is registered but never seen

Check time synchronization, DNS, region, gateway ID, MQTT/UDP endpoint, credentials, and outbound firewall access. Inspect the concentrator and forwarder logs.

The concentrator is not detected

Power down and reseat it. Confirm the hardware variant, SPI/USB connection, reset GPIO, power requirement, and the exact ChirpStack profile selected.

Verify antenna, region, RX1/RX2 configuration, gateway time source, downlink scheduler logs, and duty-cycle limits. Legacy UDP forwarding across a high-latency link can also lose scheduled downlinks.

Range is much shorter than expected

Check antenna band, connector seating, feed-line loss, enclosure effects, placement near metal, spreading factor, and noise floor. Never increase transmit power beyond regional limits.

FAQ

Can Pico 2 W be a LoRaWAN gateway?

It can be a sensor node when paired with a LoRa transceiver, but it does not replace a multi-channel SX1302/SX1303 gateway concentrator.

Should the network server run on the same Pi?

The Full image is convenient for a small private lab. Separate the gateway and network server for larger installations, redundancy, or easier upgrades.

Does LoRaWAN require internet access?

No. A private gateway and local ChirpStack server can operate on a LAN, although accurate time, backups, monitoring, and remote management still need planning.