Ionizing radiation is a nonthermal process utilized to achieve the preservation of food. At a maximum commercial irradiation dose of 10 kGy, irradiation does not impart heat to the food, and the nutritional quality of the food is generally unaffected. The irradiation process can reduce the microbial contamination of food, resulting in improved microbial safety as well as the extended shelf-life of the food[1]. Irradiation also benefits the consumer by reducing the risk of severe health issues caused by foodborne illnesses. Food irradiation has three categories: low-dose (radurization), medium-dose (radicidation), and high-dose (radappertization). Low dose irradiation (under 1 kGy) inhibits the sprouting of produce (onion, potato, and garlic); retards the ripening and fungi deterioration of fruits and vegetables (strawberry, tomato, etc.), and promotes insect disinfestations in cereals and vegetables. Medium dose irradiation (between 1 and 10 kGy) controls the presence of pathogenic organisms, especially in fruit juices; retards the deterioration of fish and fresh meat; and reduces Salmonella in poultry products, similar to pasteurization. High dose irradiation (over 10 kGy) is rather significant to the sterilization of health and personal hygiene products[2].

Since foods treated with ionizing radiation should be adequately labeled under the general labeling requirements, consumers can make their own free choice between irradiated and non-irradiated food. However, unfortunately, some countries do not apply strict regulations for irradiated foods, especially for animal feed. Therefore, detecting proper irradiation doses can be arduous for small businesses in the food industry due to governments not incentivizing strictly regulated food irradiation processes. Since irradiation can engender certain alterations that can modify the chemical composition and nutritive values of food, depending on the factors such as irradiation dose, food composition, packaging, and processing conditions such as temperature and atmospheric oxygen saturation[2], unsupervised food irradiation portends health issues.

After scrutinizing recent research papers on food irradiation, I decided to utilize ionizing radiation, weight, and visible light (color) measurements denoting the applied irradiation dose so as to create a budget-friendly and accessible device to predict food irradiation dose levels in the hope of assisting small businesses in checking compliance with existing regulations on food irradiation.

Although ionizing radiation, weight, and visible light (color) measurements provide insight into detecting food irradiation doses, it is not possible to conclude and interpret food irradiation doses precisely by merely employing limited data without applying complex algorithms since food irradiation dose levels fluctuate depending on processing techniques, food characteristics, and equipment. Therefore, I decided to build and train an artificial neural network model by utilizing the theoretically assigned food irradiation dose classes to predict food irradiation dose levels based on ionizing radiation, weight, and visible light (color) measurements. Since I could not apply ionizing radiation directly to foods by emitting Gamma rays, X-rays, or electron beams, I exposed foods to sun rays as a natural source of radiation for estimated periods.

Since Beetle ESP32-C3 is an ultra-small size development board intended for IoT applications, that can easily collect data and run my neural network model after being trained to predict food irradiation doses, I decided to employ Beetle ESP32-C3 in this project. To obtain the required measurements to train my model, I utilized a Geiger counter module (Gravity), an I2C weight sensor (Gravity), and an AS7341 11-channel visible light sensor (Gravity). Since Beetle ESP32-C3 is equipped with an expansion board providing the GDI display interface, I connected an SSD1309 OLED transparent screen (Fermion) to display the collected data.

After collecting data successfully, I developed a PHP web application that obtains the transmitted data from Beetle ESP32-C3 via HTTP GET requests, logs the received measurements in a given MySQL database table, and lets the user create appropriately formatted samples for Edge Impulse.

After completing my data set and creating samples, I built my artificial neural network model (ANN) with Edge Impulse to make predictions on food irradiation dose levels (classes) based on ionizing radiation, weight, and visible light (color) measurements. Since Edge Impulse is nearly compatible with all microcontrollers and development boards, I had not encountered any issues while uploading and running my model on Beetle ESP32-C3. As labels, I employed the theoretically assigned food irradiation dose classes for each data record while collecting and logging data:

After training and testing my neural network model, I deployed and uploaded the model on Beetle ESP32-C3. Therefore, the device is capable of detecting precise food irradiation dose levels (classes) by running the model independently without any additional procedures.

Lastly, to make the device as robust and compact as possible while experimenting with a motley collection of foods, I designed a Hulk-inspired structure with a moveable visible light sensor handle (3D printable).

So, this is my project in a nutshell 😃

In the following steps, you can find more detailed information on coding, logging data via a web application, building a neural network model with Edge Impulse, and running it on Beetle ESP32-C3.

🎁🎨 Huge thanks to DFRobot for sponsoring these products:

⭐ Beetle ESP32-C3 | Inspect

⭐ Gravity: Geiger Counter Module | Inspect

⭐ Gravity: I2C 1Kg Weight Sensor Kit | Inspect

⭐ Gravity: AS7341 11-Channel Visible Light Sensor | Inspect

⭐ Fermion: 1.51” OLED Transparent Display | Inspect

🎁🎨 If you want to purchase products from DFRobot, you can use my $5 discount coupon.

🎁🎨 Also, huge thanks to Creality for sending me a Creality CR-200B 3D Printer.

Step 1: Designing and printing a Hulk-inspired structure

Since this project is for detecting irradiation doses of foods treated with ionizing radiation, I got inspired by the most prominent fictional Gamma radiation expert, Bruce Banner (aka, The Incredible Hulk), to design a unique structure so as to create a robust and compact device flawlessly operating while collecting data from foods. To collect data with the visible light sensor at different angles, I added a moveable handle to the structure, including a slot and a hook for hanging the sensor.

I designed the structure and its moveable handle in Autodesk Fusion 360. You can download their STL files below.

For the Hulk replica affixed to the top of the structure, I utilized this model from Thingiverse:

Then, I sliced all 3D models (STL files) in Ultimaker Cura.

Since I wanted to create a solid structure for this device with a moveable handle and complement the Hulk theme gloriously, I utilized these PLA filaments:

Finally, I printed all parts (models) with my Creality CR-200B 3D Printer. It is my first fully-enclosed FDM 3D printer, and I must say that I got excellent prints effortlessly with the CR-200B :)

If you are a maker planning to print your 3D models to create more complex projects, I highly recommend the CR-200B. Since the CR-200B is fully-enclosed, you can print high-resolution 3D models with PLA and ABS filaments. Also, it has a smart filament runout sensor and the resume printing option for power failures.

According to my experience, there are only two downsides of the CR-200B: relatively small build size (200 x 200 x 200 mm) and manual leveling. Conversely, thanks to the large leveling nuts and assisted leveling, I was able to level the bed and start printing my first model in less than 30 minutes.

#️⃣ Before the first use, remove unnecessary cable ties and apply grease to the rails.

#️⃣ Test the nozzle and hot bed temperatures.

#️⃣ Go to Settings ➡ Leveling and adjust four predefined points by utilizing the leveling nuts.

#️⃣ Finally, attach the spool holder and feed the extruder with the filament.

#️⃣ Since the CR-200B is not officially supported by Cura, select the Ender-3 profile and change the build size to 200 x 200 x 200 mm. Also, to compensate for the nozzle placement, set the Nozzle offset X and Y values to -10 mm on the Extruder 1 tab.

Step 1.1: Assembling the structure and making connections & adjustments

// Connections
// Beetle ESP32-C3 : 
//                                Gravity: Geiger Counter Module
// D5   --------------------------- D
// VCC  --------------------------- +
// GND  --------------------------- -
//                                Gravity: I2C 1Kg Weight Sensor Kit - HX711
// VCC  --------------------------- VCC
// GND  --------------------------- GND
// D9   --------------------------- SCL
// D8   --------------------------- SDA
//                                Fermion: 1.51” SSD1309 OLED Transparent Display
// D4   --------------------------- SCLK
// D6   --------------------------- MOSI
// D7   --------------------------- CS
// D2   --------------------------- RES
// D1   --------------------------- DC
//                                AS7341 11-Channel Spectral Color Sensor
// VCC  --------------------------- +
// GND  --------------------------- -
// D9   --------------------------- C
// D8   --------------------------- D
//                                Control Button (A)
// D0   --------------------------- +
//                                Control Button (B)
// D20  --------------------------- +
//                                Control Button (C)
// D21  --------------------------- +

First of all, I soldered male pin headers to Beetle ESP32-C3 and its expansion board.

Then, to collect ionizing radiation, weight, and color (visible light) measurements, I connected a Geiger counter module (Gravity), an I2C HX711 weight sensor (Gravity), and an AS7341 11-channel visible light sensor (Gravity) to Beetle ESP32-C3. Since the expansion board provides the GDI display interface for DFRobot screens, I was able to connect the SSD1309 OLED transparent screen (Fermion) to Beetle ESP32-C3 via the expansion board.

After assembling the weight sensor kit, to calibrate the weight sensor in order to get accurate measurements, press the cal button on the adapter board. Then, wait for the indicator LED to turn on and place a 100 g (default value) object on the scale within 5 seconds. When the adapter board completes calibration, the indicator LED blinks three times.

Since Beetle ESP32-C3 cannot power the Geiger counter module and the weight sensor simultaneously due to its working current, I connected a USB buck-boost converter board to my Xiaomi power bank to elicit stable 3.3V to supply the sensors.

Since the Geiger counter library needs to use an external interrupt pin for counting, the Geiger counter module can only be connected to external interrupt pins. Plausibly, Beetle ESP32-C3 allows the user to define any pin as an external interrupt.

To assign labels while transmitting the collected data and run my neural network model effortlessly, I added three control buttons (6x6), as shown in the schematic below.

After completing sensor connections and adjustments on breadboards successfully, I made the breadboard connection points rigid by utilizing a hot glue gun.

After printing all parts (models), I fastened all components except the visible light sensor to their corresponding slots on the structure via the hot glue gun.

Then, I attached the visible light sensor to the moveable handle and hung it via its slot in the structure.

Finally, I affixed the Hulk replica to the top of the structure via the hot glue gun.

Step 2: Developing a web application in PHP to collate data on food irradiation doses

Inspect.

Step 3: Setting up a LAMP web server on Raspberry Pi

Inspect.

Step 4: Setting up Beetle ESP32-C3 on the Arduino IDE

Before proceeding with the following steps, I needed to set up Beetle ESP32-C3 on the Arduino IDE and install the required libraries for this project.

If your computer cannot recognize Beetle ESP32-C3 when plugged in via a USB cable, connect Pin 9 to GND (pull-down) and try again.

#️⃣ To add the ESP32-C3 board package to the Arduino IDE, navigate to File ➡ Preferences and paste the URL below under Additional Boards Manager URLs.

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

#️⃣ Then, to install the required core, navigate to Tools ➡ Board ➡ Boards Manager and search for esp32.

#️⃣ To print data on the serial monitor, enable USB CDC On Boot after setting Beetle ESP32-C3.

#️⃣ Finally, download the required libraries for the Geiger counter module, the I2C HX711 weight sensor, the AS7341 visible light sensor, and the SSD1309 OLED transparent screen:

DFRobot_Geiger | Download

DFRobot_HX711_I2C | Download

DFRobot_AS7341 | Download

U8g2_Arduino | Download

Step 4.1: Displaying images on the SSD1309 transparent OLED screen

To display images (monochrome) on the SSD1309 transparent OLED screen successfully, I needed to convert PNG or JPG files into the XBM (X Bitmap Graphic) file format.

#️⃣ First of all, download GIMP.

#️⃣ Then, upload an image (black and white) and go to Image ➡ Scale Image... to resize the uploaded image.

#️⃣ Go to Image ➡ Mode and select Grayscale.

#️⃣ Finally, export the image as an XBM file.

#️⃣ After exporting the image, add the generated data array to the code and print it on the screen.

u8g2.firstPage();      do{      //u8g2.setBitmapMode(true /* transparent*/);      u8g2.drawXBMP( /* x=*/36 , /* y=*/0 , /* width=*/50 , /* height=*/50 , data_colllect_bits);    }while(u8g2.nextPage());

Step 5: Collecting and storing food irradiation data w/ Beetle ESP32-C3

Inspect.

Step 5.1: Logging the collected data into the MySQL database

After uploading and running the code for collecting data and transmitting data packets to the web application on Beetle ESP32-C3:

☢️🍱 The device waits for the Wi-Fi module to connect to the given Wi-Fi network.

☢️🍱 Then, the device displays a modicum of the collected data on the SSD1309 OLED transparent screen.

☢️🍱 The device allows the user to collect visible light (color) data at different angles with the moveable handle.

☢️🍱 If one of the control buttons (A, B, or C) is pressed, the device transmits the recently collected data by adding the selected food irradiation dose class to the given web application.

☢️🍱 Then, if the web application appends the transferred data packet to the MySQL database successfully, the device shows this message on the SSD1309 OLED transparent screen: Data registered successfully!

☢️🍱 If Beetle ESP32-C3 throws an error while operating, the device shows the error message on the SSD1309 OLED transparent screen and prints the error details on the serial monitor.

☢️🍱 Also, the device prints notifications and sensor measurements on the serial monitor for debugging.

As far as my experiments go, the device operates impeccably while collecting measurements and transmitting data packets to a given web application :)

Step 5.2: Creating samples from data records with the web application

After logging ionizing radiation, weight, and visible light (color) measurements in the MySQL database from a motley collection of foods, exposed to sun rays as a natural source of radiation for estimated periods, I elicited my data set with eminent validity.

📌Foods:

As explained in Step 2, I generated a CSV file (sample) for each data record in the MySQL database by utilizing the web application.

☢️🍱 The web application shows the total number of data records for classes (labels) in the database.

☢️🍱 If the user clicks the Create Samples button, the web application scales data items and generates a CSV file (sample) for each data record, depending on the selected data type (training or testing).

☢️🍱 If the user clicks the Download button, the web application downloads all generated CSV files (samples) in the ZIP file format.

📌 Training samples:

📌 Testing samples:

Step 6: Building a neural network model with Edge Impulse

When I completed collating my food irradiation dose data set and assigning labels, I had started to work on my artificial neural network model (ANN) to make predictions on food irradiation dose levels (classes) based on ionizing radiation, weight, and visible light (color) measurements.

Since Edge Impulse supports almost every microcontroller and development board due to its model deployment options, I decided to utilize Edge Impulse to build my artificial neural network model. Also, Edge Impulse makes scaling embedded ML applications easier and faster for edge devices such as Beetle ESP32-C3.

Even though Edge Impulse supports CSV files to upload samples, the data type should be time series to upload all data records in a single file. Therefore, I needed to follow the steps below to format my data set so as to train my model accurately:

As explained in the previous steps, I utilized the web application to scale (normalize) and preprocess data records to create CSV files (samples) for Edge Impulse.

Since the assigned classes are stored under the class data field in the MySQL database, I preprocessed my data set effortlessly to obtain labels for each data record while generating samples:

Plausibly, Edge Impulse allows building predictive models optimized in size and accuracy automatically and deploying the trained model as an Arduino library. Therefore, after scaling (normalizing) and preprocessing my data set to create samples, I was able to build an accurate neural network model to forecast food irradiation dose levels and run it on Beetle ESP32-C3 effortlessly.

You can inspect my neural network model on Edge Impulse as a public project.

Step 6.1: Uploading samples to Edge Impulse

Inspect.

Step 6.2: Training the model on food irradiation dose levels

Inspect.

Step 6.3: Evaluating the model accuracy and deploying the model

Inspect.

Step 7: Setting up the Edge Impulse model on Beetle ESP32-C3

Inspect.

Step 8: Running the model on Beetle ESP32-C3 to make predictions on food irradiation doses

When the features array (buffer) is full with data items, my Edge Impulse neural network model predicts possibilities of labels (food irradiation dose classes) for the given features buffer as an array of 3 numbers. They represent the model's "confidence" that the given features buffer corresponds to each of the three different food irradiation dose levels (classes) based on ionizing radiation, weight, and visible light (color) measurements [0 - 2], as shown in Step 6:

After executing the IoT_food_irradiation_run_model.ino file on Beetle ESP32-C3:

☢️🍱 The device displays a modicum of the collected data on the SSD1309 OLED transparent screen.

☢️🍱 If the control button (B) is pressed, the device runs an inference with the Edge Impulse model by filling the features buffer with the recently collected ionizing radiation, weight, and visible light (color) measurements.

☢️🍱 When the device starts filling the features buffer with data items, it shows:

☢️🍱 Then, the device displays the detection result, which represents the most accurate label (food irradiation dose class) predicted by the model.

☢️🍱 Each food irradiation dose level (class) has a unique monochrome icon to be shown on the SSD1309 OLED transparent screen when being predicted (detected) by the model:

☢️🍱 Also, the device prints notifications and sensor measurements on the serial monitor for debugging.

As far as my experiments go, the device predicts food irradiation dose levels (classes) accurately by employing the collected measurements :)

Videos and Conclusion

After completing all steps above and experimenting, I have employed the device to predict and detect food irradiation dose levels of various foods and food packaging so as to check whether they conform to health and safety standards regarding food irradiation.

Further Discussions

By applying neural network models trained on ionizing radiation, weight, and visible light (color) measurements in detecting food irradiation dose levels, we can achieve to[3]:

☢️🍱 prevent changes to the packaging that might affect integrity as a barrier to microbial contamination,

☢️🍱 avert producing radiolysis products that could migrate into food, affecting odor, taste, and possibly the safety of the food,

☢️🍱 preclude inadvertent radiation effects on polymers in food packaging due to competing crosslinking or chain scission reactions.

References

[1] Vanee Komolprasert. "CHAPTER 6: PACKAGING FOR FOODS TREATED BY IONIZING RADIATION." Packaging for Nonthermal Processing of Food. Blackwell Publishing, First edition, 2007. 87 - 88.

[2] Ana Paula Dionísio, Renata Takassugui Gomes, and Marília Oetterer. Ionizing Radiation Effects on Food Vitamins – A Review. Braz. Arch. Biol. Technol. v.52 n.5: pp. 1267-1278, Sept/Oct 2009

[3] Kim M. Morehouse and Vanee Komolprasert. Overview of Irradiation of Food and Packaging. ACS Symposium Series 875, Irradiation of Food and Packaging, 2004, Chapter 1, Pages 1-11. https://www.fda.gov/food/irradiation-food-packaging/overview-irradiation-food-and-packaging.