Connecting a sensor in a lab is easy. Connecting one in a remote farm with spotty 2G and frequent power cuts is a nightmare. This is the story of how we kept a soil moisture node alive for 600 days on a single battery.
1. The Hardware Bill of Materials (BOM)
We chose components based on three criteria: Availability in local markets, cost, and power consumption.
| Component | Role | Approx Cost (INR) |
|---|---|---|
| PIC16F877A | Main Controller (Low Power) | ₹180 |
| SX1278 (Ra-02) | LoRa Module (433MHz) | ₹350 |
| SIM800L | GSM/GPRS Gateway | ₹250 |
| TP4056 + 18650 | Battery Management | ₹150 |
2. Choosing the Link: LoRa vs GSM
We used a Star Topology.
Nodes: 10x Sensor Units. Protocol: LoRa (Long Range). Range: 5km.
Hub: 1x Central Gateway. Protocol: GSM (2G). Uploads to Cloud.
Connectivity Protocol Comparison
Why LoRa? We evaluated every major IoT connectivity standard. Here's the decision matrix that drove our choice.
| Protocol | Range | Power | Data Rate | Cost/Module | Verdict |
|---|---|---|---|---|---|
| LoRa (433MHz) | 5–15 km | Ultra-Low | 0.3–50 kbps | ₹350 | ✅ Winner |
| GSM/GPRS (2G) | Unlimited* | High | 56–114 kbps | ₹250 | Gateway only |
| Sigfox | 10–50 km | Low | 100 bps | ₹800+ | ❌ No India coverage |
| NB-IoT | 10 km | Low | 200 kbps | ₹1200+ | ❌ Too expensive |
| Wi-Fi | 50m | Very High | Fast | ₹200 | ❌ No infrastructure |
Packet Loss & Retry Strategy
In the real world, LoRa packets get lost. Weather, terrain, and interference all contribute. We implemented a lightweight ACK-based retry protocol at the application layer.
// Application-layer retry logic (Gateway side)
#define MAX_RETRIES 3
#define ACK_TIMEOUT_MS 5000
void receive_with_ack(uint8_t* buffer) {
int retries = 0;
bool ack_received = false;
while (!ack_received && retries < MAX_RETRIES) {
LORA_Receive(buffer);
// Validate CRC
if (validate_crc(buffer)) {
LORA_Send_ACK(buffer->node_id);
ack_received = true;
store_reading(buffer);
} else {
retries++;
delay_ms(ACK_TIMEOUT_MS);
LORA_Request_Retransmit(buffer->node_id);
}
}
if (!ack_received) {
log_error("Node %d: packet lost after %d retries",
buffer->node_id, MAX_RETRIES);
}
}
3. The Critical "Deep Sleep" Code (Embedded C)
To survive on a single 18650 battery for months, we maximize sleep time. The duty cycle is < 0.1%.
// XC8 Compiler for PIC16F
void main() {
SYSTEM_Initialize();
while(1) {
// 1. Wake up and Read Sensor
ADC_Init();
int moisture = ADC_Read(0);
// 2. Transmit via LoRa (SPI)
LORA_Send(moisture);
// 3. Enter Deep Sleep
// Shut down peripherals
ADC_OFF();
SPI_OFF();
// Sleep for 30 mins (Watchdog Timer)
for(int i=0; i<30; i++) {
SLEEP(); // ~60s WDT timeout
}
}
}
4. Power Budget Calculation
Engineering is math. Here is why our system works.
The Math
- Active Current: 120mA (during 2s transmission)
- Sleep Current: 0.05mA (Deep Sleep)
- Duty Cycle: 2s Active / 1800s Sleep
- Avg Current: ~0.18mA
- Battery: 2600mAh (Standard 18650)
- Life Expectancy: 2600 / 0.18 = 14,444 Hours (~600 Days)
5. Field Lessons
The biggest lesson? Rats love cables. We lost two sensor nodes because field rats chewed through the moisture sensor wires. We had to armor all cabling in PVC pipes for the final deployment.
Weatherproofing & Enclosure Design
Electronics in an open field face dust, rain, extreme heat (45°C+), and curious animals. Our IP65-rated enclosure used a "breathable" silicone gasket design — waterproof but allowing pressure equalization to prevent condensation.
- Enclosure: ABS plastic box (IP65), ₹80 from local electronics market
- Cable entry: PG7 cable glands with silicone seals
- Antenna: External SMA antenna mounted on top, pointing upward for maximum LoRa range
- Heat management: White enclosure paint to reflect sunlight, internal temperature never exceeded 55°C
Field Wins
- 600+ days battery life achieved in practice
- Zero data loss with ACK retry protocol
- 30% water savings vs timer-based irrigation
Field Failures
- 2 nodes destroyed by rats chewing cables
- 1 antenna broken during monsoon winds
- GSM dropouts during peak hours (6-8 PM)
Key Takeaways
- LoRa is king for rural IoT. 5km range, ultra-low power, and ₹350/module — no other protocol comes close for Indian agriculture.
- Deep Sleep is non-negotiable. With a 0.1% duty cycle, we achieved 600+ days on a single 18650 battery. Without it: ~3 days.
- Design for failure. Rats, rain, and packet loss are not edge cases — they're the default. Armor your cables, waterproof your enclosures, and implement retry logic.
- Edge → Cloud, not Cloud → Edge. Make decisions locally. Use the cloud for reporting only. This is the architecture that survives connectivity outages.
- The BOM matters. Our entire node costs ₹1,500 ($18). Keeping it under ₹2,000 was the difference between "research project" and "deployable product".