Shopping Cart

0 item(s) in cart/ total: $0    view cart

No Project too Small

Posted by on 5/16/2013 to Blog
As many of our visitors would have noticed we have a tab called 'Design' on our menu bar. 
What most customers don't realize is that we take on projects large and small. Though we usually focus on large projects (we 'gotta pay the rent) we will often take on small projects to fill the gaps between large projects and of course they can be fun and are usually completed quickly. An example of one of those projects was for a plumber in Philadelphia who wanted to determine if it was safe to work in a basement or other poorly ventilated areas. 
 He came to our web site doing a search for 'methane detectors' and discovered the Methane CNG Gas Sensor - MQ-4 he also saw that we did custom design and prototypes. He approached us and asked if we would build him a methane detector as he had no electronics experience but saw everything he wanted on our site. As we had not worked with the gas detectors before and we were dying to try out one of the Arduino Pro Mini's we gladly took him on as a client. 
Methane gas is colorless and odorless it wont kill you if you breath it but in, but in a high enough concentration it may explode. 

 We started by putting everything together on a small breadboard:
  Methane Sensor 

The circuit was pretty simple - we used a breakout board for the methane detector and connected the output to one of the analog inputs of the Arduino, we also decided to use a pot so that the user could specify a cut-off level where the alarm would not sound. We provided a green LED to show the system was operational and when the gas threshold was exceeded the red LED would light up and the buzzer would sound. The code for this is very simple - read the voltage level on the output pin of the gas sensor, compare that to the voltage level of the pot. If the sensor voltage is higher then sound the alarm. We used a FTDI Breakout to program the Arduino.
void loop() 
{
  unsigned int ADCValue,REFValue;

  ADCValue = analogRead(0);
  REFValue = analogRead(1);
  if(ADCValue>REFValue)
    alarm=1;
  else
    alarm=0;
}
Note: The sensors need to be run (burnt in) for at least 24 hours to ensure that their readings are accurate. 

We have a timer interrupt running on timer 2 - it checks alarm, which is a volatile int, and if it is high the red LED and the buzzed are activated, if low the green LED.
ISR(TIMER2_OVF_vect) 
{
  RESET_TIMER2;
  counter ++;
  if(alarm)
  {
    digitalWrite(buzz, counter & 0x01);
    digitalWrite(RED, counter & 0x01);
    digitalWrite(GREEN, 0);
  }
  else
  {
    digitalWrite(buzz, 0);
    digitalWrite(GREEN, counter & 0x01);
    digitalWrite(RED, 0);
  }
}
As you can see from the above code we are using PWM to turn the LED's on and the buzzer - the buzzer is a piezo element so it needs to be pulsed to make a noise. Unfortunately we cannot just ship the above system to the customer, breadboards don't even travel well from office to lab, so we grabbed on of our breadboard equivalent solder boards and soldered all the components onto it. 
Methane Sensor - Prototype 
Now the customer can play around with the prototype. If the customer decides to add features this can be done very easily as the arduino still has a number of open ports. 


Project Component List 
 1  SEN-09404  Methane CNG Gas Sensor - MQ-4 $ 4.95
 1  BOB-08891  Gas Sensor Breakout Board $ 0.95
 1  DEV-11113  Arduino Pro Mini 328 - 5V/16MHz $ 9.95
 1  PRT-00116  Break Away Headers - Straight $ 1.50
 1  SBB400  400 pts solder-in breadboard (Exact Solderless Match) $ 4.99
 1  PRT-10811  DC Barrel Jack Adapter - Breadboard Compatible $ 0.95
 2  70022911  Resistor  330 Ohm 1/4W 5% $ 0.38
 1  70022898  Resistor 10K Ohm 1/4W 5% $ 0.19
 1  COM-09590  LED - Basic Red 5mm $ 0.35
 1  COM-09592  LED - Basic Green 5mm $ 0.35
 1  COM-07950  Buzzer - PC Mount 12mm 2.048kHz $ 1.95
 1  COM-09806  Trimpot 10K with Knob $ 0.95
 1  PRT-00553  Break Away Male Headers - Right Angle $ 1.95
Total Cost of Components $30.36