Let's work together and save the beautiful elephants using cutting edge technologies around us.👹 On Going Crisis
Accurate estimates suggest that there were 12 million elephants in the early 1900s. Today there are only 350, 000, which includes both savanna elephants and forest elephants.
That’s a 97% decline in just one century. At current mortality rate this species will extinct by 2030 !
Botswana is the largest home for African elephants (130, 000) followed by Zimbabwe.
Poachers are the biggest threat to African elephants. As per source, Poachers are currently shooting elephants at a rate of about 100 per day, or about 30, 000 every year. In other words, about 10% of the population is being wiped out ever year. More elephants are being killed than being born.
According to National Geographic, a pair of ivory chopsticks can sell for several thousand dollars, and carved tusks can sell for hundreds of thousands of dollars. This money is the reason poachers
While poachers are the biggest threat to African elephants, there are number of other factors which are playing big roles in reducing the numbers very fast such as environment, human-elephant conflicts and sudden aggressive behavior of young male elephants due to hormonal surges a.k.a Musth.
More than 350 elephants died in just few months in Botswana in early 2020. While the cause of death is still unknown but based on the information we have so far could be due to environmental issues such as soil poison, lack of water.
"Musth" (Musth or must /ˈmʌst/; from Persian, 'drunk') is a periodic condition in male elephantscharacterized by highly aggressive behavior and accompanied by a large rise in reproductive hormones. A musth elephant, wild or domesticated, is extremely dangerous to both humans and other elephants. There are several reported incidents of musth elephants killing other elephants, buffalos and even villagers. Study has indicated, putting elder male elephant in the pack help reduce the the aggressiveness in young musth elephants.
Elephant-human conflict poses a great threat to their continued existence. Studies on conflict between elephants and humans in Asia and in Africa have identified crop raiding as the main form of conflict. Elephant-human conflict is a result of habitat loss and fragmentation. When elephants and humans interact, there is conflict from crop raiding, injuries and deaths to humans caused by elephants, and elephants being killed by humans for reasons other than ivory and habitat degradation.
Elephants cause damage amounting from a few thousand dollars to millions of dollars. Every year, 100 humans (in some years it may be 300 people) and 40-50 elephants are killed during crop raiding in India. Source.
So, based on all the research I have done so far following are the major threats elephant population in Africa as well as in Asia.
- Illegal killing of elephants or poaching
- Human-elephant conflict
- Musth or aggressive behavior of male elephant
- Environmental issues such as wild fire, drought etc
Most, if not all of the above situations can be handled or avoided if park rangers or authorities are notified timely.🧠 Mahout - The Elephant Collar with A Brain
Introducing Mahout a smart elephant collar with GPS tracker and artificial intelligence on the edge (TinyML)
The collar uses two MCUs along with a Ublox GPS tracker and MQ135 air quality sensor. Two MCUs used in the collar are -
Heltec Wireless Stick Lite ( based on ESP32 chip )
This MCU has BLE 4 and LoRa module. BLE 4 module is used to scan any mobile or bluetooth device near elephant which indicates human presence. LoRa module provides capability to connect to LoRaWan based Helium network without any need of WiFi or GSM.
Arduino Nano BLE Sense
This MCU is mainly used to run edge impulse model locally. It has on-board microcontroller, 3 axis accelerometer and temperature & humidity sensor. 3 axis accelerometer data is feed to edge impulse model to predict elephant's activity such as resting, walking, running or musth behavior.
The microphone is used to capture voice around the elephant and feed to another model to predict situations such as trumpet or rumbling, poachers etc.
Temperature, humidity and air quality are used in combination to predict if there is any fire in the wild.
Nano sends data to Heltec over UART and Heltec sends data to Helium network in certain interval.
The collar is powered by 18650 batteries. I have not done much research on long battery life as that's already done by smart park & open collar.🎃 Demo🖥️ Architecture
Entire ecosystem is comprised of 4 components
- The Collar - which we explained above.
- Helium Network - which is backed by LoRaWAN, first people's network ever. Helium publish messages to MQTT channel when it receives UPLINK data from the collar.
- NodeJS Backend - which uses IoT Connect SDK to interact with Avnet IoT Connect dashboard. It listens for incoming messages from MQTT.
- Avnet IoT Connect Dashboard - Visualization of the sensor data and alerts to help park rangers monitor important data most effectively and get notified of any situation such as elephant moving out of park, entering into risk zone or any sign of human presence.
Let's take a deeper dive into each components and how they are used.🕸️ Helium Network
Helium is based on LoRaWan protocol which naturally provides Long Range (LoRa) coverage compared to Wifi or Bluetooth.
I was looking for a solution without GSM or WiFi. African elephants live very far in the forrest and changes are there is very poor GSM connection. Moreover the cost of GSM connection is very high when compared with Helium. Each helium hotspots can provide coverage for around 3-5 miles radius in the wild. With powerful antenna and very high altitude we can increase the coverage even further. The cost of data from device to helium network will be paid of by the earning of those hotspots.
So only cost would be to install those hotspots and data transfer from hotspot to blockchain. One hotspot can connect to thousands of devices. We can also consider building DIY helium hotspots with cloud backend miner which will further reduce the cost data and processing power on the hotspot itself. For more detail about DIY hotspot, take a look at this project on Hackster.
Each collar is registered with Helium console and configured with MQTT integration channel.
Heltec LoRa module will send data packets to helium console periodically and helium will delegate that message to MQTT channel.📊 Avnet IoT Connect Platform
IoT Connect is the only IoT platform available in the market that comes with a powerful device management system and built-in analytics that allows you to connect and manage devices with little to no coding. Its powerful yet easy-to-use interface enables enterprises to create applications faster than laborious coding saving a lot of time and money.
IoT Connect provides businesses with the infrastructure required to connect their assets, collect data and analyze it to improve decision-making practices. This is achieved by facilitating device communication and management while adhering to industry-grade security protocols. [ copied from source ]
Setting Up IoT Connect Dashboard
Setting up dashboard in Avnet's IOT Connect platform is super simple but you need to follow few steps before you get there. Let's go though them one by one.
- Create Template
Template defines the data structure a device sensor and also ability to deploy multiple devices using same template. Head over to Template and click on Create Template button.
- Create Attributes
Once your template is created, add some attributes, for example latitude and longitude of the elephant collar.
- Create Device
Once you have your template and attributes created, head over to Device tab and click on Create Device button. Type unique Id and display name. Choose the template you just created above. Choose right Entity and click on Save button.
- Create Custom Dashboard
Let's create a cool dashboard with some widgets. Head over to Dashboard and click on "New Dashboard". Double click on "Device Location" widget from left pane and edit the configuration on right. Choose your template and attributes.
Add some more widgets as necessary to display all the sensor data. I ended up with something like this.
- Create SomeRules
Now let's create some rules to trigger alerts when something unusual happens such as human conflict detected or elephant moves out of geo fencing or enters into risk zones. Head over to Rules tab and start creating rules.
- Simulate The Dashboard
One you have all the pieces wired up on dashboard, simulate the sensor data to make sure dashboard works as you expect.🧱 The NodeJS Backend
NodeJS backend is playing a role of middle-man here. It listens for incoming messages on MQTT topic, decodes the massage and sends to IoT connect using IoT connect SDK. If this service does not receive any message for a given period of time, it assumes the collar is offline and notifies dashboard. There is a very nice and well explained document on Avent website to get started with SDK. You must have nodejs 8+ installed on your computer or server. If you like to build my backend, clone the repository which is listed under code section. Open the project on Visual Studio Code or your favorite IDE.
Before you begin, open backend/config.json file and add values from you Avnet console.
"env" : "Avnet",
Then open terminal and cd into backend folder. Then run following commands.
If all goes well, you should see your backend made connection to dashboard and status circle will turn green from red.📈 Edge Impulse
Undoubtedly machine learning (ML) has lot of application when thinking about saving wild animals such as activity monitoring, human conflict detection etc. Unlike normal computer programs, the rules of ML programs are not determined by a developer. Instead, ML uses specialized algorithms to learn rules from data, in a process known as training.
Traditionally we send sensor data from IoT device to cloud and run inference engine on server. This approach has serval flaws such as high latency, high bandwidth consumption, cost of transferring data from IoT device to cloud etc.
Recent advances in microprocessor architecture and algorithm design have made it possible to run sophisticated machine learning workloads on even the smallest of microcontrollers. Embedded machine learning, also known as TinyML, is the field of machine learning when applied to embedded systems such as these.
Edge Impulse had made this journey freaking simple. As a developer you can capture data, train them and finally deploy on your IoT device from Edge Impulse website. You don't need any additional hardware. It has official support for few boards include Arduino Nano BLE Sense which means you can connect your Nano directly to Edge Impulse studio, collect data, train data and deploy back to your Nano.
The elephant collar uses two EI models
1. Activity prediction based on 3-Axis accelerometer data
2. Trumpeting or poacher activity based on acoustic sound captured by microphone
As I can't collect real data from elephants, I simulated elephant walk, rest, run and musth behavior using a toy elephant 🤔
First you need to create a project in EI Studio and connect your Nano.
Next you need to collect data while Nano is connected to EI Studio. Head over to data acquisition tab and start collecting data for 4 labels - Musth, Resting, Running & Walk. Collect at least 2 minutes of data for each labels for better prediction.
Then add the processing block and learning as below. Follow the tutorial I linked above for step by step guide.
Once your model is trained, head over to live classification tab and test your model against live data.
Once you are satisfied with the classification result, head over to Deployment tab and select "Arduino" and build the model.
This will create the binary with sample Arduino sketches. Follow the instruction on screen to import the library to your Arduino IDE. If you are interested in my code, checkout the code section below.
Similarly I have created 2nd ML model capturing acoustic sound by the on-board microcontroller. Follow this tutorial for step by step guide on how to capture sound and build the model.
Alright, so I have explained all the component and how they are linked together to make this awesome, smart collar. Now it's time to explore all the features this collar is bringing on the table and how it can solve or reduce major threats to elephants we discussed at the very beginning.👏 Features Of The Collar
1. GPS Tracking
First thing first. As we are making collars to track position of each precious elephants in the wild, we need gps tracking and visualize the position on dashboard. I got the basic covered. 😊The collar has ublox Neo 6M GPS module to track gps coordinates. For better performance and low power usage we should think about advanced ublox GNSS modules such as M9N.
2. Geo Fencing & Risk Zone Alerts
As we are tracking gps location, system will alert park rangers from dashboard immediately when an elephant is moving out of the defined territory or entering into a risky zone such as village. Park rangers can take immediate action to retrieve the elephant and avoid any poaching risk or human-elephant conflict.
3. Human Presence Detection and Alert
On collar Heltec Wireless Stick Lite microcontroller has bluetooth module which is used to scan any bluetooth devices near by. Any presence of bluetooth device in the wild will indicate human presence and notify park rangers immediately so that they can take required action on time.
4. Elephant Activity Monitoring and Musth BehaviorDetection
Using 3-Axis accelerometer and edge impulse model deployed on Arduino Nano, collar can predict elephant activities such as walking, resting, running or any aggressive behavior such as musth. All the activities will be easily visualized on the dashboard.
If any aggressive behavior is detected, park rangers will be notified immediately so that they can reduce the damage.
5. Collar Malfunction Alerts
Collar sends remaining battery life which is visualized on the dashboard. System sends alert when battery life goes below a threshold. Backend system also keeps track if receiving incoming messages from the collar. If backend does not receive any message that would indicate device is malfunctioning or offline. Park rangers will be alerted immediately.
6. Poaching Risk Alerts
Another fine use of edge impulse model running on Arduino Nano. The model is trained to detect any aggressive or feared acoustics of elephants such as trumpet, rumbling and crowd voices, gun shots etc.
7. Wild Fire Detection Alert
This feature definitely calls for extra credit 😊 Collar has MQ315 air quality sensor which can detect smoke in the air. Along with smoke and temperature sensor, we can predict is there is any wild fire and alert park rangers immediately.❓What's Next?
EI is capable of image processing. We may think about including cheap arduino cameras and predict more accurate situation such as poachers spotted or carcasses found. To keep the cost low, we may add cameras to selected elephants not all.
We may deploy some autonomous drones which will be triggered when poachers are detected or any carcasses are found. The drones will hover over the impacted area and provide more information about the incident through live video streaming. This would eliminate any false alarms and details insight.