Electronic Nose - eNose

In the previous article I provided details on VeeFarm which was one of the best projects we saw in ANZ Pied Piper 2019 edition and one of the best projects in the history of the program. The program inspired me and others to work together to showcase a great idea and the Pied Piper program itself during our presales conference.

An idea I suggested to enhance VeeFarm was an electronic nose that could be used to detect the optimal ripening of the produce to advise the owner that it is the right time to pick it up the produce. This is an idea I had in the backburner for a while but never found the time to work on. Vee gave me the perfect excuse.

The electronic nose, or eNose for short, is a custom PCB that hosts a range of gas sensors. For the proof of concept, I used the cheap MQ sensors. These are designed mostly for hobbyists and makers and they barely cost $1 per sensor. As one could expect, tweaking and calibrating these sensors it is even harder than the most expensive counterparts

Another problem is that they react to multiple gases each, not just one. So rather than using them to measure exact concentration is particles in the air, the idea would be to establish a signature for a well-known smell and compare current readings against those signatures

Here you can see a photo of the device with 4 gas sensors attached to a custom PCB


The key component in the device is a Wemos D1 mini microcontroller. I selected it because of its WiFi capabilities as well as its size. As you can see in the photo above, I broke out the serial port (TX/RX) just in case WiFi was a problem at the conference site. This would have allowed for transferring the readings to Veronique’s Raspberry PI via the serial port.

I had never worked with this MCU and I was pleasantly surprised. After some preliminary tasks I was able to leverage the Arduino IDE I am familiar with.

One constraint I had to work around was that while the gas sensors provide an analog signal, the microcontroller provides a single analog pin. You can see it in the photo of the Wemos above as “A0”. Now you can understand what the 4051’s goal is. This DIP is essentially an analog multiplexer with 8 input lines and 1 analog output. You select what sensor you want to read by acting on 3 control lines. You can see in the code excerpt above that the input selection is implemented via a function called “changeMux()”



The rest of my code is published in this GitHub repo. It contains both DHCP and Static IP versions of the solution


The gas sensors work at 5V which can be a problem for the Wemos as it works at 3.3V. The sensors provide a digital output that signals whether a given threshold (ie a certain gas concentration) is reached. The threshold is set by manipulating the pot on the back of the sensor. You can see it in blue in the photo below.


I wanted to use the analog output. After some testing with an Arduino Nano I realized that the readings when used in analog mode are well within the acceptable limits of the Wemos so I didn’t bother shifting those signals.

The readings were sent to an InfluxDB database. This is a very popular choice when it comes to time-series databases. The data was graphed with Grafana which has a great integration with InfluxDB. This screenshot from Grafana shows how the readings reacted when I exposed the eNose to a cloth with whiteboard cleaning spray. Some sensors got stimulated and others didn’t as they sense for different gases



I designed the PCB with EasyEDA and ordered through JLCPCB. It was $2 for 5 boards … little price to pay for a great learning experience.

Comments

Popular posts from this blog

Sending PowerStore alerts via SNMP

Use Vagrant to deploy to AWS