Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Raspberry Pi

Raspberry Pi LoRa Gateway: Build Long-Range IoT Network

Raspberry Pi LoRa Gateway: Build Long-Range IoT Network

March 11, 2026 /Posted byJayesh Jain / 0

LoRa (Long Range) radio technology enables IoT sensors to communicate over distances of 2–15 km on battery power that lasts for years. A Raspberry Pi with a LoRa HAT can act as a full LoRaWAN gateway, bridging dozens of remote sensor nodes to the internet via TheThingsNetwork (TTN) or a private MQTT broker. This tutorial shows you how to build, configure, and deploy a production-quality LoRa IoT gateway from scratch.

Whether you are monitoring soil moisture across a farm, tracking assets in a warehouse, or collecting environmental data from a remote station, a Pi-based LoRa gateway gives you wide-area wireless coverage at a fraction of the cost of cellular IoT.

Table of Contents

  1. LoRa vs LoRaWAN Explained
  2. Gateway Hardware Setup
  3. Installing the LoRa Packet Forwarder
  4. Registering on TheThingsNetwork
  5. Setting Up LoRa End Nodes
  6. Sensor Data Pipeline: MQTT to Dashboard
  7. Range Optimisation and Antenna Tips
  8. Frequently Asked Questions

LoRa vs LoRaWAN Explained

These terms are often confused, but they refer to different layers of the technology stack:

  • LoRa — The physical radio modulation technique (Chirp Spread Spectrum). Developed by Semtech. Enables long-range, low-power communication. LoRa operates in ISM bands (865–867 MHz in India).
  • LoRaWAN — The MAC-layer protocol built on top of LoRa. Defines how end nodes join a network, how uplink/downlink messages are formatted, and how gateways connect to a Network Server (like TTN).
  • Gateway — A device that receives LoRa radio packets from end nodes and forwards them to the Network Server over the internet (Ethernet or Wi-Fi). One gateway can serve hundreds of end nodes simultaneously.
  • End Node — A small, battery-powered sensor device that periodically transmits LoRa packets. Examples: a soil moisture sensor, a GPS tracker, a temperature logger.

In India, LoRa operates in the 865–867 MHz band (IN865 plan). Make sure your hardware and software configuration uses these frequencies to comply with WPC regulations.

Gateway Hardware Setup

You need three things for the gateway: a Raspberry Pi, a LoRa concentrator HAT, and an antenna.

Recommended Gateway Hardware

  • Raspberry Pi 4B or Pi 5 — the gateway software is lightweight; even 2 GB RAM is sufficient
  • RAK2245 Pi HAT or Dragino PG1301 — 8-channel SX1301/SX1303-based concentrators
  • 868 MHz/865 MHz antenna — fiberglass omnidirectional, 3 dBi minimum
  • Pigtail SMA connector — to connect HAT u.FL to external antenna
  • Weatherproof enclosure — for outdoor deployment

The concentrator chip (SX1301 or SX1303) is what distinguishes a real gateway from a single-channel “gateway” — it can listen on 8 channels simultaneously, dramatically increasing capacity and reliability.

Recommended: Raspberry Pi 5 Model 4GB RAM — The Pi 5 makes an excellent LoRa gateway base board. Its improved PCIe interface, faster boot, and lower power draw at idle compared to Pi 4 mean lower electricity costs for a permanently-powered outdoor gateway. The 4GB RAM handles even advanced use cases like local Node-RED dashboards running alongside the packet forwarder.

Assembly

  1. Stack the LoRa HAT on the Pi’s 40-pin GPIO header
  2. Connect the antenna via pigtail to the HAT’s u.FL connector
  3. Never power on without antenna connected — the RF amplifier can be damaged by the reflected power
  4. Flash Raspberry Pi OS Lite (64-bit) for minimal overhead

Installing the LoRa Packet Forwarder

The packet forwarder is the software that reads LoRa packets from the concentrator chip and forwards them to a Network Server over UDP. We’ll use the Semtech UDP Packet Forwarder, the de facto standard for LoRaWAN gateways.

Enable SPI

sudo raspi-config
# Interface Options → SPI → Enable
sudo reboot

Install Dependencies

sudo apt update
sudo apt install -y git build-essential libssl-dev

Clone and Build the Packet Forwarder

# Clone RAK's modified forwarder for Pi HAT
git clone https://github.com/RAKWireless/RAK2245-RAK831-LoRaGateway-RPi-Raspbian-OS.git
cd RAK2245-RAK831-LoRaGateway-RPi-Raspbian-OS
sudo chmod +x install.sh
sudo ./install.sh

For other concentrators, use the appropriate chipset-specific forwarder. The SX1303-based boards use the newer sx1302_hal library:

git clone https://github.com/Lora-net/sx1302_hal.git
cd sx1302_hal
make

Configure global_conf.json

The gateway configuration file lives at /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf.json. Set the correct frequency plan and your TTN server address:

{
  "SX1301_conf": {
    "lorawan_public": true,
    "clksrc": 1,
    "chan_multiSF_0": {"enable": true, "radio": 0, "if": -400000},
    "chan_multiSF_1": {"enable": true, "radio": 0, "if": -200000},
    "chan_multiSF_2": {"enable": true, "radio": 0, "if":       0},
    "chan_multiSF_3": {"enable": true, "radio": 0, "if":  200000},
    "chan_multiSF_4": {"enable": true, "radio": 1, "if": -300000},
    "chan_multiSF_5": {"enable": true, "radio": 1, "if": -100000},
    "chan_multiSF_6": {"enable": true, "radio": 1, "if":  100000},
    "chan_multiSF_7": {"enable": true, "radio": 1, "if":  300000}
  },
  "gateway_conf": {
    "gateway_ID": "AA555A0000000000",
    "server_address": "au1.cloud.thethings.network",
    "serv_port_up": 1700,
    "serv_port_down": 1700,
    "keepalive_interval": 10,
    "stat_interval": 30,
    "push_timeout_ms": 100,
    "forward_crc_valid": true,
    "forward_crc_error": false,
    "forward_crc_disabled": false
  }
}

Replace gateway_ID with your gateway’s EUI (derived from Ethernet MAC: ip link show eth0 | awk '/ether/{print $2}' | sed 's/://g' → insert FFFE at position 6).

For India, set radio frequencies to IN865: radio_0 at 865.0625 MHz, radio_1 at 865.9625 MHz.

Registering on TheThingsNetwork

TheThingsNetwork (TTN) V3 (now called The Things Stack) is the most popular free LoRaWAN network server.

  1. Sign up at thethingsnetwork.org
  2. Go to Console → Gateways → Register Gateway
  3. Enter your Gateway EUI (same as gateway_ID in config)
  4. Select frequency plan: India 865-867 MHz (IN865)
  5. Select cluster: au1.cloud.thethings.network (closest to India)
  6. Click Register Gateway

Once the packet forwarder is running, your gateway appears as Connected (green dot) in the TTN console within 30 seconds.

Recommended: Raspberry Pi 5 Model 16GB RAM — If you plan to run a private LoRaWAN Network Server (ChirpStack) alongside the packet forwarder on the same Pi, the 16GB model gives you plenty of headroom. ChirpStack requires PostgreSQL and Redis, which benefit from extra memory for query caching.

Setting Up LoRa End Nodes

An end node is a microcontroller + LoRa module combination that periodically sends sensor readings. Popular choices in India:

  • Arduino Nano + RFM95W module — affordable, uses LMIC library
  • STM32WL (Nucleo-WL55JC) — built-in LoRa transceiver, ultra-low-power
  • Heltec WiFi LoRa 32 V3 — ESP32 + LoRa, Arduino IDE compatible
  • RAK4631 — nRF52840 + LoRa, excellent power management

OTAA Join (Over-the-Air Activation)

In TTN console, go to Applications → Add Application → Add End Device. Select your device type and note the DevEUI, AppEUI, and AppKey. Enter these in your Arduino sketch:

// LMIC library sketch for IN865
#include 
#include 
#include 

static const u1_t PROGMEM APPEUI[8]  = { /* LSB first */ };
static const u1_t PROGMEM DEVEUI[8]  = { /* LSB first */ };
static const u1_t PROGMEM APPKEY[16] = { /* MSB first */ };

void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8); }
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8); }
void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16); }

Once joined, the node sends temperature/humidity readings uplink every 10 minutes — ideal for battery-powered deployments where Class A LoRaWAN’s 1–10 µA sleep current extends battery life to years.

Recommended: DHT20 SIP Packaged Temperature and Humidity Sensor — The DHT20’s I2C interface and improved accuracy (±0.3°C, ±3% RH) make it an excellent sensor payload for LoRa end nodes. Its SIP package is compact enough to fit inside a small waterproof enclosure for outdoor deployments.

Sensor Data Pipeline: MQTT to Dashboard

TTN delivers decoded payload data to your application via MQTT, webhooks, or direct API. The MQTT integration is the most flexible for custom dashboards.

TTN MQTT Setup

# Install Mosquitto MQTT client
sudo apt install -y mosquitto-clients

# Subscribe to all uplink messages from your application
mosquitto_sub 
  -h au1.cloud.thethings.network 
  -p 8883 
  --capath /etc/ssl/certs/ 
  -u "YOUR-APP-ID@ttn" 
  -P "YOUR-API-KEY" 
  -t "v3/YOUR-APP-ID@ttn/devices/+/up"

Node-RED Dashboard

Install Node-RED on the Pi for a visual dashboard with zero frontend code:

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
sudo systemctl enable nodered.service
sudo systemctl start nodered.service

In Node-RED, use the node-red-contrib-ttn package to connect directly to TTN and visualise sensor data on a dashboard — temperature graphs, humidity gauges, GPS map for trackers.

InfluxDB + Grafana (Production Stack)

For a production installation with historical data retention and professional charts:

# Install InfluxDB 2.x
curl https://repos.influxdata.com/influxdata-archive.key | gpg --dearmor > /etc/apt/trusted.gpg.d/influxdata.gpg
echo 'deb https://repos.influxdata.com/debian stable main' > /etc/apt/sources.list.d/influxdata.list
sudo apt update && sudo apt install influxdb2

# Grafana
sudo apt install -y grafana
sudo systemctl enable grafana-server && sudo systemctl start grafana-server

Range Optimisation and Antenna Tips

LoRa range is dramatically affected by antenna placement, obstacles, and spreading factor (SF) settings.

Spreading Factor vs Data Rate Trade-off

SF Data Rate Range Time on Air
SF7 5.5 kbps ~2 km urban 56 ms (10B)
SF9 1.37 kbps ~5 km 226 ms
SF12 0.25 kbps ~15 km rural 1.98 s

Use Adaptive Data Rate (ADR) in TTN — the network automatically selects the optimal SF for each end node based on observed SNR.

Gateway Placement

  • Mount the gateway as high as possible — rooftop mounting increases range 3–5×
  • Use a quality N-type fiberglass antenna (3–6 dBi gain)
  • Keep coaxial cable runs short — every 3 dB of cable loss halves effective range
  • Avoid metal enclosures around the antenna

Frequently Asked Questions

Is LoRa legal to use in India?

Yes. LoRa operates in the 865–867 MHz ISM band in India, which is unlicensed for short-range devices under WPC (Wireless Planning and Coordination Wing) regulations. No license is needed for personal or commercial IoT deployments using compliant hardware at the allowed power levels (up to 1W ERP).

How many end nodes can one Raspberry Pi gateway support?

An 8-channel LoRaWAN gateway can theoretically handle thousands of end nodes, since each transmission is very short (56 ms to 2 s). In practice, capacity depends on how frequently nodes transmit. With Class A nodes sending every 10 minutes, a single gateway comfortably supports 500–1000 devices. TTN also enforces a 1% duty cycle per node, which naturally limits channel congestion.

What is the maximum range achievable with a Pi LoRa gateway?

In line-of-sight rural conditions with a good rooftop antenna, 10–15 km is achievable at SF12. In urban India, expect 1–3 km due to buildings and interference. The world record for LoRa range (using a balloon) is over 700 km, demonstrating the technology’s theoretical ceiling under ideal conditions.

Can I build a private LoRaWAN network without TheThingsNetwork?

Yes. ChirpStack is an open-source LoRaWAN Network Server that runs entirely on-premise. Install it on the same Pi as the packet forwarder (for small deployments) or on a dedicated server. ChirpStack gives you full control over data routing, device management, and integrations, with no dependency on TTN’s cloud infrastructure.

How long does a battery-powered LoRa end node last?

A properly configured Class A node (sleep between transmissions) with two AA batteries can last 2–5 years sending one packet every 15 minutes at SF9. The key is minimising radio-on time and using a microcontroller with deep sleep (like STM32WL or SAMD21 with sleep current under 5 µA).

Ready to build your IoT network? Zbotic.in stocks Raspberry Pi boards, sensors, and accessories to get your LoRa gateway project off the ground. Explore the full Raspberry Pi and IoT collection at Zbotic.in.

Tags: gateway, iot, long-range, LoRa, LoRaWAN, Raspberry Pi, sensor network, TheThingsNetwork
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
RetroPie Setup Guide: Turn Ras...
blog retropie setup guide turn raspberry pi into a retro gaming console 595132
blog attiny85 pinout programming projects complete guide 595137
ATtiny85 Pinout, Programming &...

Related posts

Svg%3E
Read more

Raspberry Pi Benchmarks: Performance Testing All Models

April 1, 2026 0
Table of Contents Introduction and Use Cases Hardware Requirements Software Installation Configuration and Setup Testing and Validation Advanced Features Troubleshooting... Continue reading
Svg%3E
Read more

Raspberry Pi PoE: Power Over Ethernet Setup Guide

April 1, 2026 0
Table of Contents Introduction and Use Cases Hardware Requirements Software Installation Configuration and Setup Testing and Validation Advanced Features Troubleshooting... Continue reading
Svg%3E
Read more

Raspberry Pi GSM HAT: SMS and Cellular IoT

April 1, 2026 0
Table of Contents Introduction and Use Cases Hardware Requirements Software Installation Configuration and Setup Testing and Validation Advanced Features Troubleshooting... Continue reading
Svg%3E
Read more

Raspberry Pi RS485: Industrial Sensor Network

April 1, 2026 0
Table of Contents Introduction and Use Cases Hardware Requirements Software Installation Configuration and Setup Testing and Validation Advanced Features Troubleshooting... Continue reading
Svg%3E
Read more

Raspberry Pi CAN Bus: Vehicle OBD2 Data Reader

April 1, 2026 0
Table of Contents Introduction and Use Cases Hardware Requirements Software Installation Configuration and Setup Testing and Validation Advanced Features Troubleshooting... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now