Modern Indian agriculture is rapidly embracing technology, and an IoT soil monitor farm ESP32 LoRa system represents one of the most impactful applications of electronics in this space. By continuously measuring soil moisture, temperature, and nutrient levels across a farm and transmitting data wirelessly over kilometres via LoRa radio, farmers can make data-driven decisions about irrigation and fertilization — reducing water use by up to 40% and improving crop yields significantly. This guide shows you how to build a complete farm soil monitoring system from scratch using affordable components available in India.
Why LoRa for Farm IoT in India?
Indian farms face unique connectivity challenges. Most agricultural land is far from Wi-Fi infrastructure, cellular coverage is inconsistent in rural areas, and running cable across fields is impractical. LoRa (Long Range) radio technology solves this beautifully:
- Range: 2–15 km in open terrain (line of sight) — one gateway can cover an entire large farm
- Power: LoRa transmitters consume only 20–40mA during transmission, and field nodes can sleep at <10µA between readings
- Cost: LoRa modules cost ₹300–800, far cheaper than cellular modems
- No SIM card needed: LoRa operates on 865–867 MHz ISM band in India — license-free operation
- Penetration: LoRa signals penetrate through crops, trees, and light structures better than Wi-Fi’s 2.4GHz
For reference, a single LoRa gateway placed at a farm’s highest point can reliably communicate with 10–50 sensor nodes spread across hundreds of acres. This makes LoRa the dominant choice for precision agriculture IoT in India, used by startups like AgNext, CropIn, and large agricultural universities.
System Architecture Overview
Our farm soil monitoring system has three layers:
- Field Sensor Nodes (many): ESP32 + LoRa module + soil sensors, solar powered, deployed every 50–100 metres across the field
- LoRa Gateway (one per farm zone): ESP32 + LoRa module, connected to internet via Wi-Fi or 4G, bridges field data to cloud
- Dashboard: Node-RED or ThingsBoard running on a Raspberry Pi or cloud server, visualizes data and sends alerts
Data flows from field → LoRa radio → gateway → MQTT broker → Node-RED dashboard → farmer’s phone/browser. The entire system can be set up for under ₹8,000 per node, with no recurring subscription costs if hosted locally.
Ai Thinker NodeMCU-32S ESP32 Development Board – IPEX Version
The IPEX antenna connector on this board makes it ideal for connecting an external LoRa module antenna, maximizing wireless range across your farm.
Building the Soil Sensor Node
Each field node measures soil moisture, temperature, and optionally NPK (nitrogen-phosphorus-potassium) levels. Here’s the component list per node:
- ESP32 development board (with IPEX antenna connector for LoRa)
- LoRa module: Ra-01 or Ra-02 (SX1278 chip, 433MHz) or SX1276-based 868MHz module for India
- Soil moisture sensor (capacitive type preferred over resistive for longevity)
- DS18B20 waterproof temperature sensor (for soil temperature)
- BME280 sensor (ambient temperature, humidity, pressure for above-ground data)
- Solar panel (5V 2W or 6V 1W) + TP4056 charger + 18650 Li-Ion cell
- IP65 waterproof enclosure
DS18B20 Temperature Sensor Module
A waterproof DS18B20 probe sensor perfect for measuring soil temperature at different depths — communicates over 1-Wire protocol directly with your ESP32.
Wiring the Sensor Node
| Component | Connection | Protocol |
|---|---|---|
| LoRa (SX1278) | SPI: GPIO 5/18/19/27 + NSS/RST/DIO0 | SPI |
| Soil moisture sensor | GPIO 34 (ADC1) | Analog |
| DS18B20 probe | GPIO 4 + 4.7kΩ pull-up | 1-Wire |
| BME280 | I2C: GPIO 21 (SDA), GPIO 22 (SCL) | I2C |
| Battery/Solar | Via TP4056 → LDO → 3.3V | Power |
Sensor Node Firmware
#include <Arduino.h>
#include <SPI.h>
#include <LoRa.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_BME280.h>
#include "esp_sleep.h"
#define NODE_ID 1 // Unique ID for this field node
#define LORA_SCK 5
#define LORA_MISO 19
#define LORA_MOSI 27
#define LORA_SS 18
#define LORA_RST 14
#define LORA_DIO0 26
#define SOIL_PIN 34
#define DS18B20_PIN 4
#define SLEEP_MINUTES 15 // Send every 15 minutes
OneWire ow(DS18B20_PIN);
DallasTemperature soilTemp(&ow);
Adafruit_BME280 bme;
void setup() {
// Init LoRa
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_SS);
LoRa.setPins(LORA_SS, LORA_RST, LORA_DIO0);
LoRa.begin(866E6); // 866 MHz — India ISM band
LoRa.setSpreadingFactor(10); // SF10: range vs speed balance
LoRa.setTxPower(20); // Max 20dBm
// Read sensors
soilTemp.begin();
soilTemp.requestTemperatures();
float soil_temp_c = soilTemp.getTempCByIndex(0);
int soil_raw = analogRead(SOIL_PIN);
int soil_pct = map(soil_raw, 4095, 1500, 0, 100); // Calibrate these values!
soil_pct = constrain(soil_pct, 0, 100);
bme.begin(0x76);
float air_temp = bme.readTemperature();
float air_hum = bme.readHumidity();
float pressure = bme.readPressure() / 100.0;
// Send LoRa packet
String packet = String(NODE_ID) + "," + String(soil_pct) + "," +
String(soil_temp_c, 1) + "," + String(air_temp, 1) + "," +
String(air_hum, 1) + "," + String(pressure, 0);
LoRa.beginPacket();
LoRa.print(packet);
LoRa.endPacket();
// Sleep until next reading
esp_sleep_enable_timer_wakeup((uint64_t)SLEEP_MINUTES * 60 * 1000000ULL);
esp_deep_sleep_start();
}
void loop() {}
GY-BME280-3.3 Precision Altimeter Atmospheric Pressure Sensor Module
Measure ambient temperature, humidity, and barometric pressure above the crop canopy — correlate with soil data for comprehensive crop health monitoring.
Setting Up the LoRa Gateway
The gateway receives LoRa packets from all field nodes and forwards them to your MQTT broker or cloud service. It consists of an ESP32 (with Wi-Fi or 4G for uplink) and another LoRa module.
#include <Arduino.h>
#include <SPI.h>
#include <LoRa.h>
#include <WiFi.h>
#include <PubSubClient.h>
const char* ssid = "FARM_WIFI";
const char* password = "WIFI_PASS";
const char* mqtt_server = "192.168.1.100";
WiFiClient wifi;
PubSubClient mqtt(wifi);
void setup() {
Serial.begin(115200);
SPI.begin(5, 19, 27, 18);
LoRa.setPins(18, 14, 26);
LoRa.begin(866E6);
LoRa.setSpreadingFactor(10);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) delay(500);
mqtt.setServer(mqtt_server, 1883);
mqtt.connect("LoRaGateway");
}
void loop() {
int packetSize = LoRa.parsePacket();
if (packetSize) {
String data = "";
while (LoRa.available()) data += (char)LoRa.read();
int rssi = LoRa.packetRssi();
// Parse: nodeId,soilPct,soilTemp,airTemp,airHum,pressure
String topic = "farm/node/" + data.substring(0, data.indexOf(','));
String payload = "{"raw":"" + data + "","rssi":" + String(rssi) + "}";
mqtt.publish(topic.c_str(), payload.c_str());
}
mqtt.loop();
}
Building the Monitoring Dashboard
With data flowing into MQTT, you can visualize it in Node-RED or ThingsBoard. For a farm dashboard, we recommend these panels:
- Farm map view: Node-RED Dashboard world-map node showing each sensor’s location with color-coded moisture level
- Historical charts: Line charts showing soil moisture trend over past 7 days — essential for understanding irrigation needs
- Alert thresholds: Automated SMS/WhatsApp alert when soil moisture drops below 30% (irrigation needed) or rises above 80% (waterlogging risk)
- Comparison view: Side-by-side comparison of different field zones — useful for identifying problem areas
- Weather correlation: Overlay rainfall data from Open-Meteo API (free) with your soil moisture readings to validate your sensors
ThingsBoard Community Edition (free, self-hosted) is particularly powerful for this use case — it has built-in LoRa support, customizable dashboards, rule chains for alerts, and can be installed on a Raspberry Pi or a low-cost VPS starting at ₹400/month.
DS18B20 Programmable Resolution Digital Temperature Sensor
Multiple DS18B20 sensors can share a single GPIO wire (1-Wire bus) — deploy probes at different soil depths (5cm, 15cm, 30cm) to understand the full soil temperature profile.
Solar Powering the Field Nodes
Running wires to sensors across a farm is impractical. Solar power with battery backup is the standard solution for Indian agricultural IoT deployments.
Solar Sizing for an Indian Farm Node
Our field node (ESP32 + LoRa + sensors, reading every 15 minutes) has an average power consumption of approximately 0.5mA (dominated by 15µA deep sleep + short active bursts). Power budget:
- Daily energy: 0.5mA × 24h = 12mAh/day
- Battery: 2500mAh cell with 50% usable = 1250mAh usable → 104 days of cloudy backup
- Solar panel: A 0.5W panel at 5V producing ~100mA peak × 5 peak-sun-hours = 500mAh/day (41× the daily need)
Even the smallest solar panel (0.5W to 1W) is more than sufficient. Use a 6V panel (not 5V) with a TP4056 charger module to ensure charging even in partially cloudy conditions. Most Indian states receive 4.5–6.5 peak-sun-hours per day — excellent for solar IoT nodes.
Enclosure and Field Deployment Tips
Use IP65-rated ABS boxes for the electronics enclosure. Mount the solar panel at a 15°–25° tilt facing south for maximum annual energy capture at Indian latitudes (8°N–35°N). The sensor probes should be waterproofed with silicone sealant at the cable entry points. In high-clay soils, calibrate the capacitive soil sensor with wet/dry soil samples from your specific field before deployment.
2 x 18650 Lithium Battery Shield for Arduino/ESP32/ESP8266
Pair this battery shield with a small solar panel and TP4056 charger for a completely self-sustaining farm IoT node that never needs a manual battery change.
Frequently Asked Questions
What LoRa frequency should I use in India?
India’s ISM band for LoRa is 865–867 MHz. Use 866 MHz as a default. Do NOT use 433 MHz (used by some cheap modules from China) as it is not licensed for India and may cause interference. The TRAI has authorized 865–867 MHz for unlicensed low-power applications, making it safe for agricultural IoT deployments.
How many sensor nodes can one LoRa gateway handle?
A single-channel LoRa gateway (one LoRa module) can handle 10–30 nodes comfortably, depending on the reading frequency and spreading factor. A multi-channel gateway (using 8 LoRa channels with an SX1301 chip) can handle thousands of nodes — this is what LoRaWAN commercial networks use. For most farms up to 500 acres, a single-channel gateway works fine with nodes reading every 15 minutes.
Can I connect this system to government agriculture schemes?
Yes. Several state governments (Maharashtra, Karnataka, Punjab, Tamil Nadu) have precision farming initiatives that provide subsidies for IoT-based soil monitoring equipment. ICAR (Indian Council of Agricultural Research) also has funded programs. Your data dashboard can generate reports compatible with these schemes, and the data can be shared with agricultural universities for research collaboration.
What is LoRaWAN and should I use it instead of raw LoRa?
LoRaWAN is a network protocol built on top of LoRa radio. It adds features like device management, security (AES-128 encryption), and integration with network servers. For a self-contained farm network, raw LoRa (as described in this guide) is simpler to implement. LoRaWAN makes sense if you want to use The Things Network (TTN) infrastructure, which has growing coverage in Indian cities, or if you’re building a product for commercial sale.
How accurate are the soil moisture readings?
Capacitive soil moisture sensors (the recommended type) provide relative readings that require calibration per soil type. After calibrating with your specific soil (take readings in air=0%, saturated soil=100%), accuracy is typically ±3–5%. For precision irrigation decisions, this is adequate. Absolute accuracy comparable to laboratory tensiometers requires a ₹5,000+ commercial sensor, but the DIY approach is sufficient for most farm automation needs.
Get all the ESP32 boards, sensors, and battery shields you need to deploy a professional farm soil monitoring network. Available at Zbotic.in with fast shipping across India.
Add comment