A LoRa farm sensor network for wide area coverage on a budget solves one of the biggest challenges in agricultural IoT: Wi-Fi only reaches 30-50 metres, but farms span hectares. LoRa (Long Range) radio technology provides 1-15 km coverage per gateway node with minimal power consumption, making it ideal for large farm deployments in India where running electrical cables across fields is impractical and 4G coverage may be spotty. This guide covers building a complete LoRa farm sensor network using SX1278/Ra-02 modules with ESP32 for soil moisture, temperature, and humidity monitoring across a large agricultural area.
Table of Contents
- LoRa Technology Basics
- Farm Network Design
- Sensor Node Hardware
- Gateway Hardware
- Sensor Node Code
- Gateway Code
- Solar Power for Remote Nodes
- Frequently Asked Questions
LoRa Technology Basics
LoRa (Long Range) is a spread spectrum modulation technique derived from chirp spread spectrum (CSS). Key characteristics:
- Frequency: 865-867 MHz in India (ISM band, licence-free)
- Range: 1-5 km in rural farmland (line of sight); 500m-2km in dense vegetation
- Data rate: 300 bps to 50 kbps depending on spreading factor (SF) setting
- Power consumption: 15-20mA during transmission, under 1µA in sleep
- Bandwidth: 125 kHz or 500 kHz
- LoRaWAN: Standard protocol for LoRa networks; supports The Things Network (TTN) free public gateway infrastructure
For the Indian frequency band, use SX1278 or Ra-02 modules configured for 868 MHz or 915 MHz (check local regulations with WPC/DoT as the specific sub-bands may evolve). The 433 MHz band is also widely used in India for point-to-point LoRa (longer range but may need licence for some power levels).
Farm Network Design
A typical LoRa farm sensor network uses a star topology:
- Sensor nodes (end devices): Battery or solar-powered ESP32 + Ra-02 LoRa module + sensors. Transmit data every 15-60 minutes. 5-50 nodes per gateway. Placed throughout the farm in irrigation zones, on individual fields, near water sources.
- Gateway: Raspberry Pi or ESP32 + LoRa module + Wi-Fi/4G modem. Receives data from all nodes, parses it, and uploads to a cloud server or local database. One gateway per 5-10 km radius covers most Indian farm sizes.
- Cloud server: ThingSpeak, InfluxDB Cloud, or a custom server receives data from the gateway and provides dashboard, alerts, and API access.
For a 10-hectare farm (typical for commercial vegetable farming in India), 4-6 sensor nodes placed at representative locations (near inlet, centre, far end, different crop types) plus one gateway at the farm building is a practical minimum deployment.
Sensor Node Hardware
Each field sensor node requires:
- ESP32 development board
- LoRa Ra-02 (SX1278) module for 433 MHz or SX1276 for 868/915 MHz
- Capacitive soil moisture sensor
- DS18B20 waterproof temperature probe (soil temperature)
- BME280 (air temperature, humidity)
- 18650 Li-ion battery + holder
- TP4056 charging module (if using solar)
- 6V 2W solar panel (for solar charging)
- IP65 enclosure
Node cost per unit: approximately ₹800-1,400 (battery powered) or ₹1,500-2,200 (with solar). With proper deep sleep implementation, a single 3000mAh 18650 cell powering sensor readings every 15 minutes lasts 4-8 months before recharging.
Gateway Hardware
- Raspberry Pi 4 (₹4,500-6,000) or old laptop/server
- LoRa shield or Hat for Raspberry Pi (₹1,500-3,000)
- Jio/Airtel 4G router or USB modem for internet connectivity
- High-gain LoRa antenna (5-8 dBi) mounted at height (5-10 metres above ground increases range significantly)
- UPS or solar + battery for continuous power
Alternatively, use a commercial LoRaWAN gateway (RAK2287, Dragino LPS8) which plugs into TTN for ₹8,000-25,000, providing more robust packet handling than a DIY ESP32 gateway.
Sensor Node Code
Install LoRa library by Sandeep Mistry in Arduino IDE.
#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include <Adafruit_BME280.h>
#define LORA_SS 5
#define LORA_RST 14
#define LORA_DIO0 2
#define NODE_ID 1 // Unique ID for each sensor node
Adafruit_BME280 bme;
void setup() {
Serial.begin(115200);
Wire.begin();
bme.begin(0x76);
LoRa.setPins(LORA_SS, LORA_RST, LORA_DIO0);
if (!LoRa.begin(433E6)) { // 433 MHz for India (verify regulations)
Serial.println("LoRa init failed");
while(1);
}
LoRa.setSpreadingFactor(10); // SF10: longer range, lower data rate
LoRa.setSignalBandwidth(125E3);
LoRa.setCodingRate4(5);
LoRa.setTxPower(17); // 17 dBm
}
void loop() {
float temp = bme.readTemperature();
float humidity = bme.readHumidity();
int moisture = analogRead(34); // Capacitive sensor on GPIO 34
int moisturePercent = map(moisture, 3200, 1500, 0, 100);
moisturePercent = constrain(moisturePercent, 0, 100);
// Build compact JSON payload
String payload = "{"id":" + String(NODE_ID) +
","t":" + String(temp, 1) +
","h":" + String(humidity, 1) +
","sm":" + String(moisturePercent) + "}";
LoRa.beginPacket();
LoRa.print(payload);
LoRa.endPacket();
Serial.println("Sent: " + payload);
// Deep sleep for 15 minutes to save battery
esp_sleep_enable_timer_wakeup(15ULL * 60 * 1000000); // 15 minutes
esp_deep_sleep_start();
}
Gateway Code
// Gateway (also ESP32 + LoRa module)
#include <SPI.h>
#include <LoRa.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
const char* ssid = "FARM_WIFI";
const char* password = "WIFI_PASS";
const char* serverURL = "https://your-server.com/farm-data"; // Or ThingSpeak
void setup() {
Serial.begin(115200);
LoRa.setPins(5, 14, 2);
LoRa.begin(433E6);
LoRa.setSpreadingFactor(10);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) delay(500);
Serial.println("Gateway ready");
}
void loop() {
int packetSize = LoRa.parsePacket();
if (packetSize) {
String received = "";
while (LoRa.available()) received += (char)LoRa.read();
int rssi = LoRa.packetRssi();
Serial.println("Received: " + received + " RSSI:" + String(rssi));
// Forward to server
HTTPClient http;
http.begin(serverURL);
http.addHeader("Content-Type", "application/json");
String body = "{"data":" + received + ","rssi":" + String(rssi) + "}";
int code = http.POST(body);
Serial.println("Server response: " + String(code));
http.end();
}
}
Solar Power for Remote Nodes
For nodes beyond cable reach in large farms, solar power is essential. A 6V 2W solar panel (₹200-400) with a TP4056 1A charger and 3000mAh 18650 battery provides:
- Solar input: 6V × 0.33A (at full sun) = 2W per panel
- Daily energy: 2W × 5 hours (Indian average sun) = 10 Wh per day
- Node consumption: Sleep current (10µA × 14.5min) + active current (100mA × 0.5min) = very low average
- Balance: More than adequate for year-round operation including cloudy days
Position solar panels at 15-20 degrees tilt facing south (toward the equator) for maximum annual energy in India. In low-sun areas or for nodes with heavier loads (displays, multiple sensors), increase to 10W panels.
Frequently Asked Questions
Is LoRa legal to use on farms in India?
The 865-867 MHz ISM band is designated for licence-free short-range devices in India under the WPC’s Gazette Notification. LoRa modules operating within India’s permitted power limits (typically up to 100mW EIRP) do not require a wireless licence. However, regulations evolve — verify current WPC guidelines before large-scale deployment. The 433 MHz band is also widely used in India but check power limits. Commercial LoRaWAN gateways from established vendors are designed to meet Indian regulatory requirements.
What is the maximum number of sensor nodes one LoRa gateway can handle?
A single-channel DIY gateway (ESP32 + Ra-02) can handle approximately 20-30 sensor nodes if they transmit infrequently (every 15-60 minutes). A full 8-channel LoRaWAN gateway handles 100-500 nodes depending on traffic pattern. The LoRaWAN duty cycle requirement (1% maximum transmission duty cycle) means even a single gateway can handle many nodes if they transmit briefly and infrequently. For a 50-node farm, a commercial LoRaWAN gateway is recommended over a DIY single-channel gateway.
How do I diagnose LoRa reception problems in my farm?
Print RSSI (Received Signal Strength Indicator) and SNR (Signal-to-Noise Ratio) values at the gateway for each received packet. RSSI below -120 dBm and SNR below -15 dB indicate weak signal. Causes: antenna not connected, antenna mismatch, terrain blocking (hills, dense trees, buildings), distance too great, or spreading factor too low. Increase SF (from 7 to 12) for better sensitivity at the cost of lower data rate. Mount the gateway antenna as high as possible — every 6 metres of height doubles the effective range in flat terrain.
Can I use The Things Network (TTN) free LoRaWAN infrastructure in India?
TTN has gateways deployed in major Indian cities (Bangalore, Mumbai, Delhi, Hyderabad) but rural coverage is sparse. Check TTN coverage map at ttnmapper.org for your location. If TTN coverage is available, use it — it is completely free and provides excellent infrastructure. If not, deploy your own gateway and use TTN’s server infrastructure (still free) with your own gateway connecting via backhaul internet. TTN’s fair use policy allows 30 seconds of uplink airtime per day per node — adequate for 15-minute interval monitoring.
Add comment