Introduction: Fartometer - Arduino

About: Brain will control the world!
Fartometer allows you to measure how mighty your farts are.

FartometerProject is an Open Source Project that brings the art of releasing flatulences to another level.
Using a very intuitive Arduino code, it allows you to send and receive data among an Arduino device, a BLE Shield and another device such as a smartphone (FartometerIOSProject) through bluetooth.

More details on and . Both FartometerArduinoProject and FartometerIOSProject are licensed under GNU GPL v. 2 or later.

Step 1: Intro

At first, I thought of the Fartometer project as a mean to get to know the Arduino environment. However, as I have a research background, I can't stop thinking about science even when I'm not thinking about science.

I lost so many sleeping hours in this project just by the fact that I was waking up 2am with random questions like “But methane doesn’t smell, so what kind of chemical element smells like rotten eggs in a fart?”.

The good thing is, not sleeping gave me a lot to share about general knowledge of farts.

Step 2: Research

Before starting this project, I did some research on past projects and turned out that I found on the Internet two very good projects regarding the measurement of flatulences. Arduino Fart-O-Meter and Fart Intensity Detector.

My mistake was that I followed the first one and that project turned out to be a partially wrong solution, but this project should hopefully give you some insight on what to do right, so please bear with me.

So why is the solution for this project partiallywrong?

The reason if because even though a fart may contain 0-10 percent methane in it, not everyone has the bacteria that produces methane in their stomach. In fact, most of adults (2/3) pass farts that contain no methane, vide They have a pretty ugly website, I know, although they have very good sources.

Well, I gotta admit that I had to test my fartometer for real... only for science, ok? I verified that I did have the bacteria and it had approximately 110 milliliters (average quantity in a human fart) of CH4 (Methane) vide and that allowed me to continue to work on this project.

When did I realize that Methane was odorless?

In one of those sleepless nights my brain reminded me that they add odor to the kitchen gas for that same reason; methane does not smell. The gas that smells like rotten eggs is called Hydrogen Sulfide (H2S) and only represents about 1% of the total gas concentration in a fart.

That’s to say, if you want to know how stinky a fart is, you should probably get a Hydrogen Sulfide Sensor, not a methane sensor, be aware of that.

In my project, though, I’m measuring the amount of methane in the air and how loud it is with a sound sensor, which I will include on another future post. It would be also interesting if you added a thermal(temperature) sensor, as it is explained on the Fart Intensity Detector project.

Update: I tried to add the sound sensor at some point, but I believe I never got to implement it and write a post about it.

Step 3: List of Required Materials

  • iPhone 4s or newer with Bluetooth LE (I’m using an iPhone 6 with iOS version 9.0)
  • Arduino Uno Board (I’m using SparkFun Arduino Red Board, which is compatible with Arduino Uno)
  • USB Mini-B Cable
  • 3 Jumper Wires
  • A BLE Shield (A shield that will go on the top of the Arduino and will send messages to your device through Bluetooth, I’m using RedBearLab BLE Shield)
  • And finally… a gas sensor. I’m using MQ-4 (CH4 sensor)! Although, as I said before, it would’ve been better if I had used MQ-136 (H2S sensor). It is way more expensive, though. You can check the list of MQ gas sensors for arduino here.

I ended up buying the full SparkFun Inventor’s Kit, because it is very convenient for future projects. Thus, I only bought the SparkFun Inventor’s Kit, the RedBearLab BLE Shield and the MQ-4 sensor.

Step 4: Communication Between IPhone and BLE Shield

That was my first project using Arduino. And I got very impressed about how flexible it is for using components and making small projects.

The first thing I did was reading a tutorial about how to implement Bluetooth LE with an Arduino and integrating that with an iPhone.

It would have been way easier to have implemented that if had only followed that tutorial; however, I decided to buy the RedBearLab BLE Shield instead of the BLE-Shield v2.0.0 based on Bluegiga’s BLE112 Module, and guess what, I don’t regret at all, RedBearLab has a very good documentation and has also open source projects for iOS and Android.

In order to use the RedBearLab BLE Shield, you will need to install Arduino IDE and then, inside your IDE, you will need to install some libraries and test it.

After installing it, you should test it by selecting the library project “Simple Chat”. You will find that on File > Examples > RBL_nRF8001 > SimpleChat

Click on Verify and then on Upload. If everything goes right, your Arduino is already prepared for communicating with your smarthphone. If not, you should probably take a look at,, BLE Shield LibraryManager.pdf, and Check also if you have installed your Arduino driver and have selected the correct Arduino Port (the one that your arduino is plugged in, duh!).

Ok, now your Arduino is working and only waiting for pairing a device, which is an iPhone in this case.

For testing purposes, RedBearLab has an app on App Store (you can also do it using their Android app). Download it and select “Simple Chat”, make sure that your Bluetooth is on

Pair your smartphone with your Arduino board through the “Scan” button. After that, everything should be working properly and you can send and receive messages through your devices. In your Arduino, remember to set your Serial Monitor baud rate as 57600 baud, which is the default BLE Shield bauld rate value.

Check the cellphone and Serial Monitor images.

See that I’m using in this project messages up to 16 bytes of length. That’s why the message “But you’re a machine, duh” was cut. Beware of that, then.

Lastly, as you already know how the BLE Shield works, you can download my Arduino’s code here on my GitHub.

My Arduino’s code is based on a simple dual state machine, where canReadSensors can be ON or OFF. If the paired device send a message cmd_start, the Arduino reads its sensors and send the sensors’ messages back to the paired device. The format of the message is something like met:200, which represents the value read by the Methane Sensor. It is important to know that the Arduino will be sending those messages until it receives a message cmd_stop from the paired device (your iPhone, for instance). Knowing when to send cmd_start and cmd_stop is crucial, once it can save lots of battery.

Step 5: Attaching MQ-Sensor to the Arduino

From this point, you shoud have this code uploaded in your Arduino.

Your MQ-sensor has 4 pins:

  • AO: Analog Output
  • DO: Digital Output
  • GND: Ground
  • VCC: 5V

Use your wires to make the connection between your breadboard and your BLE Shield. Connect the AO wire to the A0(analog zero) pin in your BLE Shield. After that, connect the GND wire to the BLE Shield’s GND pin. And finally, connect the VCC wire to the BLE Shield’s 5V pin.

You can also check this video for a better comprehension.

Now, if you launch the RedBearLab app for iPhone (HINT: IT ALSO WORK WITH THEIR ANDROID APP!), you will need to send cmd_start to start receiving information from the BLE Shield. Try it (Check the images above).

Step 6: Conclusion

Congratulations!!! Now you have your own fartometer!!! You can customize it the way you want! Don’t forget to calibrate your sensors!

Now that you are receiving the concentration of gas in the air through bluetooth, you can create an app monitor!!!

I made my Fartometer app monitor based on their Simple Chat app, which is open source.
You can download, check and run my iOS app on and the Arduino code on