Edge Impulse logo
Blog Post

Safer, More Nutritious Food with tinyML

Machine Learning, TinyMLBuild a machine learning-powered food irradiation detection device using an ESP32 board, Geiger counter module, and visible light sensor.

Nick Bild

June 22, 2022

    Early Atomic Age notions, reinforced by science fiction of the era, that radiation might mutate tiny creatures like ants into giant city-destroying beasts now seem rather quaint. We know better now, but the knowledge gained in the intervening years has not alleviated all of our concerns around harnessing this power, but instead has shifted them to more tangible, real-world problems. As a case in point, consider food irradiation. It is well understood that food irradiation improves food hygiene, reduces spoilage, and extends its shelf life. But as is so often true, there can be too much of a good thing — excessive irradiation can reduce the nutritional content of food, and may also lead to health issues in those that eat the treated foods.

    Unfortunately, it can be a challenge to ensure that foods have not received excessively large doses of radiation. In the food industry, small businesses in particular tend to lack a simple, low-cost method to detect irradiation dose levels after treating foods. Machine learning enthusiast Kutluhan Aktar found this situation to be troubling, considering the potential health problems that can be caused, so he got to work studying the recent literature in search of a solution. His goal was to find some easily measurable parameters that could serve as a proxy for irradiation levels. His research suggested that food weight, color, and emitted ionizing radiation would likely fit the bill.​

     Hulk-inspired structure with a moveable visible light sensor handle

    Exactly how the complex interplay between these parameters translate into irradiation levels is by no means clear, however. So, rather than spend months or years trying to understand the relationships, Aktar decided to use Edge Impulse to build an artificial neural network to do that difficult work for him. To bring this idea to life, an appropriate hardware platform was also needed, and the DFRobot Beetle ESP32-C3 development board was selected for the role. This tiny board comes with an ESP32-C3 RISC-V 32 bit single-core processor and 400 KB of SRAM that are perfect for running Edge Impulse models that have been optimized for resource-constrained devices. The Beetle is also extensible, and Aktar took advantage of that fact to add in some sensors — a Geiger counter module, a weight sensor kit, and an 11-channel visible light sensor. A small OLED was also included in the design to provide a simple user interface.

    Prototyping the hardware design

    A case was 3D-printed to house all of the hardware, and provide a platform for analysis of foods. After the hardware was assembled and housed in the casing, Aktar’s attention was turned to building the machine learning analysis pipeline. As a first step, he needed to collect sensor data from food that had been exposed to varying quantities of radiation.  After checking his parts bin for an unlicensed nuclear accelerator and coming up short, Aktar decided on a more realistic approach to irradiating foods — he left them out in the sunshine. Depending on the time spent soaking up the sun, measurements were labeled as “regulated," “unsafe,” or “hazardous.”

    Collecting training data

    The collected data was formatted as CSV files, then uploaded to Edge Impulse Studio.  Each sample was automatically assigned to its respective class based on the name of the file. The raw data was then fed into a neural network classifier to translate the various sensor measurements into one of the three chosen classes. After training the model, it was tested on a fresh dataset that the model had not yet been shown. An average classification accuracy of 96.3% was found. Well, it looks like Aktar’s research paid off — it seems that the selected parameters are quite capable of detecting food irradiation levels!

    Model testing results

    Before the project could be called a success, the model needed to be deployed to the physical device that was previously constructed. One of the many options that Edge Impulse provides for deployment is the download of an Arduino library. Aktar chose this option, then incorporated the library into his own project with a few clicks. He then ran some live tests of the completed device with irradiated food samples and found it to perform accurate classifications.

    This project provides yet another example of the ease with which an innovative new idea can be brought to life using tools like Edge Impulse and the Beetle ESP32-C3 development board. In a matter of a few days time, a device can be created that has the potential to transform important safety processes that can protect human health and improve nutrition. Aktar has provided copious details in the project write-up — we highly recommend that you check it out to stoke your own creativity, and learn a few things in the process.


    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