Introduction: Gas Cap

Picture of Gas Cap

Since you've gotten into electronics, haven't you wondered if there is a fart sensor out there?  I sure did.  I discovered that if you use a methane sensor, especially the MQ-4, even at very low concentrations, it reads farts.  What if you combined that into a hat with an LED Bar Graph and a XBee?  Exactly.  The Gas Cap was made with that in mind.  For around $100, you can build your own Gas Cap, a human gas-operated LED Bar Graph on a hat.  So, you fart into the methane sensor, wirelessly transmit that data to the hat, and watch the LEDs light up so that your friends can see how horrible it was.

Feel free to leave any questions or comments.

Step 1: Parts

Picture of Parts

You will need to purchase the following from Sparkfun:

Relevant Parts:

Methane CNG Sensor  $5
330 Ohm Resistor  $0.25 (2)
XBee Series 2 - Wire Antenna  $26 (2)
Lilypad Arduino 328 Main Board  $22
Lilypad XBee  $15
Lilypad LED PCB Set  $5
Lilypad Simple Power  $5
FTDI Basic  3.3V (for programming the Lilypad) $15
110mAh LiPo  $7
850mAh LiPo  $9
XBee Explorer  $25
XBee Breakout Board  $3
XBee Headers for Breakout Board  $1 (2)
JST 2-pin Through-Hole Connector  $1
SPDT Mini Power Switch  $1.50

Other:

Red LED (10)
Green LED
LiPo Charger Basic  $10
Mini-B USB Cable
A Black Soft Cotton Hat
Altoids Smalls mint tin
PC
Soldering Iron
Dremel
Needle
Conductive Thread  $3
Long Wooden Stick or Umbrella
Hot Glue Gun
Chalk

Step 2: Terminal Configuration

Picture of Terminal Configuration
Now it's time to setup our XBees.  We'll first load a new firmware on with X-CTU, and then set the parameters with your favorite terminal application.  We need one XBee configured as a Router AT and another for a Coordinator API.  This is because we are sending data from the router, but the only way to receive it is to set it in API mode.  

Plug your XBee Explorer into your computer with one of the XBees on it already.  Once in X-CTU, select the correct COM port (usually known as "USB Serial Port") and check the "Enable API" box.  Go into the Modem Configuration tab.  Click the leftmost drop down menu and select XB24-ZB.  Click on the drop down menu to the right of it and select ZigBee Coordinator API.  Click the Always Update Firmware box and then press write.  After about a minute, it should be done uploading the firmware.  Now, take out this XBee and put a "C" on it so that we remember it's the coordinator.  Put the other XBee in and on the right hand drop down box, select ZigBee Router AT this time.  Go back to the PC Settings tab, and then uncheck the "Enable API" box.  Go back to the Modem Configuration tab, and then press the write button.  After about a minute, it should be done uploading the firmware.  Make sure to mark this one with an "R" so that we remember it's the router.

Wait!  Stay in X-CTU!  We need to program our coordinator in X-CTU because it is API mode.  Every time you have an XBee in API mode, you have to configure it in X-CTU.  Insert the XBee with a "C" on it.  Check the enable API box in PC settings.  Go back to the terminal and type in "+++" .  Type in "ATRE" to restore the factory defaults.  Type in "ATDH0013A200" to set the high part of the routers serial address.  Type in "ATDL the low part of your router's serial address" to set the low part of your router's serial address.  Type in "ATID 0" to set the PAN ID to 0. Type in "ATWR" to write your changes.  

Go into your favorite serial terminal application and plug in your XBee Explorer with the XBee labeled with an "R", or your router.  Type in the following commands after you type in "+++"!
  1. ATDH 0013A200
  2. ATDL the low part of your coordinator's serial address goes here
  3. ATID 0
  4. ATJN 1
  5. ATD02
  6. ATIR 64
  7. ATWR

Step 3: Programming the Lilypad

Picture of Programming the Lilypad

You can download the Arduino code below.  Put your FTDI Basic 3.3V on the Lilypad and plug into the computer.  Select Lilypad Arduino w/ ATmega328 from the Arduino boards menu.  Upload the code to the Lilypad.  Charge your LiPo's now so that they will be fully charged for step 6.

Step 4: Assembling the Hat

Picture of Assembling the Hat

Now, take your cap and make sure there are no metallic parts in it.  Use a soft cloth hat (not a hard polyester one with cardboard inside like I used which was very difficult to stitch).  Decide where you want your 10 LEDs, and also where the Lilypad and Lilypad Xbee, and Lilypad Simple Power are going to be located.  Using regular thread (not conductive), sew these in place with a few stitches each just to stabilize them a bit.  It is a lot easier than using pins, and then you won’t poke yourself. 

Take a piece of chalk, and map out all your connections, just to make sure.  The chalk will brush off later.

Using the conductive thread, sew all your connections as planned.  Make sure that the power source is as close to the Lilypad main board as possible.  Remember to make good knots at the end of the stitch and then cut closely so as not to overlap the threads and short circuit.  I also put hot glue at most of the knots to make sure they didn’t unravel.  You will need to use a small insulation tube where the + to + overlaps another row of stitches.  Put at least 3-4 passes through each of the Lilypad holes to ensure good conduction.

Step 5: Assembling the 2nd Part of the Gas Cap

Picture of Assembling the 2nd Part of the Gas Cap

Use the Fritzing example to understand the connections.

Wire up the methane sensor like so, but use your 330 ohm resistor instead of the 10K that they show in the example.  The reason for this is that the XBee's voltage reference is 1.2V, so we need a really low value, and replacing the voltage divider resistor it the exact thing to do.

Solder the XBee headers to the breakout board (not the actual XBee!) and attach one of the XBees to the new breakout board.  Looking at the Altoids tin, flip it over so that the clamshell end is at the bottom.  Open the top up and of the left, rotate the XBee breakout board so that the top of the breakout board is facing left.  Place the methane sensor in the right of the bottom of the tin.  Dremel the Altoids tin on the bottom so that it makes a small hole for the XBee's antenna.  Dremel a bigger hole for the methane sensor to the right of that. Make sure it fits, and then take out the sensor and the breakout board.  Take the XBee out of the breakout board.  Put electrical tape on all sides of the tin so that no metal is showing because we don't want it to get shorted out!

Now it's time for soldering!  Connect the analog input pin on the methane sensor to pin 20 of the XBee breakout Board (the top right pin).  Connect +5V of the methane sensor and connect it to VCC on the breakout board.  Connect GND's together on the sensor and then connect to GND on the breakout board.  Connect VREF on the breakout board to VCC on the breakout board.  Attach an LED and resistor between ON on the breakout board and GND.  Wire up a switch to the LiPo jack in-between VCC and GND.  Check the polarity of the LiPo jack by inserting the LiPo the correct way and soldering.  Cut the methane sensor's leads so that they do not touch the Altoids tin.

With the Altoids tin open, rotate it 180 degrees so that "smalls" label on the tin is facing you.  Put your XBee in the socket that we attached to the methane sensor, the switch, and the power LED.  Put the whole jumble of wires including the XBee socket, methane sensor, the switch, and the power LED into the altoids tin facing down so that the Xbee antenna and methane sensor go out of the holes that you Dremeled.  Put the 110mAh LiPo on top of the whole mess and connect it to the LiPo jack connected to the XBee socket.  Close the Altoids tin and flip over.

Step 6: Stay Away!

Picture of Stay Away!

Now, we don't want someone to fart on your hand!  Hot glue the top side of the tin (the side that does not have the methane sensor and the rocker switch) to a long wooden stick or the end of a torn down umbrella.  If you don't have a long wooden stick of some sort, go buy an umbrella for $3 at Walmart.  That's what I did.  There are some pictures up above of the meltdown of the umbrella.  

Step 7: Farting Finale!

Picture of Farting Finale!

Now plug in the 850mAh LiPo into the Lilypad Power Supply in the hat.  Flip on both of the switches and start farting!  It's hilarious!  Thank you for looking at my instructable.  If you like this, please subscribe. 

Comments

huck alexander (author)2012-06-12

Totally cool idea. My wife just didn't understand... I want to make one of these. It would be the perfect for someone I know. Though I am concerned with reduced lifespan of the sensor under whole milk circumstances (one does have to test it right)?

I find it so intriguing that at your age, you have been able to conceptualize so many of your ideas. Good for you, man.

I do have two questions for you. What inspired you to get into electronics and microcontrollers at your age? Second, I have a younger sister who I am trying to teach electronics fundamentals to. What has helped you learn? What methods were most effective for you?

Again, great job.
*following*

Qtechknow (author)huck alexander2012-06-14

Awesome! Thanks for the comment!

I wanted to get into electronics because I was bored with video games and TV. One day, my dad had found MAKE magazine, we bought a soldering kit, and I made more and more electronics from then on. The way I learned is I got: MAKE magazine, a small soldering kit, a soldering iron, Getting Started with Arduino (book), an Arduino, plus many other components. I made the ArduSensor Fun Pack (also one of my Instructables, for sale at my website, www.qtechknow.com) for beginners to start electronics! They are plug-in-play sensors for Arduino. I recommend that you get an ArduSensor Fun Pack for your sister to get started with electronics, plus all of the stuff mentioned above (if you don't already have it!).

zomfibame (author)2012-06-08

Mighty, mighty, mighty COOL. too funny!

ka1axy (author)2012-05-04

Not to detract from the sheer awesomeness of this design, but it did cause me to think that perhaps this reminder is overdue:

Just because it *can* be built, doesn't mean it *should* be built.

//thank you for your attention

Zombie_BBQ (author)ka1axy2012-06-06

You are just jealous of this young man's epic awesomeness. so go troll yahoo ...

ka1axy (author)Zombie_BBQ2012-06-06

I am jealous.

Also glad I don't work in a closed space with him.

:-)

Qtechknow (author)ka1axy2012-06-07

Yay! Thanks!

razamatraz (author)2012-05-02

Top notch work good sir.

A bit expensive but I imagine a wired version would be half as much (or less).

I used to work in a gas plant and the H2S detectors also work and level is more proportional to the stink since it is not the methane component that actually smells bad. It was kind of funny when someone wearing a personal H2S monitor would set it off in the lunch room.

Qtechknow (author)razamatraz2012-05-17

Thanks for the comment! Since you mentioned H2S, I think I might make an ultimate fart evaluation kit that evaluates an H2S sensor, a methane sensor, and a microphone to detect the REAL value!

razamatraz (author)Qtechknow2012-05-18

Sounds like a cool idea. Combine all aspects of fart nastiness.

yoyology (author)2012-05-02

This is a device of epic awesomeness. I applaud you, sir!

Qtechknow (author)yoyology2012-05-16

Thanks for the comment! If you are going to Maker Faire this weekend, try and find the kid with the farting hat!!!

yoyology (author)Qtechknow2012-05-16

Man. I wish. It's a long way from Tulsa to SF. :-(

TheBroSquad (author)2016-06-02

I love seeing other non-adults on instructables! Especially ones that come up with high quality, well explained ideas. In this day-in-age, it's very difficult to be underage, yet still respected for your achievements. I applaud you and any other kids that are not afraid to use their brains to go somewhere in life. (I like some adults too, FYI)

Stavros! (author)2015-08-09

You know, something like this to hang in the bathroom at work, or on the door to give fair warning to other people would be an interesting idea....

banker (author)2015-06-14

Hey, Everybody! Fart in my face so I can measure your fart. It's for my research.

krazytechboy (author)banker2015-06-17

That's just weird.

tp.pa.12 (author)2015-06-14

Neat idea, but I know the level of my fart by how loud my wife screams "Man That Smells" & if there is " I think I'm going to puke" well, what more is needed to be said.

Tp

jooly4 (author)2015-06-14

Oh my goodness! What fun for the guys in my family. I live with five of them and the other would love this. Guys really are so different than the females of the species. I had so much fun with my nutty sons, their friends, and my grandsons. Keep on being a nut young one.

MarkFisk (author)2015-06-14

Very nice. Now if you could harness the energy and save the world with a truley renewable enegry source!

cart562 (author)2015-05-26

I don't need this for my friends to know how horrible my farts are....

gpay10 (author)2013-11-23

This idea would be great if it could sense carbon monoxide! I would buy one for my grandkids to wear to school (our schools have a lot of incidents of faulty heaters and carbon monoxide poisonings)

diy_bloke (author)gpay102015-04-23

use the MQ7 or MQ9 sensor: http://playground.arduino.cc/Main/MQGasSensors

brandonkim5211 (author)2014-04-25

Hey, what's up Q(uinn). :D ITS MEEEEEE! Guess.

supermitch (author)2014-02-19

Oh my God i am sooooooooo stupid! I just realized that I put the Xbee module backwards on the Xbee Explorer! Yay!

supermitch (author)2014-02-09

Hi Qtechknow! I read about you in Popular Science and I thought "I know that kid! He's the one who made the number-one prize winner for Instructables I've wanted to make." I had looked at this project months earlier, and thought it was really cool. Finally, when we picked our annual MAP goal for school (just something you want to improve on), I picked technology. I decided I would build the Gas Cap. I just recently received most of the parts via UPS. I've been trying to get my XBee to register to the X-CTU I just downloaded, and it wouldn't find the serial USB port. I quickly learned that it was because I didn't install the FTDI drivers, so I plugged in my FTDI Basic and downloaded them from ftdichip.com. Now the USB serial port is registering, but my XBee still won't connect. Its power light is on, and I am using a Mac, so I sort of have to interpret what the Windows X-CTU tutorials mean. If you could write a few comments to help me or write a follow-up Instructable about X-CTU, that would be great!

Qtechknow (author)supermitch2014-02-09

I'm not exactly sure what is happening. Since Digi released this recently, I'd recommend using the more reliable Windows version, just to be safe. At the moment, I'm downloading the X-CTU for Mac to see what is happening. Thanks!

SGT. Desert (author)2012-08-11

you are super smart

Qtechknow (author)SGT. Desert2013-10-30

Thanks!

whittler123 (author)2013-09-14

Hey Qtechknow,
I read about you in a popular science magazine. You're amazingly smart!!!!!!!!!!!!!!!!

Qtechknow (author)whittler1232013-10-30

Thanks!

Adambowker98 (author)2012-07-04

So does the methane sensor act like a switch? It senses gas and completes the circuit?

Qtechknow (author)Adambowker982012-07-05

Not entirely; the gas sensor changes resistance instead of acting like a switch. In my code, I change the bar graph according to the resistance of the gas sensor.

Adambowker98 (author)Qtechknow2012-07-05

So if I used a cluster of LEDs rather than a bar graph, would the LEDs get brighter as the fart got worse? And the LEDs not shine so brightly because of added resistance whenever the fart is kinda small?

Qtechknow (author)Adambowker982012-07-06

You should also try that; I don't usually do electronics without programming!

Adambowker98 (author)2012-07-04

Could you make this as a pocket fart detector with just a few LEDs and no bar graph?

Qtechknow (author)Adambowker982012-07-05

You could, but that would need an entirely different format and different instructable. You could always try!

Adambowker98 (author)Qtechknow2012-07-05

Could I wire some LEDs to a switch and then a methane sensor and then to a battery? You turn it on and the brightness of the LEDs determines the level of the fart?

Qtechknow (author)Adambowker982012-07-06

Try it!

randsroark (author)2012-06-20

Nice job!

Can you explain the AT commands for the XBee? Like, what does the ATJN 1 command do? Better yet, where do you find Digi's AT command list?

thealeks (author)2012-05-09

now i would use this to detect other peoples farts(and emit a beep or have the leds where i can see them) before my nose does, so i dont have to smell them. how many times have we been on elevators and a methane sensor at waist level could detect the fart before it reaches our nose, allowing you possibly enough time to get off at the next floor, saving you from the stench.

this instructable is brilliant!

ka1axy (author)thealeks2012-06-06

Bonus points for, well, a pointer!

...so you can indicate "who dealt it".

Qtechknow (author)ka1axy2012-06-07

Thanks!

FrenchFrog (author)2012-05-07

Very creative and definitely a winner! I would be surprised if it isn't chosen. :-o
:-)

Qtechknow (author)FrenchFrog2012-06-07

Thanks, FrenchFrog!

Qtechknow (author)2012-06-07

Thanks, xsohailx!

litliao (author)2012-05-06

$100! could be a little costly. LED bar graph + methane detection + wireless communication can be achieved in a more convenient and even plug-and-play way. well, don't need as much as $100 of course.

About This Instructable

31,168views

81favorites

License:

Bio: White House Maker Faire // 16 years old // CEO of Qtechknow, maker and electronics enthusiast, I teach Arduino classes, and put making into schools! My successful ... More »
Add instructable to: