LoRa Smart Agriculture: Soil Sensor Data over 5km Range India
India’s agriculture sector is undergoing a quiet digital revolution, and LoRa smart agriculture for soil sensor monitoring is at its heart. Covering vast farm fields with WiFi or cellular connectivity is expensive and power-hungry — but LoRa (Long Range) wireless technology can transmit soil moisture, temperature, and NPK sensor data over 5 kilometres on a single 18650 battery charge lasting weeks. This complete project guide shows Indian farmers and electronics hobbyists how to build a LoRa-based soil monitoring system using the Ai Thinker Ra-01 module, an Arduino/ESP32 node, and a gateway that uploads data to a dashboard.
Why LoRa is Ideal for Indian Farming
Traditional precision agriculture solutions from multinational companies cost lakhs of rupees per installation — completely out of reach for small and medium Indian farmers owning 1–5 acres. LoRa changes the economics dramatically:
- Range: 2–5 km in open agricultural terrain, up to 10 km with elevated antenna
- Power: A sensor node running at 1% duty cycle lasts 1–2 years on two AA batteries
- Cost: A complete LoRa sensor node costs under ₹800 in components from Zbotic
- No SIM card required: Unlike GSM/4G solutions, LoRa uses license-free 865–867 MHz band (India’s allocated ISM band)
- Penetration: LoRa signals pass through buildings, trees, and crop canopy with minimal attenuation
In states like Maharashtra, Punjab, Karnataka, and Andhra Pradesh where farms are geographically spread, a single LoRa gateway mounted on a water tank or electricity pole can cover an entire village’s worth of fields. India’s TRAI allocated the 865–867 MHz band for LoRa/ISM use, so you can legally operate without a licence at up to 1W ERP.
System Architecture Overview
A typical LoRa smart agriculture system has three layers:
- End Nodes (Sensor Nodes): Battery-powered Arduino/ESP32 + LoRa module + soil sensors. These transmit packets every 15–60 minutes and sleep the rest of the time.
- Gateway: An always-on ESP32 + LoRa module connected to WiFi or 4G. It receives packets from all nodes and forwards data to the cloud.
- Cloud Dashboard: ThingSpeak (free for non-commercial), Cayenne, or a self-hosted Grafana instance. Farmers access data via mobile app or WhatsApp alerts.
For a small farm, you can also run a standalone system without the cloud: the gateway stores data on an SD card and serves a local WiFi dashboard accessible from a mobile phone within 30m of the gateway.
Ai Thinker LoRa Ra-01H Module
The Ra-01H operates in the 803–930 MHz band and is based on the SX1276 chip. Perfect for long-range soil sensor nodes in Indian agricultural fields — up to 5km range outdoors.
Choosing the Right LoRa Module
The Ai Thinker Ra-01 series is the most popular choice for Indian makers due to availability and price. Here is a comparison of the models available at Zbotic:
| Module | Chip | Frequency | India Use |
|---|---|---|---|
| Ra-01H | SX1276 | 803–930 MHz | Best — covers 865 MHz ISM |
| Ra-01SC | SX1262 | 860–930 MHz | Excellent — newer chip, lower power |
| Ra-01SH | SX1262 | 803–930 MHz | Excellent — widest band |
For agriculture in India, use 865 MHz (India’s LoRa ISM band). The Ra-01H is the most commonly stocked and has extensive library support with the RadioLib and LoRa.h Arduino libraries.
Ai Thinker LoRa Ra-01SC Module (SX1262)
The newer SX1262-based Ra-01SC offers lower power consumption and better sensitivity than SX1276. Ideal for battery-powered agricultural sensor nodes requiring months of operation.
Building the Soil Sensor Node
The sensor node is the heart of the system. It reads soil data, packages it into a LoRa packet, transmits it, and immediately returns to deep sleep to conserve battery.
Components for one sensor node
- Arduino Pro Mini 3.3V / 8 MHz (or ESP32 with deep sleep)
- Ai Thinker Ra-01H LoRa module
- Capacitive soil moisture sensor (YL-69 or v1.2 capacitive type)
- DS18B20 waterproof temperature sensor (for soil temperature)
- 18650 LiPo battery + TP4056 charger module
- Mini solar panel (5V 1W) for self-recharging
Wiring Ra-01H to Arduino Pro Mini
| Ra-01H Pin | Arduino Pro Mini | Notes |
|---|---|---|
| VCC | 3.3V | 3.3V ONLY — 5V will damage module |
| GND | GND | |
| SCK | D13 | SPI Clock |
| MISO | D12 | SPI MISO |
| MOSI | D11 | SPI MOSI |
| NSS/CS | D10 | Chip Select |
| DIO0/RST | D9/D8 | Interrupt/Reset |
Setting Up the LoRa Gateway
The gateway runs continuously (powered by 5V adapter or solar + battery bank) and listens for LoRa packets from all nodes. An ESP32-based gateway can simultaneously handle LoRa reception and WiFi/4G cloud uploads.
For areas without WiFi, attach a SIM800L or SIM7600 GSM module to the gateway ESP32 and upload data over mobile data. Jio and Airtel 2G/4G coverage is excellent in most Indian rural areas, making this a robust fallback.
Ai Thinker LoRa Ra-01SH – Spread Spectrum Module
The Ra-01SH covers 803–930 MHz with the SX1262 chip. Use this as your gateway receiver for better sensitivity (-148 dBm) and to receive packets from multiple sensor nodes simultaneously.
Transmitter and Receiver Code
Install the LoRa library by Sandeep Mistry from Arduino Library Manager. This works with SX1276 (Ra-01H) out of the box.
Sensor Node Transmitter (Arduino Pro Mini / ESP32)
#include <SPI.h>
#include <LoRa.h>
#define SS 10
#define RST 9
#define DIO0 8
#define FREQ 865E6 // 865 MHz India ISM band
const int SOIL_PIN = A0;
const int NODE_ID = 1; // Unique ID per sensor node
void setup() {
LoRa.setPins(SS, RST, DIO0);
if (!LoRa.begin(FREQ)) {
// Retry or halt
while (1);
}
LoRa.setSpreadingFactor(10); // SF10 for ~3-5km range
LoRa.setSignalBandwidth(125E3);
LoRa.setCodingRate4(5);
LoRa.setTxPower(17); // Max 17dBm for SX1276
}
void loop() {
int rawSoil = analogRead(SOIL_PIN);
int moisture = map(rawSoil, 1023, 300, 0, 100); // calibrate for your sensor
moisture = constrain(moisture, 0, 100);
float tempC = 28.5; // Replace with actual DS18B20 reading
LoRa.beginPacket();
LoRa.print(NODE_ID);
LoRa.print(",");
LoRa.print(moisture);
LoRa.print(",");
LoRa.print(tempC, 1);
LoRa.endPacket();
// Deep sleep for 15 minutes to save battery
// ESP32: esp_deep_sleep(15 * 60 * 1000000ULL);
delay(15 * 60 * 1000UL); // Arduino: simple delay
}
Gateway Receiver (ESP32 + WiFi upload to ThingSpeak)
#include <SPI.h>
#include <LoRa.h>
#include <WiFi.h>
#include <HTTPClient.h>
#define SS 5
#define RST 14
#define DIO0 2
const char* SSID = "YourFarmWiFi";
const char* PASS = "password";
const char* TS_KEY = "YOUR_THINGSPEAK_WRITE_API_KEY";
void setup() {
Serial.begin(115200);
WiFi.begin(SSID, PASS);
while (WiFi.status() != WL_CONNECTED) delay(500);
LoRa.setPins(SS, RST, DIO0);
LoRa.begin(865E6);
LoRa.setSpreadingFactor(10);
Serial.println("Gateway ready, listening...");
}
void loop() {
int pktSize = LoRa.parsePacket();
if (pktSize) {
String data = "";
while (LoRa.available()) data += (char)LoRa.read();
int rssi = LoRa.packetRssi();
Serial.printf("Received: %s | RSSI: %d dBmn", data.c_str(), rssi);
// Parse: "nodeID,moisture,temp"
int nodeID = data.substring(0, data.indexOf(',')).toInt();
int moisture = data.substring(data.indexOf(',')+1, data.lastIndexOf(',')).toInt();
float temp = data.substring(data.lastIndexOf(',')+1).toFloat();
// Upload to ThingSpeak
HTTPClient http;
String url = String("https://api.thingspeak.com/update?api_key=")
+ TS_KEY + "&field1=" + moisture + "&field2=" + temp;
http.begin(url);
http.GET();
http.end();
}
}
Power Management and Solar Integration
A sensor node transmitting every 15 minutes with LoRa consuming 120 mA during transmission (~500 ms) and sleeping at 5 µA uses approximately:
- Transmission energy: 120 mA × 0.5s × 4 times/hr = 0.067 mAh/hr
- Sleep energy: 0.005 mA × 60 min = 0.3 mAh/hr
- Total: ~0.37 mAh/hr → 2000 mAh 18650 battery lasts ~225 days
For permanent installation in Indian fields where battery swapping is inconvenient, add a 5V 1W mini solar panel (available at most Indian electronics shops) through a CN3791 MPPT solar charger to the 18650 battery. Even on monsoon cloudy days in Maharashtra or Kerala, the panel generates enough to sustain the node’s minimal consumption.
Enclose the entire node in a IP65-rated junction box (available at local hardware stores for ₹80–120). Seal the soil sensor probe with silicone gel at cable entry points to prevent moisture ingress.
15cm 3dBi GSM/GPRS PCB Antenna with IPEX Connector
Extend your LoRa gateway’s range with an external antenna. This 3dBi PCB antenna connects via IPEX and can be positioned for optimal field coverage from a water tower or rooftop.
Frequently Asked Questions
Is LoRa legal to use in India for agriculture?
Yes. India’s TRAI has allocated the 865–867 MHz band as an unlicensed ISM band. LoRa devices operating in this band at up to 1W ERP (which includes Ra-01H at 17 dBm = 50 mW — well within limit) do not require any radio licence. This is one of the key advantages of LoRa over other wireless technologies for Indian agriculture.
How many sensor nodes can one gateway support?
A single-channel LoRa gateway (like the ESP32 + Ra-01H) can handle 10–30 nodes comfortably if transmissions are infrequent (every 15+ minutes). For larger deployments, use a multi-channel gateway (RAK7244, Dragino LPS8) that supports 8 simultaneous channels — handling hundreds of nodes.
What is the difference between LoRa and LoRaWAN?
LoRa is the physical radio layer (the modulation technique). LoRaWAN is the network protocol layer built on top of LoRa, adding device addressing, encryption (AES-128), and network server infrastructure. For small farm deployments, plain LoRa point-to-point is simpler. For large networks connecting to The Things Network (TTN) — which now has gateways in Bangalore, Mumbai, Delhi, and Hyderabad — use LoRaWAN.
Can I measure NPK (nitrogen, phosphorus, potassium) with LoRa nodes?
Yes. RS485 NPK sensors (available on Indian electronics platforms for ₹3000–5000) communicate via Modbus RTU. Connect via a MAX485 module to the Arduino node. The sensor reads N, P, K values which are then packaged into the LoRa payload and transmitted to the gateway.
How do I increase LoRa range beyond 5km?
Increase spreading factor (SF12 gives maximum range at cost of data rate), use a directional antenna at the gateway (Yagi or patch), and ensure line-of-sight or elevated placement. A Ra-01H with SF12 and a 5 dBi gain antenna at 10m height can realistically achieve 15+ km in flat terrain like Punjab or Haryana fields.
Add comment