FACULTY OF ENGINEERING AND SUSTAINABLE DEVELOPMENT Department of Electronics, Mathematics and Natural Sciences Gas Data Acquisition using Arduino Lander Lejarza Lasuen Gävle, June 2017 Bachelor Thesis in Electronics, 15 ECTS Supervisor: Niklas Rothpfeffer Examiner: José Chilo ii Abstract The aim of this project is to acquire gas data using an Arduino microcontroller. This project is part of a bigger project called The electronic nose where mechanical, thermal, electrical, electronic and software parts work together. It is the continuation of a project handled before where mainly the mechanical, thermal and electrical parts were done. The whole e-Nose project is divided in 4 main subcategories: general mechanical structure, thermal and piston electric circuit, gas sensors and software. My work will be focused in the last two subcategories of the general project. The sample to be measured is placed inside of a moving cylinder, which will lift up the sample reaching near the sensors and warming it using a thermal resistance, to release more odor. That is where the sensors act, synchronized with the piston, will get the data through the Arduino and sends it to the computer to be analysed. The sensors will be activated using an Arduino Mega 2560 and transferred to the computer to be analysed with MatLab. To control the measurement, a push button, a LCD display and a LED will be placed; having like this a full control of the project and an easy interface for the user. Six gas sensors will be used, which will be enough to be able to differentiate between different kind of gases. With such variety it is possible to categorize between combustible gas (methane, propane, LPG etc.), NH , alcohol and more gases. 3 The e-Nose will be able to measure different gases in more than ways depending on the program we choose. For a more accurate response, more sensors would be needed using a sensor fusion method or more accurate sensors. iii Dedication To my family and everyone who helped me in my career. iv Acknowledgements I want to show my gratitude to all the people who helped, collaborated or guided me during the development of this work. I start with my university professors, José Chilo and Niklas Rothpfeffer, who guided me implementing the project and suggested me different paths to find solutions to the problems that appeared during this process. I also want to thank to all my mates who supported me when I asked them for help. This work has been possible thanks to all your collaboration. Table of Contents v CHAPTER 1 ............................................................................................................................ 1 Introduction .......................................................................................................................... 1 1.1 Background ..........................................................................................................................1 1.2 Objective ...............................................................................................................................2 1.3 Outline ...................................................................................................................................3 CHAPTER 2 ............................................................................................................................ 4 Theory ................................................................................................................................... 4 2.1 Electronics basics ...............................................................................................................4 2.1.1 Sensors ........................................................................................................................................ 4 2.1.2 Potentiometer ............................................................................................................................. 4 2.2 Arduino .................................................................................................................................6 2.2.1 Arduino Mega 2560 ..................................................................................................................... 6 2.2.2 Arduino Software ........................................................................................................................ 8 2.3 MatLab Software ..................................................................................................................9 2.4 PyEGG program ................................................................................................................. 10 2.5 Components of the project ............................................................................................... 10 2.5.1 Gas sensor ................................................................................................................................. 10 2.5.2 Shields ....................................................................................................................................... 16 2.5.3 Piston ......................................................................................................................................... 17 2.5.4 LCD............................................................................................................................................. 17 2.5.5 Buzzer ........................................................................................................................................ 18 CHAPTER 3 .......................................................................................................................... 19 Method and Results ............................................................................................................ 19 3.1 Previous Project ................................................................................................................ 20 3.1.1 Piston ......................................................................................................................................... 20 3.1.2 Thermal configuration ............................................................................................................... 21 3.1.3 User system ............................................................................................................................... 22 3.1.4 Software .................................................................................................................................... 24 3.2 Electric circuit .................................................................................................................... 25 3.3 Calibration .......................................................................................................................... 27 3.4 Statistical analysis ............................................................................................................. 29 3.5 Obtaining concentrations ................................................................................................. 36 3.6 Software .............................................................................................................................. 38 3.6.1 Declaration ................................................................................................................................ 38 3.6.2 Calibration ................................................................................................................................. 38 3.6.3 Programs ................................................................................................................................... 39 3.6.4 Functions ................................................................................................................................... 41 3.7 Results ................................................................................................................................ 43 CHAPTER 4 .......................................................................................................................... 46 Conclusions ......................................................................................................................... 46 4.1 Summary ............................................................................................................................. 46 4.2 Problems ............................................................................................................................. 46 4.3 Future work ........................................................................................................................ 4v7i References .......................................................................................................................... 48 Appendix A .......................................................................................................................... 50 Appendix B .......................................................................................................................... 53 Appendix C .......................................................................................................................... 58 vii List of Tables Table 1: Arduino Uno specifications .............................................................................................. 6 Table 2: Arduino Mega 2560 specifications ................................................................................... 7 Table 3: RL for different sensors .................................................................................................. 27 Table 4: Calculating RO ............................................................................................................... 28 Table 5: Features of voltages readings .......................................................................................... 33 Table 6: Empirical data from manufacturers graph ...................................................................... 37 List of Figures viii Figure 1: Schematic of potentiometer ............................................................................................. 5 Figure 2: Arduino Mega 2560......................................................................................................... 8 Figure 3: MQ series internal circuit .............................................................................................. 11 Figure 4: Vout changes in gas presence for MQ-6 ...................................................................... 12 Figure 5: Measurement dependence on humidity and temperature for MQ-2.............................. 13 Figure 6: Voltage divider .............................................................................................................. 13 Figure 7: Vout vs ppm .................................................................................................................. 14 Figure 8: MQ-2 Relation between RS/RO and Gas ppm .............................................................. 15 Figure 9: Fc-22 shield ................................................................................................................... 16 Figure 10: Pistons cables .............................................................................................................. 17 Figure 11: 2x16 LCD display ....................................................................................................... 18 Figure 12: Project Flowchart ........................................................................................................ 20 Figure 13: General structure ......................................................................................................... 21 Figure 14: Thermal Resistance ..................................................................................................... 22 Figure 15: Piston FSM .................................................................................................................. 23 Figure 16: Piston and Thermal General Electrical Circuit............................................................ 24 Figure 17: LCD-Arduino mounting schematic ............................................................................. 25 Figure 18: Electric Circuit ............................................................................................................ 26 Figure 19: %7.2 alcohol beer samples voltage readings ............................................................... 30 Figure 20: %14.5 alcohol wine samples voltage readings ............................................................ 31 Figure 21: %26 alcohol liquor samples voltage readings ............................................................. 31 Figure 22: Features of beer ........................................................................................................... 33 Figure 23: Features of wine .......................................................................................................... 34 Figure 24: Features of liquor......................................................................................................... 34 Figure 25: MQ-6 Alcohol equation............................................................................................... 37 Figure 26: No alcohol ppm measurement ..................................................................................... 43 Figure 27: %5.2 Beer ppm measurement ...................................................................................... 44 Figure 28: %14.5 wine ppm measurement ................................................................................... 44 Figure 29: %26 liquor ppm measurement ..................................................................................... 45 Figure 30: Removing wine ppm measurement ............................................................................. 45 1 CHAPTER 1 Introduction 1.1 Background The Electronic Nose is a project that measures and analyses gas data and concentrations, using for this purpose mechanical, thermal, electrical, electronic and software parts. In the previous project (look Chapter 3), the mechanical and thermal parts were implemented, and all ran with specific software; whereas in this project, the problem of data acquisition and analyses is affronted. The e-Nose is a very practical project, which with some changes for example, can serve as a gas leakage detector. It allows to measure different gases concentration in a certain moment or to see the evolution of a gas concentration in time. In a world where the air pollution is increasing rapidly affecting severely our health [1], to have a full understand of the materials and gases we use is critical, and so on this project concerns also this investigation area. It is not the purpose of this project to use it in gas leakages, but taking this project as a base, e code can be changed to make interesting programs, such as guessing which product was used as a sample in the e-Nose. However, we have to underline that these options are secondary in this project, and the main development is based on the microcontroller and sensors implementation, acquisition and analyses of data. To manage the acquisition and analyses of gas data, specific hardware and software is necessary. The main purpose of the hardware would be to manage the inputs and outputs, and to make possible to interact with the project. For this purpose, a microcontroller is needed. Nowadays, there are several options in the market, such as Microchip or Arduino. In our case the Arduino will be used, the reason is explained in the next subchapter. As far as the software, to control Arduino boards, usually the Arduino software is used. However, it is not the only option available; MatLab software is also perfectly viable for this purpose, and actually, it is also better analysing data. So, in our case MatLab will be used. 2 1.2 Objective As we said before, the main objective is to acquire and analyse gas data. However, this is not enough to make a general understanding of the project. To acquire data, 6 different sensors will be used, each one with his own characteristics. All this data has to be handled by a microcontroller and different actions have to be made: connections between the micro and sensors, program the micro to acquire the data in the correct moment, and save the data. As far as the software, data needs to be more than just collected; has to be analysed. The Arduino language allows having total control on the board without having connected any cables to it, which is a huge advantage. But there are also some problems with it: it is not possible to view data or graphs in the computer, which obviously cuts down a lot of possibilities regarding the analyses. There is another famous possibility very extended in the scientific areas, which is MatLab. It allows having full control of the Arduino and at the same time plot graphs, controlling all the data we collected etc. However, some limitations appear with this decision. First of all, usually the Arduino boards are less powerful than other kind of boards such Microchip ones. It is not a big problem for this project, because the power of the microcontroller is not the most important feature here; but it will definitely delay a little bit the data acquisition process. Moreover, using the MatLab software, one problem appears: computer needs to be connected to the Arduino board to execute the program. In the previous project, the piston and the thermal resistance were controlled using the Arduino software, making it more useful because we do not have to use any external devices. But in this case, data has to be managed and analysed, to plot graphs for example, and for this purpose, the computer is essential. As far as the interface with the user, a LCD display is used to improve the communication. This allows following all the measuring process easily and smoothly. Moreover, a digital fingerprint is realized with a python based program, analysing the data we collected and collecting some useful information. This information characterizes the data, marks its specifications and enables the comparison between different sample readings.
Description: