TinyML: It’s a Gas!

The oil and gas industry is critically important as it supplies the raw materials that serve as the world’s primary fuel sources. The processes and systems used in the industry rely on state-of-the-art technologies to produce and distribute the oil and gas, and in the midst of all of that complexity lurks the possibility that something can go awry from time to time. Along these lines, one of the primary concerns is gas leaks. These leaks can happen at any stage of production, from drilling to transportation. Leaks that go undetected pose workers with a wide range of potential health hazards — flammable gasses or vapors can ignite, and noxious fumes can lead to illness or even death.

Traditionally, monitoring for gas leaks is done by placing sensors at strategic locations throughout a facility. The sensors cannot be in all places at once, so they may not immediately detect a leak if it is not nearby. Moreover, these sensors often transmit their data wirelessly to a central location where human operators decide what action to take. As such, any breakdown in communications could leave the operators blind to potential problems. The engineers at Zalmotek have put forward an idea for a new type of gas leak detector that solves these issues, and might even be capable of more accurately detecting gas leaks.

Nordic Semiconductor Thingy:91 multi-sensor cellular IoT prototyping platform

Their proof of concept design uses inexpensive hardware that can go anywhere, even on the workers themselves, which has the potential to greatly increase the density of sensors in an area. And by leveraging the Edge Impulse machine learning development platform, gas detections were made more accurate than traditional sensors by incorporating an intelligent algorithm into the device. Since the algorithm is optimized to run on-device, wireless network availability is not required to sound an alarm. That is a lot of upgrades to pack into just over five square inches of space!

The tiny device occupying that space is a Nordic Thingy:91 cellular IoT prototyping platform. It is based on the powerful nRF9160 system-in package, and is a multi-sensor device equipped with an environmental sensor suite, LTE connectivity, and full compatibility with Edge Impulse machine learning models. The onboard air quality sensor can detect a wide range of gasses, including methane, carbon monoxide, and hydrogen sulfide. That air quality sensor was put to use to detect CO2, CO, and isopropanol for the prototype build. Since gas sensor data can contain a good deal of noise, which can make it difficult to interpret, a machine learning model was built to predict when high concentrations of these gasses were present and likely to be representative of an actual gas leak.

The Thingy:91 is a great platform for smart wearables

As is always the case, the machine learning algorithm needed sample data to learn from before it could be put into service, so Zalmotek downloaded the Edge Impulse Nordic Thingy:91 firmware and flashed it to the device. This linked the Thingy:91 to their Edge Impulse Studio project, and as sensor data was collected, it was automatically uploaded to that project. By mixing baking soda and vinegar in a confined area, they were able to create high concentrations of CO2. Similarly, wood smoke was used to generate high levels of CO, and a bottle of 97% concentration isopropanol provided sensor measurements for the third and final gas. Data was also captured under normal conditions, without any gasses being generated through artificial means.

Designing an intelligent algorithm with Edge Impulse Studio

All of the gas data was combined into a “gas leak” class, and the remainder was labeled as “normal.” With data collection out of the way, an impulse was created to analyze gas samples. It began with a preprocessing step that splits sensor readings into two second windows. Those measurements were then fed into a neural network classifier. After tuning the model’s hyperparameters, the training process was kicked off.  After a short time, training had completed, and a confusion matrix was presented to help in understanding how well the model was performing. An average classification accuracy rate of better than 86% had been achieved. This result was further validated using the more stringent model testing tool. This reported that a classification accuracy of nearly 96% was observed on data that was not included in the training process.

Increasing the model performance

This is an excellent result already, but to demonstrate how a great model can be made even better, Zalmotek increased the number of training cycles and the learning rate. Running the model testing tool after this tweak showed that the classification accuracy had climbed to 100%. There was no further room left for improvement, so the machine learning analysis pipeline was deployed to the Nordic Thingy:91. Since the board is fully supported by Edge Impulse, a custom firmware image was available for download that contained the entire pipeline. After flashing it to the device, it was immediately up and running, acting as a gas leak detector. Zalmotek notes that the pipeline could also be deployed as a C++ library, which would offer the flexibility to add in one’s own logic.  This would make it possible to trigger alarms, log data, send notifications remotely, or anything else that your project might require.

Zalmotek showed how easy it can be to use Edge Impulse to quickly build a prototype that may one day transform an entire industry. If you are not yet convinced that it is as easy as all of that, take a peek at the project documentation to see for yourself. You can even get a jumpstart on bringing your own ideas to life by cloning the public Edge Impulse project. If you still have any questions or need any assistance at all, you can always reach out to us and one of our experts will be happy to help.


Want to see Edge Impulse in action? Schedule a demo today.

Subscribe

Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter