Food and Formalin Detector Using Machine Learning Approach

Unethical use of formalin, in the preservation of food items posing threat to public health. Without chemical experts accurately Formalin detection is a time consuming and complicated task. Moreover, the presence of naturally occurring formalin in food items may interfere in detecting artificially added formalin. Purpose of the study was to develop a simple cost-effective and reliable detection technique that can detect contaminated food. Therefore, quantifying artificially added formalin and naturally formed extent it is important to dynamically detect food for the comparison. With this view in mind, we have applied different machine learning algorithms like Naïve Bayes, Logistic regression, Support Vector Machine, K-NN Classifier on fruit’s feature dataset to build a predictive model. We found that the K-NN algorithm works best in terms of accuracy. Finally using food conductance to electricity Rules have been developed and uploaded to the microcontroller unit. Combining with Arduino and the VOC HCHO gas sensor our own android application is able to detect 1-50 ppm of formalin. Several Tests are conducted and polynomial regression has been applied to predict the concentration of formalin in a given sample.


List of Tables
. The exceeding level of formalin in air cause unfavorable outcomes like watery eyes; burning sensations in the eyes, nose, and throat; coughing; wheezing; nausea; and skin irritation [4]. The statement from NIOSH, 20 ppm of formalin is very harmful to human and life [2].
Considering the harmful condition of the human, OSHA set many standards to use formalin [4]. In the workplace like lab, office permissible exposure limit (PEL) for formalin is 0.75 parts per million parts of air (0.75 ppm) [4]. Another standard is the short-term exposure limit (STEL) that's range is 2ppm.
Now the concentration of formalin can be detected various way like e-nose technology, sensing formalin chemically [4]. To know the concentration of formalin a detector can be used. The detector can detect the formalin by sensing the presence of formalin in the air. This volatile chemical compound detector helps a person to identify the fruit which he/she doesn't know Contaminated or not [3]. This detector also helps the person to know the concentration of formalin which is safe or unsafe for his/her health. However, Formalin can be naturally found in foods, such as meats, fish, fruits and vegetables, dried mushroom and crustacean, as a typical metabolic by-product [5]. Presence of formalin content conjointly varies with the food conditions and items. This doesn't imply that formaldehyde isn't toxic. Any intense compound is probably going to be harmful in large doses; however, the span of the dosage, how it is devoured and who is presented to it makes a difference. As formalin naturally presents in food items, it could interfere with artificially added formalin when they are going to be detected. It is important to quantify the artificially added formalin from naturally occurring formalin in food items. We have applied various algorithms to the dataset we are working on. The accuracy of detecting sample food of different algorithms is different.
We measured the accuracy of the following algorithms: The performance measure was different for each of the algorithms. We compared these algorithms on the same train and test dataset so that the decision of which algorithm works better on these algorithms can be taken. We found that K-NN Classifier provides the best accuracy among the algorithms we applied. The other algorithm also did well in other performance measures. Later in this paper, these performance measures are compared.

Motivation
The extensive admixture of up to date fruits, vegetables and fish with malignant concentrations of formalin has become a crucial outcome in People's Republic of Bangladesh which causes health risk of the human [5]. Due to lack of adequate observation and raids, an Excessive concentration of solution has been found in most fruits of the native market. Most of our citizens frequently shop for fruits and vegetables. Half of them buy these from the edge hawkers. These places are not monitored by mobile courts. For this to detect the moderate level of formalin in food especially in fruits and vegetables, we have to develop the idea of formalin detection system using machine learning algorithm like polynomial regression, rule base classification.

Problem Statement
Most of the fruits and vegetables naturally contain formalin in them and the amount varies with the food items. For this reason fruit identification is necessary for separating natural occurring formalin from artificially added formalin. Only sensing raw formalin without a predefine model of naturally formed formalin result could be misleading. On the other hand, sensing formalin chemically in contaminated food is not appropriate for general use. A digitalized device with pre-trained model could be a better solution for non-technical person using their own sell phone.

Objectives
The main objective of the project under the scrutiny is: 1. To develop an IoT based designed model to detect the presence of formalin in fruits and vegetables using machine learning approaches.

Outline of this Report
The layout of rest of this report has been organized as takes after.
Chapter 2 presents the literature review on the topic of Fruit and Formalin Detection.
Chapter 3 clarifies hardware specification of the components used in the project.
Chapter 4 explains methodology of the project that how the project being implemented.
Chapter 5 presents the real implementation of the project.
Chapter 6 outlines conclusion of this work precisely and describes the scope of future work for possible extended application of the project.

Literature Review
The surveys from various papers are taken and considered. Some of them are given below: Fruits and vegetables can be detected by a machine in many ways. Arduino based food detection is a simple circuit using resistor can be found in and they detect sample food by measuring the resistance in them. They check resistance range of different foods using Serial Output and use those resistances to make create a range to detect food and display the food name on the LCD screen.
Some paper is mainly focused on the implementation and testing of formalin detector like. The Intense level of using formalin almost all kinds of raw foods, vegetables and dairy products have increased day by day alarmingly and terrifyingly in Bangladesh. Many researches worked to detect the extent of formalin use in fish available in Dhaka city. They collected five species of fishes from five several local markets of Dhaka city and measure the amount of formalin on their samples. Electronic-nose technologies and applications have come through advances in sensor design, software innovations, material improvements and progress in micro circuitry design and systems integration in the present world is proposed in [6].
Different types of sensory instruments and using e-nose technology in agriculture, forestry can be found in [5] and their applications applied in food and dairy industry can be found in [7], pharmaceutical industries and food application using e-noses tongues [8] are also reviewed of this papers. [9]. Another approach is to sense formalin chemically in contaminated food [10]. Simple spot test quantification methods to determine formaldehyde in aqueous samples were also proposed [11]. There are also several other methods proposed for formaldehyde detection, including (pulsed amperometric detection) PAD method [12], solid phase microextraction (SPME) extraction and gas chromatography-mass spectroscopy (GC-MS) analysis [13], gas chromatography-mass spectrometry with selected ion monitor (GC-MS-SIM) [14], by enhanced chemiluminescence [15], using cd-doped TiO2-SnO2 sensor [16] and highly sensitive colorimetric detection method for gaseous formaldehyde [21]. In [17], information is presented on five different local markets of Dhaka city in Bangladesh, where the presence of formalin was detected using the formalin detection kit for fish developed by Bangladesh Council of Scientific and Industrial Research (BCSIR).
Some paper proposes a microcontroller based electronic formalin detection system along with an Android smartphone app to show the results and status of sample food [5], [2]. They applied all methods in a specific environment and different temperatures. However in real life, it may tough to detect the formalin accuracy at any fixed environment and temperature. We know that formalin is a volatile 40% aqueous solution of formaldehyde, this discussed in [21]. Grove sensor is able to detect the presence of formalin.
The voltage output of the HCHO sensor is exponentially proportional to the concentration of formaldehyde gas [11]. In paper [5], their approach was mainly based on Formalin detector system incorporating supervised learning. They implemented a microcontroller based hardware using Grove VOC HCHO gas sensor and developed an android application and detect formalin in different temperatures. They took some sample data from their experimental sample and applied supervised machine learning approach like logistic regression and SVM (Support Vector machine). They used reference as formalin kit which is available in the market. Some Research was developed [3] on the detector that can sense the presence of formaldehyde in air measured in parts per million (ppm) and used SD technology. They used MQ138 which the semiconductor gas sensor used for formaldehyde detection and also monitored the air quality. In computer science, machine learning itself a term intended to identify a singular model that can be applied to any instance in order to make a prediction from sample dataset.

Machine Learning Algorithms
In this section we briefly discuss Naïve Bayes, Logistic regression, Support Vector Machine, K-NN, ruled based Classifier and Polynomial regression, that we applied for detecting the sample fruits and vegetables and formaldehyde in them.

Naïve Bayes
Naive Bayes is a first processing algorithm relative to other machine learning algorithms. It works on Bayes theorem of probability to predict the class of unknown data set. Naive Bayes model is easy to build and particularly useful for very large data sets. It also performs well in multiclass prediction. It is an eager learning algorithm. It is able to make predictions in real time.

Support Vector Machine
Support Vector Machine a supervised machine learning algorithm which can be used for both classification and regression challenges. It is a classification technique that seeks to find a hyperplane that partitions the data by their class label and at the same time avoid over-filtering the data. The learning of the hyperplane in linear SVM is done by transforming the problem by using linear algebra. And it makes a binary classification based on separating hyperplane on a remapped instance space. In SVM, it is easy to have a linear hyperplane between these two classes.

K-NN
KNN means K-Nearest Neighbors algorithm. KNN algorithm is one of the simplest classification algorithms and it is one of the most used learning algorithms. Its purpose is to use a database in which the data points are separated into several classes to predict the classification of a new sample point. KNN is also a lazy algorithm as opposed to an eager algorithm. K-NN keeps all the training data. For more accuracy, K-NN requires all the training data for the testing phase.

Logistic Regression
Logistic regression is the suitable regression analysis to conduct when the dependent variable is dichotomous. Logistic regression is an analytical analysis. Logistic regression is used to define data and to explain the relationship between one dependent binary variable and one or more nominal, ordinal, interval or ratio-level independent variables.

Rule-base Modeling Approach
Rules base machine learning model approach uses a set of rules that specify a mathematical model thus can be translated into Markov chain or different equations. It is especially effective where set of rules is easier than the model it implies, that means the model repeats the demonstration of a limited range of patterns. A biochemical model of living organisms is an important domain for its appliance. Rule base classification can process both categorical and numerical data. Basically rule base classification is a straightforward way to classify data generating if-then rules to cover all cases.

Confusion matrix
Confusion matrix is a convenient way of performance measure of any predictive model. We have calculated Accuracy of the above mentioned algorithms. Accuracy show that how often the classifier is correct. It is mostly used figure to rate any classifier. To measure the performance metrics, the use of confusion matrix is useful and convenient. A confusion matrix is introduced to represent the relation between the actual and predicted class. We can calculate various performance measures from the confusion matrix of any given algorithm along with its accuracy.

Polynomial regression
Polynomial regression is a popular machine learning algorithm. It can be consider as a special type of linear regression. It has two axis X axis stands for the data value and Y axis is used for the Target value.
Polynomial regression might better fit such cases where data may be scattered not linear. Below equation shows the Quadratic Equation of polynomial of degree 3 and where ω is constant.
After reviewed this papers, we observed that using e-nose technologies are easy and costeffective. There are many proposals which based on how formaldehyde can be detected in contaminated foods. We chose the approach which ensures quality measurement of contaminated fruits and vegetables by quality assessment using sensor network.

Familiarization of Hardware
In this chapter, we depict the whole inserted arrangement of our venture where the entire fundamental parts name, their hugeness in the undertaking are portrayed intricately.

Arduino UNO
Founded on the Atmega328 datasheet Arduino UNO is made. It is a microcontroller board. It consists fourteen (14) digital input/output pins among these six(6) will be used as PWM outputs, six (6) analog inputs, a sixteen(16) megahertz quartz oscillator, a USB connection, a power jack, an ICSP header, and a reset button. Everything has in it for the assistance of the microcontroller; that helps to connect it to a PC with a USB cable or power it with an AC-to-DC adapter or battery to start.

Arduino Power
With the help of USB cable or an outer power supply Arduino UNO is powered. The supply source is chosen instinctively. From an AC-to-DC adapter or battery, the outer power will come back. A 2.1 mm center-positive plug is plugged into the board's power jack and the adapter is associated with it. At the top of the power connector the GND and Vin pins are implanted to conduct the battery.6 to 20 volts is the outer power supply to conduct the board. When the supply power is less than 7 volts, the board could be changeable. Again if the supply power is more than 12 volt, so voltage controller will be overheated.
Then the board is spoiled. So the suggested range of the power is 7 to 12 volts.   GND: GND is indicated the Ground pins.

Memory
For the code saving, The Atmega328 contains 32 KB of flash memory. In this 0.5 KB is employed for the bootloader. 2 KB of SRAM and 1 KB of EEPROM is also in it.

Arduino Inputs and Outputs
Arduino has fourteen digital input/output pins. By using pinMode(), digitalRead() and digitalWrite() functions,this pins are used.At 5V,every pins of arduino is operated. It contains an interior pull-up resistor which resistance is 20-50 kohms. It is disconnected by default. Among these fourteen pins, some pins have specific functions that are given below:  Serial Pins 0 (Rx) and 1 (Tx): Rx pins receive the TTL serial information and Tx pins transmit the TTL serial information.
They're associated with same ATmega328P USB to TTL serial chip.

 External Interrupt Pins 2 and 3:
For triggering interrupt or low value, these pins are organized.
 PWM Pins 3, 5, 6, 9 and 11: Using the analog Write () function, these pins produce an 8-bit PWM output.  Arduino has some other pins like AREF and Reset Pin.

Grove HCHO Sensor
The Grove HCHO is a gas sensor. It follows semi conductivity rules to sense an element presence in the air. So it is also a semiconductor gas sensor. In this WSP2110 VOC gas sensor is used for sensing the element. Its conductivity changes with the concentration of gas exist in the air. Grove HCHO sensor is very sensitive and stable sensor because it's ability to sense a gas which concentration is up to 1 ppm.  Fig. 3.3.     The system shows status based on the fruit it detected and the sensor value, output voltage and concentration of formalin in ppm value. Comparing with naturally occurring formalin in food it considers either the food is "safe" or "Dangerous" for health.

Working Procedures of the Device
The working principle of the Food and formalin detection system is elaborated in the Fig. 4.2. Our first target was to detect sample food by the machine with the help of machine leaning approaches.
Second, target was to detect the formalin in the detected fruits. Finally display the result by the Andriod App. Each steps of working procedures of our whole system are described completely in the next chapter.

Preparing Dataset
Dataset we used to build the predictive model was generated by Dr.

Hardware Design and Implementations
A Development research method is applied in our study to come up with a solution to find out formaldehyde detection problem in our daily life. This included hardware assembly and machine learning approaches for the development. The Arduino Uno R3 microcontroller board is attached with other input and output components: Grove HCHO sensor, HC-05 Bluetooth module, 10k ohm resistors and LED.
ATmega328 AVR microcontroller is a dual-inline-package interface with CH340G chip. This works as the brain of the whole system and empowers the system to facilitate the process of formalin detection.
The system is comprised of code using Arduino programing language, testing, debugging and simulating with Arduino IDE.

Hardwire Design of Food Detector
Food detector is a very simple low cost device which is basically follows the principles of physics and chemistry. Different resistances offered by the several food items are measured by the Arduino's analog inputs. For developing the system we used- We know vegetables and fruits could be good source of conductor of electricity because of the presence of juice in them which forms mild acid. Acids are able to conduct electricity just like galvanic cell [19] where conductivity depends on the amount of chemical and water in them. More watery and chemical compound will allow more electrical energy to pass through. Acidic fruits are good conductor of electricity.

Hardware connection
First we place a 10k ohm resistor on the breadboard in parallel and connect one point of the resistor with Arduino A0 analog pin. Then connect another point resistor with GND from Arduino as shown in the Fig.   4.5. A connection wire directly inserted into sample food and it's another terminal comes from Arduino 5 volt pin. The foods we want to test make a close circuit with Arduino. We use those resistances in the food and make range of different foods. Arduino's analog input is using here to measure this resistance offered by the foods.  We create different ranges based on the measured resistances. We write a code for detecting apple, carrot, cucumber and red plum. The code is added at Appendix. However, the resistance values kept changing anomalously from time to time. The reason behind this could be the chemical changes inside the fruit due to air were changing the resistance. Following block Diagram shows the design of the food detection system.

Design of formalin detector sensor
Grove HCHO was the semiconductor VOC sensor used for detecting formaldehyde combining with arduino. This sensor featured to detect gas concentration up to 1 ppm. As formaldehyde is self-vaporized solution, its presence can be detected by volatile organic compound sensor. The output voltage of the sensor is exponentially proportional with the concentration of formalin gas [18].

HCHO Sensor with Arduino
For Connecting HCHO sensor with Arduino required equipment's are:

Android App Development
Our Android application is developed by using MIT App Inventor 2. MIT App Inventor is a cloud based integrated Development Environment (IDE). This is a web based tool for building mobile apps on Android platform by drag and drop option. Graphical interface is used here which is very similar to Scratch. Block-based programming language is used to build the Application which is also known as visual programming [20]. The Designer, Block Editor and Android Emulator are the three section of the app inventor where the work takes place.

App Interface Design
For developing our Apps we follow the below steps: 1. User Interface-Our user interface palette is very simple. One Label and one ListPicker is used which is visible to the user. Label1 is used to display all the result we want to see in our phone Screen. It displays the instruction for the food we detected and sensor value, output voltage and concentration of formalin in ppm value in a sample food received from our device. It also displays the Temperature and humidity of the environment. ListPicker button is used for whose text set as 'Get'. Two Button is used in our app. Button1 is TextToSpeech1 for reading the results from Label1. Button2 is for taking the picture of the food we want to test which is saved in our phone memory. The image will be displayed in the phone screen.
2. Connectivity Palette-Four nonvisible components are used like BluetoothClient1, Clock1, TextToSpeech1 and TinyDB1. BluetoothClient1 and Clock1 required for connecting the device and the app with the Bluetooth module. TextToSpeech1 is used to convert the text into speech.
TinyDB1 is required for saving the picture in the SD Card.

App Blocks Design
Blocks are program the way we want our app to behavior. These Build-in blocks control things like logic, math and the text that want to add with each component. Bluetooth Connection: First we select Before picking from ListPicker and add set the element of list to show the available Bluetooth devices. Again we select After picking from ListPicker and add set status label for connecting with our device to Bluetooth App. When we click on the connect button, connection between HC-05 module and app will be established. When user press on Bluetooth image its elements set as paired Bluetooth address and name so it will show the paired Bluetooth address which is 48 bit long unique code. The screen will be look like Fig.   4.11. Take image and display: We use button2 for clicking photo of our sample photo to be tested. When the button is pressed it called the camera's TakePicture method. Once camera finish taking picture, AfterPicture event occurs which fetch the image. It assigns the image to the picture property of the image control. This makes copy of the image that was just taken and displays it on our phone screen. TinyBD1 is used to store the taken picture in local directory automatically.  Text to speech: This Block is added to read the data we display in label1. When sensor value button is pressed it read all the available data.

Complete Device
The complete device of Food and Formalin detection is show in Fig. 4.15 which is a comprehensive lowcost device. This package is composed with Arduino, sensor, Bluetooth module, LED and our self-made Android App.

Flowchart of the Program
After designing the working principle, the flow chart of the system is implemented where the code and the model is developed and tested. The flowchart of the complete system is shown in Fig. 4  The algorithms we applied show different performance measures. K-nearest neighbors provided the highest accuracy (100.00%) and the Naïve Bayes did the least performance in terms of accuracy (36%).
For this precise dateset, we acquire the highest accuracy when k=5

Experimenting the Range of Resistance in food
Different foods contain different rage of resistance. Arduino's analog pin (A0) was used to measure the voltage drop across the resistance in the piece of fruit or vegetable. We take some sample food like apple, cucumber, carrot, etc. and measure the resistances to create a range using serial output of Arduino. The ranges are outlined in Table 5.2. Rules were established with other features like output voltage, color, width, height and mass of sample food for the analysis.

Developing models
In this phrase fruit is detection by knowledge-based comparison and decision making. Rule base machine learning algorithm pay important rule here to classification and decision making that we already discuss in chapter 2.Using the Rule-base Algorithm we set some rules to detect sample food, some of them are given below in Fig 5.2 :

Train the machine with naturally Occurring forming
The aim of our study is to conduct a sport test to detect artificially added formalin in food items to prohibit its appliance in food. However, formaldehyde is a natural chemical compound which is ubiquitous in our environment and it's also present in many plant and animals for their normal metabolism. It can be also found naturally in different food items including vegetable, fruit, fish and meats [21]. Concentration of natural occurring formalin in food items varies according to conditions and types of food [22]. This natural occurring formalin may interfere in detection of artificially added formalin in food items. Therefore it is important to quantify the artificially added formalin from naturally occurring formalin in food items.
Several researches were conducted on analyzing the naturally occurring formalin in food items [21,22].
Using Secondary data from The Centre for Food Safety (CFS) we create a model to identify the safe or dangerous level of artificially added formalin in food items. Fig 5.4 shows the different level [mg/m3] of natural occurring formalin in fruits and vegetables. We train our model with this value for the further comparison with measured value by our detector. According to NIOSH, 1 ppm = 1.23 mg/m3.

Experiment on detecting Artificially added Formalin from sample food
Authors applied a small scale experimental analysis to evaluate the capability of the device to detect formalin. We collect some fresh fruits and vegetables from Shwapno Super Shop and measure the concentration of formalin in electric signal output voltage and also in ppm (parts per million). For testing the accuracy of the device sample fruits i.e. carrot placed in 1 liter closed container and added 5 milliliters of formaldehyde with it. Our aim is to get targeted concentration (ppm) of gas greater than natural occurring formalin for carrot (10 mg/m 3 ). System prediction YES is considered as 1, as well as our targeted concentration is 1. The Experiment was conducted at measured temperature (300K). We leave the container for 3 hours to expose with formaldehyde. We take the readings of targeted gas to calculate the accuracy referred as (5.1) in percentage scale [14]. System follows basic K-NN machine learning principle. We repeat the experiment for different fruits and vegetables with 5 ml of formaldehyde and measure the accuracy. liter closed container which is exposed with Formaldehyde and HCHO sensor was placed inside the container. First we monitor the output Voltage ( ) in fresh air. We also measure R0 which is Resistance of the sensor in fresh air using equation (5.2). is Input voltage for the sensor. Then we adjust R1 which is the blue potentiometer attach with HCH0 sensor with a small screwier. This fixed R0 in the number of range 10-100. For our case we fix R1 at 1. Relationship between Vol and R0: To demonstrate the accuracy of the device expected result was to get the target gas. After waiting three hours we again measure the resistibility (Rs) of the sensor. Microcontroller converts the ratio of the resistances (y) to ppm value using equation (  show the observed concentration of formalin in parts per million (ppm).From the result we can see our developed system is able detect formalin. We repeat the experiment with other samples.   Based on the result our system obtains the accuracy of 100% in first iteration. After repeating several times with different samples, the average accuracy of our developed device becomes 99%. Fig 5.7 shows the Natural and artificially added formalin in different food items in voltage response (V). From the experiment we also gain that system could appropriately detect 1-50 ppm of formalin.

Experiment on Raw formalin detection
Our second experiment is to find out the system response for various concentration of raw formalin. At first we measure the temperature and humidity of the environment. We take 14 different concentrations of constant level (1ml) of formalin and measured the response of the device. Three trials were conducted at three measured temperature and humidity for testing the consistencies of the data. The following Fig. 5.8 shows the graph of the experiment's result of the target gas for different concentration.   There are some drawbacks of our developed system. When concentration of formalin is more than 50 ppm system fail to detect the accurate targeted concentration. Better sensor is required for better performance. Detecting fruits by only using resistance give sometimes wrong result and not appropriate for all fruits. Using image processing machine learning approaches this problem can be solved.
Page 37 of 50 Chapter 6

Overall Conclusion
Formaldehyde is one of the commonest molecules in nature. A solution of 35 to 40 percent of water in formaldehyde is called formalin. Some foods and fruits are known to contain naturally occurring formaldehyde in some specific ranges. To keep fruits, some raw foods like fishes and meats for a long time, prevent from decomposing people are using a large amount of formalin which reflects a big impendence of our health issues. But Bangladesh Food Safety Authority claimed that there is no scope to adulterate vegetable and fruits by mixing formalin, a health hazardous chemical which is not fully true.
The rapid development of artificial senses technologies in the present world is increasing day by day. By using the machine learning algorithm is avowedly underpin and also increase the capacity of the system. , which is kind capable of differentiating between natural and artificial formalin at all temperatures in PPM value and all within a portable, lavish, accurate and user-friendly package. Our implemented device can detect the fruit and makes use of Grove VOC HCHO gas sensor which can feasibly detect given sample fruit and concentration of formaldehyde present in comestible products. The human sensing system cannot detect the amount of formaldehyde or even the presence of it in any comestible products. But our implemented device can replicate the human sensing system to detect this harmful element in comestible products. Our ultimate goal is to help the general community regarding health concerns of them. To ensure healthy eating we involve ourselves in this implementation to make our country a better place for living.

Discussion
By naturally fruits and vegetables contain different level of formalin in them. It is necessary to develop a system that behaves in such a way that can detect formalin based on their natural occurring formalin and will not interfere with artificially added formalin. It is therefore obvious to detect fruit or vegetable dynamically by the system. Considering this we develop a system which first detect a fruit or vegetable then compare the measured concentration present in them with their natural occurring formalin. Different machine learning algorithms where applied for detecting food items like fruits and vegetables where K-NN algorithm gives us the best result for the particular dataset. Different Rules were developed and applied on sample food for detection. Our first Experiment shows the accuracy of the device we developed. Targeted amount is measured in ppm value, finally comparing with naturally occurring formalin in food items system classify either artificially formalin is added or not. Based on the classification our system make decision either it is safe or dangerous. Integrated Android application added extra feature with our developed system and make it more interesting. We conduct our second Experiment for analyzing the sensing capacity of the sensor and monitoring its behavior in different concentration of formalin. For low concentration linearity is obtained and for higher concentration nonlinear behavior is found. We fit the curve using Polynomial regression.

Future work
Ours proposes to develop a smartphone-based system that offers a simple & rapid route to detect sample foods and sense harmful element formaldehyde in our daily consumed. The further development of our device will be to ensure the following properties which are to more utility, efficiency, and effectiveness in formaldehyde sensing operations in our daily consumed foods. The foods can be detected by using the application of image processing also. It can explore the possibility of implementing a neural network rather than using the different machine learning algorithms. Also can explore the possibility of commercially developing a photonic or MEMS-based formalin sensor and using it in our designed system [4] [21]. Java and python based program will be developed for further improvements of the Android application which will be able to show all past detection results with the concentration of formalin. It could be possible to Connect to the cloud or server may also be considered where all the previous data will be stored. Design the hardware device outer look can be better which will also easily portable to anywhere.
After connecting all devices with Arduino, we plug the assemble Arduino into our laptop and load up our developed code to Arduino IDE.
Following code need to upload to the board: