We select and review products independently. When you purchase through our links we may earn a commission. Learn more.

This Clever Person Used a Raspberry Pi to Make an Electronic Nose

Mendoza's smelling gas sensor, made with a Raspberry Pi 3
Luis Rodriguez Mendoza

People use Raspberry Pis to make a ton of creative and unique gadgets, but this one might take the cake. Or rather, smell it. Creator Luis Rodriguez Mendoza was inspired by trained sniffing dogs at the airport then wondered whether low-cost gas sensors could do the same thing.

We see a huge variety of sensors—like those that can sense noise, temperature, humidity, or light—used every day for a variety of tasks, but gas sensors are far less common. Using the sensors to actively “smell” the scents in the nearby environment, rather than to just detect a scent passively, is even less common.

Mendoza said that “The purpose of the project is to show that low-cost sensors can be reliable in detecting odours and that they can possibly be used in clinical settings.” He used just four types of gas sensors to carry out extensive tests and model training.

“Testing was done using samples of beer and brewed coffee,” he stated when asked about his testing process. “A K-Nearest Neighbours (KNN) algorithm was used in MATLAB to create a classification model that was used to predict the aromas of beer and coffee, and was validated using a 10-fold cross validation (k-fold) … a 98 percent classification accuracy was achieved in the testing process.

“Each sample was taken, on average, for 15 minutes at one second intervals, producing over 900 sample readings per test and the data was exported into CSV files. For classification purposes, an additional column was manually added to label the sample (i.e., coffee, beer, air). The three datasets were imported and combined in MATLAB. This data was used to create a k-nearest neighbour model, k was selected to be 5, this was determined by trial and error. A 10-fold cross-validation was used to validate the model, and a Principal Component Analysis (PCA) was used as an exploratory technique to verify the model and the results, similar to the work shown in past research.

Principal component analysis chart from Mendoza's test data
Luis Rodriguez Mendoza

“A test dataset was gathered by taking 17 new samples of two-minute readings at one second intervals to assess the classification model. Each sample was independent of each other (only air, beer, or coffee was measured at a time), and they were manually labelled accordingly, resulting in over 2500 measurements. This data was imported, combined, and randomly rearranged in MATLAB. Using the classification model created from the training dataset, the testing data was classified and the results from the classification model represent 97.7% accuracy.”

The overall high accuracy rates produced by the individual test subjects is truly impressive. Mendoza used a Raspberry Pi 3 for the tests and mentioned that he first learned about the device in late 2020 in one of his university courses. “I quickly realized how easy, efficient, and capable Raspberry Pi boards are,” he said.

via The MagPi

Suzanne Humphries Suzanne Humphries
Suzanne Humphries was a Commerce Editor for Review Geek. She has over seven years of experience across multiple publications researching and testing products, as well as writing and editing news, reviews, and how-to articles covering software, hardware, entertainment, networking, electronics, gaming, apps, security, finance, and small business. Read Full Bio »