This blog page is all about the project development of a chemical device that my group has selected.
Project Development Entry
1.
Our team Chemical
Device
Our chemical device is a Carbon Monoxide(CO) gas sensor that trips a sound alarm whenever that CO level in the room, specifically a kitchen, is too high.
The chemical device is meant to alert people in the room that the CO concentration in the room is too high and that they have to do something about it. This is important because breathing in too much CO is detrimental to one's health, possibly leading to death. Thus, this chemical device can warn and prompt the people in the room to take action by switching on a ventilation fan to remove CO from the room.
2.
Team Planning, allocation,
and execution
Team members: Haziq(Hawkeye), Dorson(Iron Man), and Derrick (Me, Spiderman)
Finalised Bill of Materials(BOM)
The finalised Gantt Chart shows 2 bars for each activity, one being for the planned time of execution and the actual time for execution.
3. Design and Build Process
Part 1.
Design and Build of Casing and Lid (done by Hawkeye).
Blog Link: https://cp5070-2021-2b03-group1-haziq.blogspot.com/p/project-development.html
Part 2. Programming of CO Gas Sensor and LCD (done by ME, Spiderman).
At first, I was not sure how I was going to create a program that can integrate both the CO Gas Sensor and the LCD. So, I searched around the internet for "inspiration". And so, I followed the instructions given by the video. The video demonstrates how to calibrate an MQ2 gas sensor using Arduino. It also shared a webpage where I can find the code used for the calibration which can be found here. I then copied this code onto the Adruino IDE to make a few changes. I also noticed that this code, unlike many others for an MQ2 gas sensor, did not include a MQ2 library because the whole program consisted of the codes one would find in the MQ2.h and MQ2.cpp libraries.
Firstly, since we are using an LCD, the LCD library has to be included. So after searching on the internet, I found a .zip file of the LCD library here and added it onto the IDE.
1. On the Arduino IDE application, click "Sketch", then click "Add file..."
2. A new window pops up, prompting to search for the .zip file to extract. I clicked on "This PC"
3. I double-clicked on "Downloads".
4. I then double-clicked on "Arduino-LiquidCrystal-I2C-library-master" and clicked "Open"
5. I then included the library by typing out this code:
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
Now the library is included.
6. Since our chemical device is meant to make an sound alarm, we borrowed some code from the Melody library from our Pegacorn project last semester:
#define N_A7 3520
int const TEMPO = 1200;
int melody[] = {
N_A7, N_A7, N_A7, N_A7, N_A7, N_A7, N_A7, N_A7
};
int noteDurations[] = {
8, 8, 8, 8, 8, 8, 8, 8
};
I used the note A7 because it has a high pitch that sounds very annoying, which can be effective as an alarm.
7. Onto the main code:
void setup() {
lcd.begin();
lcd.setCursor(0, 0);
lcd.print("Calibrating...");
Ro = MQCalibration(MQ_PIN);
lcd.print("Calibration is done!");
lcd.clear();
}
void loop(){
int co = MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_CO);
lcd.setCursor(0, 0);
lcd.print("CO:");
lcd.print(co);
lcd.print( "PPM" );
if(co >= 9){
lcd.setCursor(0,1);
lcd.print("CO LEVEL HIGH"); // Print a message to the LCD.
int melody_len = sizeof(melody)/sizeof(melody[0]);
for (int thisNote = 0; thisNote < melody_len; thisNote++) {
int noteDuration = TEMPO / noteDurations[thisNote];
tone(8, melody[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.45;
delay(pauseBetweenNotes);
noTone(8);
}
lcd.clear();
}
else {
lcd.setCursor(0,1);
lcd.print("Normal Level");
}
}
As seen under "void setup()", the codes are all related to the LCD. This is where the LCD is setup. When switched on, the LCD reads "Calibrating...", and when it's done calibrating, reads "Calibration is done!" and clears the LCD to display a different set of text under "void loop()".
Under the "void loop()", the first five lines of code tells the LCD to display the concentration of CO gas in terms of ppm, at the point (0,0) which refers to the location of the cursor on the LCD which is a 16 x 2 display.
Below the five lines mentioned are the if/else statements, which dictate what the LCD displays and what the on-board buzzer of the Arduino UNO does IF the concentration of CO is greater than 9 ppm.
So the IF statements tells the LCD to print a message reading "CO LEVEL HIGH" at (0,1) and tells the on-board buzzer to play the melody found in step 6, then the LCD display is cleared to repeat the first five lines under "void loop()".
The ELSE statement tells the LCD to print the text "Normal Level" at (0,1) of the LCD for everytime the concentration of CO is not greater than 9 ppm.
That's it for the programming.
Part 3. Integration of all parts and electronics (done by Iron Man)
Blog Link: https://cp5070-2021-2b03-group1-dorson.blogspot.com/p/project-development.html
4.
Problems and
solutions
There were two aspects in which we encountered problems:
1. The Parts
2. The Program
The Parts
- We originally thought that the dc motor for the fan required for us to use a motor driver such as the L298N. Since we did not have this component, we thought that the idea of implementing a ventilation fan has been ruled out.
Solution: We improvised by using one of our other ideas to replace having to use the fan which was to implement an alarm system. This way, even though the chemical device does not directly address the issue of high CO levels in a kitchen, the alarm system can alert people in the kitchen of the high CO levels and prompt them to do some corrective actions.
- The MQ2 gas sensor and the LCD screen did not fit into the slots on the 3D print allocated for the respective components
Solution: We basically just printed another casing that has bigger slots to fit the components nicely.
The Program
- The concentration of CO displayed on the LCD screen is fluctuating and sometimes displays negative values or values that are unreasonably high for an air-conditioned environment
Solution: Troubleshooting all throughout the program led us to believe that the issue was found in the downloaded zip files for the MQ2 gas sensor library. Thus, we started a completely new program that already has a slightly different library typed within the program and borrowed some of the codes from the first iteration of the program.
5.
Project Design Files
as downloadable files
If you just want the whole folder, here it is:
Here is how our chemical device(without components) looks:
Comments
Post a Comment