An animal tracking collar using GPS and LoRa enables livestock monitoring across large grazing areas in India, helping farmers locate stray cattle, prevent theft, and manage herd movements. With India having the world’s largest cattle population (305 million bovines), GPS-LoRa tracking offers an affordable alternative to expensive commercial tracking solutions. This guide covers building a lightweight GPS-LoRa animal collar with ESP32 and power-efficient deep sleep design.
Table of Contents
- Why GPS Livestock Tracking Matters in India
- GPS and LoRa Architecture
- Components Required
- Circuit and Wiring
- ESP32 Tracker Code
- LoRa Gateway Setup
- Collar Design Considerations
- Frequently Asked Questions
Why GPS Livestock Tracking Matters in India
Livestock theft and straying cause enormous losses to Indian farmers. Key statistics:
- India loses over Rs 25,000 crore annually to cattle theft and straying
- Average Indian farmer walks 3-5 km daily just to locate grazing animals
- Night-time straying causes road accidents (cattle account for 5% of highway fatalities)
- Forest-edge farmers face elephant and leopard predation — early detection saves lives
- Gaushalas (cow shelters) managing 500+ animals need automated herd tracking
A GPS-LoRa collar costing Rs 2,000-3,000 pays for itself within 2-3 months in saved search time and prevented theft.
GPS and LoRa Architecture
The system architecture:
- Collar node: ESP32 + NEO-6M GPS + LoRa SX1278 + 3.7V LiPo battery + solar charging
- Gateway: Raspberry Pi + LoRa module at farmhouse (range 2-10 km in open terrain)
- Map server: Node.js server on Raspberry Pi with Leaflet.js map showing animal positions
- Alert: Geofence boundary breach triggers SMS via SIM800L at the gateway
LoRa is preferred over GSM/3G for animal collars because:
- Range: 5-15 km vs 1-3 km effective range for 3G in hilly terrain
- Power: LoRa uses 40-120 mA during TX vs 500-2000 mA for GSM — 10x better battery life
- Cost: No SIM card fees — own-network operation
- Reliability: Works in areas with no mobile signal
Components Required
Sensor Products from Zbotic
- GY-BME280 3.3V Sensor — optional: temperature/humidity for heat stress monitoring
Complete parts list per collar:
- ESP32-WROOM-32 module (bare module, not dev board, for weight savings)
- NEO-6M GPS module with ceramic antenna
- LoRa SX1278 Ra-02 433MHz module
- 3.7V 2000mAh LiPo battery
- TP4056 LiPo charge controller with protection
- 6V 1W solar panel (thin film or rigid, 80x55mm)
- MCP1700-33 3.3V LDO regulator
- Nylon webbing collar (40mm wide, heavy duty)
- Stainless steel D-rings and buckles
- Waterproof potting compound for electronics encapsulation
Circuit and Wiring
Compact wiring for collar (minimise size and weight):
- GPS TX -> ESP32 GPIO16 (UART2 RX), GPS RX -> GPIO17
- LoRa: MOSI -> GPIO23, MISO -> GPIO19, SCK -> GPIO18, CS -> GPIO5, RST -> GPIO14, DIO0 -> GPIO2
- Solar panel -> TP4056 IN+/IN- -> LiPo
- LiPo -> MCP1700 -> 3.3V to ESP32/LoRa/GPS
- Battery voltage monitor: voltage divider (100k/100k) -> GPIO35
Target total weight: under 150g (collar hardware included). Use SMD components and a custom PCB for minimum size. A 3D-printed ABS enclosure (55x35x20mm) fits all components.
ESP32 Tracker Code
#include <TinyGPSPlus.h>
#include <HardwareSerial.h>
#include <LoRa.h>
#include <SPI.h>
TinyGPSPlus gps;
HardwareSerial gpsSerial(2);
#define LORA_SS 5
#define LORA_RST 14
#define LORA_DIO0 2
// Deep sleep interval: 5 minutes between GPS fixes
#define SLEEP_US (5ULL * 60 * 1000000)
// Device ID (unique per collar)
const uint8_t DEVICE_ID = 1;
// GPS fix timeout
const unsigned long GPS_TIMEOUT_MS = 90000; // 90 seconds
RTC_DATA_ATTR int bootCount = 0;
RTC_DATA_ATTR float lastLat = 0;
RTC_DATA_ATTR float lastLon = 0;
void setup() {
Serial.begin(115200);
bootCount++;
gpsSerial.begin(9600, SERIAL_8N1, 16, 17);
SPI.begin(18, 19, 23, LORA_SS);
LoRa.setPins(LORA_SS, LORA_RST, LORA_DIO0);
// Wait for GPS fix (with timeout)
float lat = 0, lon = 0;
bool gotFix = false;
unsigned long start = millis();
while (millis() - start < GPS_TIMEOUT_MS) {
while (gpsSerial.available()) {
gps.encode(gpsSerial.read());
}
if (gps.location.isUpdated() && gps.location.isValid()) {
lat = gps.location.lat();
lon = gps.location.lng();
gotFix = true;
break;
}
delay(100);
}
// Read battery voltage
float batV = analogRead(35) * (4.2 / 4095.0) * 2.0;
uint8_t batPct = constrain((batV - 3.5) / (4.2 - 3.5) * 100, 0, 100);
// Transmit via LoRa (even if no GPS fix - send last known position)
if (!gotFix) { lat = lastLat; lon = lastLon; }
else { lastLat = lat; lastLon = lon; }
if (LoRa.begin(433E6)) {
LoRa.setSpreadingFactor(9);
LoRa.setSignalBandwidth(125E3);
LoRa.setTxPower(17);
// Compact 14-byte payload
LoRa.beginPacket();
LoRa.write(DEVICE_ID);
LoRa.write((uint8_t)bootCount);
// Encode lat/lon as int32 (multiply by 1e6)
int32_t latI = (int32_t)(lat * 1e6);
int32_t lonI = (int32_t)(lon * 1e6);
LoRa.write((uint8_t*)&latI, 4);
LoRa.write((uint8_t*)&lonI, 4);
LoRa.write(batPct);
LoRa.write(gotFix ? 1 : 0);
LoRa.endPacket();
Serial.printf("Sent: lat=%.6f lon=%.6f bat=%d%%n", lat, lon, batPct);
}
gpsSerial.end();
LoRa.end();
esp_sleep_enable_timer_wakeup(SLEEP_US);
esp_deep_sleep_start();
}
void loop() {} // Never reached
LoRa Gateway Setup
The Raspberry Pi gateway decodes LoRa packets and displays animal positions on a map:
- Raspberry Pi 3 or 4 with LoRa hat (RFM95W or SX1276-based)
- Node.js server with serialport library receives decoded packets
- Leaflet.js map with OpenStreetMap tiles shows real-time positions with animal icons
- Geofence defined as polygon on map — breach triggers SMS via SIM800L or email alert
- Position history stored in SQLite for movement analysis
Average gateway coverage with 9m antenna height: 5-8 km in flat terrain, 2-4 km in hilly areas common in Rajasthan, MP, and Chhattisgarh grazing regions.
Collar Design Considerations
Physical design is as important as electronics for livestock collars:
- Weight: Under 2% of animal body weight — max 150-200g for goats, 500g for adult cattle
- Durability: Animals rub against trees, roll in mud, wade through water — use IP67-rated enclosure
- Fit: Leave 2-finger gap between collar and neck. Check fit monthly as animals grow or gain/lose weight.
- Solar panel: Mount on top of collar for maximum sun exposure. Replace annually.
- GPS antenna: Must face skyward — use an external patch antenna mounted flat on collar top.
Frequently Asked Questions
What is the battery life of a GPS-LoRa collar with 5-minute update intervals?
With a 2000mAh LiPo and 5-minute deep sleep cycles, expect 7-10 days without solar charging. With a 1W solar panel in Indian conditions (5+ peak sun hours daily), the collar is effectively self-sustaining — battery stays above 80% year-round.
How accurate is the GPS position for finding a stray animal?
NEO-6M GPS provides 2.5-5 metre CEP accuracy in open sky. In dense forest, accuracy drops to 15-30 metres due to tree canopy blocking satellite signals. This is accurate enough to locate an animal within a single field.
Can one gateway track 50+ animals?
Yes. LoRa can handle hundreds of nodes if they are not all transmitting simultaneously. Use staggered transmission schedules (each collar has a slightly offset wakeup time based on device ID) to prevent packet collisions.
Is there a government scheme to subsidise livestock tracking?
Yes. The National Livestock Mission (NLM) and Rashtriya Gokul Mission provide subsidies for dairy animal identification and tracking technology. Contact your state Animal Husbandry Department for current subsidy rates.
Add comment