A comprehensive real-time livestock monitoring solution that simulates NavIC satellite positioning for humans and LoRa signal strength for livestock tracking. The system provides live visualization with automatic updates every 2 minutes and distance-based alerts.
- Real-time Monitoring: Live updates every 2 minutes (120 seconds)
- Human-centric Tracking: NavIC satellite positioning simulation for human reference point
- Livestock LoRa Tracking: Two-cow monitoring with RSSI-based positioning
- Distance Alerts: Automatic alerts when livestock exceed 100m safe distance
- Interactive Web Map: Real-time browser-based visualization
- Hardware-Ready: Structured for easy integration with actual NavIC and LoRa hardware
- Python 3.7 or higher
- Modern web browser (Chrome, Firefox, Safari, Edge)
- Network connectivity for real-time updates
- Minimum 4GB RAM recommended
# Clone or download the project
cd navic_lora_monitor
# Install required dependencies
pip install -r requirements.txtEdit config.py to customize your setup:
# Base coordinates (default: Bangalore, India)
BASE_COORDS = (12.9716, 77.5946)
# Update frequency (seconds)
UPDATE_INTERVAL = 120 # 2 minutes
# Distance threshold for alerts (meters)
DISTANCE_THRESHOLD = 100
# Web server settings
HOST = 'localhost'
PORT = 5000python app.pyOpen your web browser and navigate to:
http://localhost:5000
- Initialization: System starts with base coordinates and begins monitoring loop
- Position Updates: Every 2 minutes, the system:
- Simulates human NavIC position with realistic movement
- Generates cow LoRa RSSI signals and estimates positions
- Calculates distances from human to each cow
- Determines alert status based on distance threshold
- Live Broadcast: Updates are automatically sent to all connected web clients
- Continuous Monitoring: Process repeats indefinitely until manually stopped
- Reference Point: Human position (NavIC simulation)
- Target Entities: Two cows with LoRa signal simulation
- Calculation Method: Geodesic distance using geopy library
- Alert Threshold: 100 meters (configurable)
NavIC Simulation → Human Position
LoRa RSSI → Cow Positions → Distance Calculation → Alert Status → Map Update
navic_lora_monitor/
├── app.py # Main Flask application & real-time server
├── simulation.py # Position simulation for NavIC & LoRa
├── distance.py # Distance calculations & alert logic
├── config.py # Configuration settings
├── requirements.txt # Python dependencies
├── templates/
│ └── map.html # Web interface template
├── static/
│ ├── css/
│ │ └── style.css # Additional styling
│ └── js/
│ └── map.js # Enhanced JavaScript functionality
└── README.md # This file
- Live Map: Interactive map with real-time position markers
- Status Panel: System information and connection status
- Human Position: Current NavIC coordinates and timestamp
- Livestock Status: Individual cow information with RSSI and distances
- Alert Display: Visual indicators for distance threshold breaches
- Update Timer: Countdown to next automatic update
- Human Marker: Blue pin (👤) showing NavIC position
- Cow Markers: Colored circles indicating status
- 🟢 Green: Safe (≤100m distance)
- 🔴 Red: Alert (>100m distance)
- Info Popups: Click markers for detailed information
- Auto-Refresh: Map updates automatically without page reload
- Live Updates: Automatic refresh every 2 minutes
- Connection Status: Visual indicator of server connectivity
- Alert Notifications: Immediate visual alerts for distance breaches
- Multi-Client Support: Multiple users can view simultaneously
UPDATE_INTERVAL = 120 # Update frequency (seconds)
RECONNECT_TIMEOUT = 30 # Client reconnection timeout
MAX_RETRY_ATTEMPTS = 5 # Connection retry limitDISTANCE_THRESHOLD = 100 # Alert distance (meters)
RSSI_REFERENCE = -40 # RSSI at 1 meter (dBm)
PATH_LOSS_EXPONENT = 2.7 # Signal propagation factorHUMAN_MOVEMENT_RANGE = 0.001 # Human movement variation (degrees)
COW_MOVEMENT_RANGE = 0.002 # Cow movement variation (degrees)
RSSI_MIN = -120 # Minimum RSSI value (dBm)
RSSI_MAX = -30 # Maximum RSSI value (dBm)The system is designed for easy integration with real hardware:
# Replace simulation with actual NavIC receiver
def get_navic_position():
# return serial_read_navic() # Real hardware
return simulate_navic_position() # Current simulation# Replace simulation with actual LoRa network
def get_lora_signals():
# return lora_receiver.get_rssi_values() # Real hardware
return simulate_lora_signals() # Current simulation- Position History: Track movement patterns over time
- Alert History: Log all distance threshold breaches
- System Statistics: Performance and connectivity metrics
- JSON Format: Standard format for data analysis
- Ctrl+E: Export current data to JSON file
- Ctrl+R: Request immediate position update
# Test different scenarios
from simulation import simulator
# Normal operation
data = simulator.generate_test_scenario('normal')
# Force alert conditions
alert_data = simulator.generate_test_scenario('alert')
# Mixed conditions
mixed_data = simulator.generate_test_scenario('mixed')- Monitor memory usage during extended operation
- Verify 2-minute update intervals with system logging
- Test real-time delivery across multiple browser sessions
- Validate distance calculations with known coordinates
Connection Problems
- Check if port 5000 is available
- Verify firewall settings allow local connections
- Ensure all dependencies are installed correctly
Map Not Loading
- Check internet connection (required for map tiles)
- Verify JavaScript is enabled in browser
- Try refreshing the page or clearing browser cache
Updates Not Appearing
- Check browser console for error messages
- Verify WebSocket connection is established
- Restart the application if issues persist
Enable detailed logging by setting DEBUG = True in config.py
System logs appear in the console with timestamps and severity levels:
2024-07-25 10:30:15 - INFO - Update #5 completed
2024-07-25 10:30:15 - WARNING - ALERT: 1 cow(s) beyond safe distance!
Easily extend to monitor more livestock:
# In simulation.py, modify num_cows parameter
cow_data = self.simulate_lora_signals(human_pos, num_cows=5)Add multiple distance thresholds:
# In distance.py
def determine_multiple_alert_levels(distance):
if distance <= 50:
return 'safe'
elif distance <= 100:
return 'caution'
else:
return 'alert'Store data for pattern analysis:
# Add database integration
import sqlite3
def store_position_data(timestamp, human_pos, cow_data):
# Store in database for historical analysis
passChange HOST = '0.0.0.0' in config.py to allow network access
- Heroku: Use
Procfilewithweb: python app.py - AWS: Deploy using Elastic Beanstalk or EC2
- Docker: Containerize with provided Dockerfile template
The web interface is responsive and works on smartphones and tablets
- Mobile App: Native smartphone application
- SMS Alerts: Text message notifications for critical distances
- Machine Learning: Predictive analysis for animal behavior
- Cloud Database: Historical data storage and analytics
- Multi-Farm Support: Monitor multiple locations simultaneously
- NavIC Receiver Integration: Real satellite positioning
- LoRa Network Setup: Actual livestock transmitters
- Sensor Expansion: Temperature, heart rate, activity monitoring
- Power Management: Solar-powered field deployment
- Check the troubleshooting section above
- Review system logs for error messages
- Ensure all dependencies are correctly installed
Contributions are welcome! Areas for improvement:
- Additional visualization features
- Enhanced alert mechanisms
- Hardware integration modules
- Performance optimizations
- Documentation improvements
This project is designed for educational and development purposes. Ensure compliance with local regulations for livestock monitoring and satellite positioning systems.
- NavIC: Indian Regional Navigation Satellite System
- LoRa: Long Range wireless communication protocol
- Flask-SocketIO: Real-time web communication
- Leaflet.js: Interactive mapping library
- OpenStreetMap: Map tile provider
NavIC + LoRa Real-Time Distance Monitoring System - Bringing precision livestock tracking to modern agriculture 🛰️🐄📍