The elephant edge challenge provides an exciting opportunity for ideas in conservation technology to be applied on the field. In this particular challenge, technology can play dual roles in mitigating human-animal conflict and in gaining advanced insights into short and long term behaviour of elephants.
The idea proposed and demonstrated in this project is a framework that combines smart collars and smart gateways.
Human-Elephant conflict in IndiaIn India, between the years 2015 - 2018, human-elephant conflict caused 1713 human and 373 elephant deaths. Technology can help in reducing the deaths in some scenarios. For instance, 49 elephants died due to accidents with trains between 2016 - 2018. Coffee & Tea plantation roads that are increasingly used by tourists are becoming ever increasing scenes of conflict. Crop raiding by elephants destroys the livelihood of farmers and is becoming increasingly dangerous for humans and elephants. Some studies also indicate that hotspots of human-elephant conflicts are around edges of protected areas, plantations and riverine corridors.
Requirements of a technology solutionThe common requirements of a technology framework solution for the different kinds of human-elephant conflict would include:
- Accurate and reliable early warning systems deployed in identified hotspots.
- Smart collar sensor data combined with edge machine learning to provide real time alerts that can be basic sensor based and more complex machine learning based detection of alerts such as human presence, gunshots, firecrackers, etc.
- Sensor and machine learning data for insights into complex elephant behaviour.
- Gateways to communicate with collars and send data over the cloud to a dashboard for Park/Forest officials.
- Local alerts by the gateway to the people locally affected during human-elephant conflicts.
This project proposes a framework to address these requirements. The following is a breakdown of the framework solution:
O Gateway towers with graded and configurable early warning systems based on geographical perimeters. For example, towers can have configured warning and alert perimeters. These can be used to send appropriate notifications when elephant collars enter/leave these perimeters.
O Notifications that are two fold:
- Local notifications that can be adapted to the regional context. For example, alerts over Bluetooth mesh/SMS in farms, digital displays in forest roads and train tracks, Bluetooth mesh hopped messages to train drivers, etc.
- Cloud notifications to the dashboard along with push alerts for remote monitoring by Park/Forest officials, etc.
O The following common data types:
- Real time collar data
- Gateway tower configuration data
- Gateway to dashboard data
- Activity history data
- Machine Learning (ML) history data
O With the real time collar data we can:
- Send collar identification information
- Send sensor data
- Send real time ML detected events
O With the Gateway tower configuration we can:
- Set geographic perimeters around any critical areas of human-animal conflict
O With the Gateway to dashboard data we can:
- Combine data from gateway, collar and events through gateway monitoring, sensors & machine learning and send them to cloud dashboards.
O With the activity history we can:
- Store the elephant activity detected through sensors when the collar is not in range of any gateway tower to broadcast.
O With the ML history we can:
- Store events, behaviours and environment predictions. These can provide short term and long term insights into more complicated behaviour of elephants.
O With the addition of some sensor reading code, real sensor data from the collar can be pushed to gateways through the given code.
O Similarly different regional context or conflict area specific machine learning solutions can be “plugged-and-played” into this framework.
O It is also imagined that the software written for this challenge can be a guide in developing and deploying a robust version in the field (in a more native language like C).
The above proposed framework can be applied to:
- Farmlands with frequent crop raiding by elephants
- Railway track sections with higher incidence of accidents
- Sanctuary borders that see human-elephant conflicts
- Zones in forests that have high risk of poaching
- Plantation roads where dangers to humans are high
- Forest observation points for general monitoring of elephants
- Similar setup for other endangered species that are in conflict with humans.
The code has been written with the following functionalities:
- To read gateway tower configuration information from a JSON file.
- Monitor geographical perimeters of the tower defined in the JSON file.
- Generation of event messages when the elephant collar is in range and breaches the defined perimeters. This is done by checking the Cross Track distance of the elephant collar location from the four sides of the perimeter. As of now, this works for rectangular perimeters but not for any four sided polygons.
- Different event messages generation for local and dashboard notifications.
- Send data (containing tower, collar and event information) from device to IoT Connect dashboard
The following functions were added to simulate sensors and communication between LoRa and Bluetooth devices
- Simulate an elephant collar coming in range of a LoRa gateway by defining a range radius and checking if the elephant is within that range by calculating the Haversine distance.
- Mimic the gateway listening to elephant collars through LoRa or Bluetooth by connecting to a MQTT broker and subscribing (listening) for animal collar topics
- Simulate an elephant moving through different areas and broadcasting information by reading artificial collar information from a prepared JSON file and publish the information periodically.
Sample real time collar data:
{
"collar_id": "Elephant214KLIN",
"animal_species": "Elephant",
"animal_name": "yaanai",
"animal_position": {
"latitude": 8.969345,
"longitude": 77.130787
},
"orientation": "North",
"activity": {
"current_state": "WALKING",
"mag_orientation": "UPRIGHT",
"duration": 13.5,
"acceleration": {
"x-axis": 0.5,
"y-axis": 0.21,
"z-axis": 0.03
}
},
"sensor_events": [
{
"level": "WARNING",
"event": "Low battery",
"value": 9
}
],
"tiny_ml_detected_events": [
{
"level": "DANGER",
"event": "Firecracker sounds detected",
"confidence": 87.5
},
{
"level": "ALERT",
"event": "Human voices detected",
"confidence": 91.2
}
],
"collar_charge": 75,
"last_gateway_sync": "2020-10-25 15:27:13"
}
In this data structure, we have included the field: “animal_position” with latitude and longitude. This is included for the purposes of this simulation. The collar location during actual deployment will be calculated by the gateway tower connected to the LoRa Cloud.
Sample gateway to dashboard cloud data:
{
"dataArray": [
{
"data": {
"tower_id": "FarmlandGateway1",
"tower_area": "Theni",
"tower_position": {
"latitude": 8.955328,
"longitude": 77.13456
},
"tower_type": "FARM_LAND_TOWER",
"tower_zone": "CONFLICT",
"event_message": {
"level": "WARNING",
"text": "Yaanai inside FarmlandGateway1 warning perimeter"
}
},
"uniqueId": "FarmlandGateway1",
"time": "2020-10-27 19:12:34"
},
{
"data": {
"collar_id": "Elephant214KLIN",
"animal_species": "Elephant",
"animal_name": "yaanai",
"animal_position": {
"latitude": 8.969345,
"longitude": 77.130787
},
"orientation": "North",
"activity": {
"current_state": "WALKING",
"mag_orientation": "UPRIGHT",
"duration": 13.5,
"acceleration": {
"x-axis": 0.5,
"y-axis": 0.21,
"z-axis": 0.03
}
},
"collar_charge": 75,
"last_gateway_sync": "2020-10-25 15:27:13"
},
"uniqueId": "collarInfo",
"time": "2020-10-27 19:12:34"
}
]
}
Sample activity history data:
{
"collar_id": "Elephant214KLIN",
"animal_species": "Elephant",
"animal_name": "yaanai",
"activity_log": [
{
"timestamp": "2020-10-25 15:21:45",
"state" : "RESTING",
"duration" : 27.5,
"orientation" : "UPRIGHT",
"acceleration": {
"x-axis": 0.01,
"y-axis": 0.03,
"z-axis": 0.00
},
"mag_orientation": "North"
},
{
"timestamp": "2020-10-25 15:21:45",
"state" : "RESTING",
"duration" : 27.5,
"orientation" : "UPRIGHT",
"acceleration": {
"x-axis": 0.01,
"y-axis": 0.03,
"z-axis": 0.00
},
"mag_orientation": "North"
},
{
"timestamp": "2020-10-25 15:21:45",
"state" : "RESTING",
"duration" : 27.5,
"orientation" : "UPRIGHT",
"acceleration": {
"x-axis": 0.01,
"y-axis": 0.03,
"z-axis": 0.00
},
"mag_orientation": "North"
}
}
Sample machine learning history on collar data:
{
"collar_id": "Elephant214KLIN",
"animal_species": "Elephant",
"animal_name": "yaanai",
"ml_prediction_log": [
{
"timestamp": "2020-10-25 15:21:45",
"event_prediction": {
"event": "WITH_HERD",
"level": "INFO",
"confidence": 94.7
},
"beaviour_prediction": {
"behaviour": "Agitated",
"confidence": 56.2
},
"environment_prediction": {
"environment": "RIVER_BANK",
"confidence": 65.3
}
},
{
"timestamp": "2020-10-25 15:45:06",
"event_prediction": {
"event": "WITH_HERD",
"level": "INFO",
"confidence": 95.1
},
"beaviour_prediction": {
"behaviour": "Normal",
"confidence": 86.2
},
"environment_prediction": {
"environment": "RIVER_BANK",
"confidence": 43.4
}
},
{
"timestamp": "2020-10-25 16:23:21",
"event_prediction": {
"event": "WITH_HERD",
"level": "INFO",
"confidence": 97.8
},
"beaviour_prediction": {
"behaviour": "Normal",
"confidence": 86.2
},
"environment_prediction": {
"environment": "THICK_FOREST",
"confidence": 43.4
}
}
]
}
SimulationWith the code and sample data included in this project we can simulate:
- One or more elephants moving and broadcasting real time collar information.
- One or more gateway towers listening for collar broadcasts.
- Perimeter, sensor and ML based events.
Two reproducible simulations are included in this project.
Scenario 1: Elephant leaving sanctuary and crossing railway trackFor this demonstration, a location in Edapalayam, Kerala, India has been picked. Here there is a railway track running through a forest area. Two towers have been added to monitor this potential conflict zone.
The simulated path of an elephant leaving the sanctuary, crossing the railway track and going to the forest on the other side:
The towers have configured warning and alert perimeters. However, they behave differently.
- The Sanctuary edge tower, notifies when the elephant collar leaves the warning/alert perimeter.
- The Railway tower notifies when the elephant collar is within the warning/alert perimeters.
A representation of the warning and alert areas of the two towers.
To reproduce this simulation, you would need the following:
Step 1: Avnet IoT Connect Dashboard setup.
Setup an account on Avnet IoT Connect. Setup gateway devices on the Avnet IoT Dashboard. The documentation will guide you through creating Templates, Gateway Devices, setting the Dashboard, etc. The configured gateway device ID on the dashboard should match the unique ID in the data being pushed to the cloud. There is also documentation on setting up rule matching for events in the data being sent to the IoT Connect.
Rules for template devices can be configured in the following way:
The dashboard set up for this simulation:
Step 2: A computer, and(or) a RaspberryPi.
I have used the following setup: A RaspberryPi to imitate the Elephant collar (publisher). A Laptop to serve as the MQTT broker. The two (subscribers) gateway towers were also running on the laptop. This simulation can also be done on a single computer without RaspberryPi.
Step 3: IoT Connect SDK.
The Python SDK to connect to IoT Connect can be downloaded from here: https://help.iotconnect.io/documentation/sdk-reference/device-sdks-flavors/. Instructions to install the SDK are provided in help.txt.
Step 4: MQTT Connection
- On your computer, ensure that you have Mosquitto broker (or an alternative) installed.
- On the devices from which you are going to publish(collar broadcast) and subscribe(gateway towers), get a MQTT client such as Paho installed.
- Configure the clients with the broker IP. For the collar, edit the IP in:
collar/roaming_elephant_simulation.py
. For the gateway tower, edit the IP in:gateway/edge_gateway_tower.py
.
Step 5: LoRa range
For this simulation, the LoRa range of the two towers is 650 meters. Check this value in the variable lora_range
in edge_gateway_tower.py
.
Step 6: Running the simulation
From the command line, the towers can be started up with the command:
python edge_gateway_tower.py <<tower_config_JSON_file_name>>
For our simulation, execute the following two commands:
python edge_gateway_tower.py sanctuary_edge_tower.json
python edge_gateway_tower.py rail_track_tower.json
The collar can be simulated with the command:
python roaming_elephant_simulation.py <<simulated_collar_JSON_file_name>>
For this simulation, from the machine you want to be simulating the collar, execute:
python roaming_elephant_simulation.py leave_sanctuary_cross_rail_track_path.json
All parts of the simulation should be running now. You should see the collar broadcasting real time collar information. When the elephant collar comes in range of a tower, you will see it checking if the collar has breached the geo fenced perimeters. For events, you will see local messages printed on the console and messages to the IoTConnect dashboard being sent. If you have the dashboard up, you can see live data and notifications of alerts.
Video demonstration of the simulation:
Scenario 2: Elephant near farmland & ML detected human activityFor this demonstration, a farming locality close to forests in Theni, TamilNadu, India has been picked.
The simulated elephant path has been numbered 1 to 8. A farmland gateway tower has been added.
The configured perimeters and range of the towers is visually shown below:
To reproduce this simulation, steps 1 to 4 from the previous simulation are the same.
Step 5: LoRa range
For this simulation, the LoRa range of the tower is 1200 meters. Check this value in the variable lora_range
in edge_gateway_tower.py
.
Step 6: Running the simulation
From the command line, the tower can be started with the command:
python edge_gateway_tower.py farm_land_tower.json
For collar simulation from the machine you want, execute:
python roaming_elephant_simulation.py farm_with_sensor_ml_events_collar_path.json
The simulation should be running now. In the console executing the tower code, you should see local perimeter alerts. In the Avnet IoT Connect dashboard you should see dashboard messages for perimeter, sensor and ML detected notifications. You can configure the rules for the template device to show UI alerts when events match rules.
Video demonstration of the simulation:
Reference resources:- Man elephant conflict and its mitigation
- How to save Indian elephants from killer rail tracks
- Mapping human-elephant conflict hotspots
- Determinants of human-elephant conflict in a land-use mosaic
- Assessing farm based measures for mitigating human-elephant conflict
- Human-Elephant Conflict: A Review of Current Management Strategies
- Using satellite telemetry to mitigate human-elephant conflict
- Valparai model in mitigating human elephant conflict
- Impact of foliage on LoRa 433MHz propagation in tropical environment
- A study of the LoRa signal propagation in forest, urban, and suburban environments
Comments