Hazardous Gas Monitor

Contributors: jenfoxbot
Favorited Favorite 17


Phant is No Longer in Operation

Unfortunately Phant, our data-streaming service, is no longer in service. The system has reached capacity and, like a less-adventurous Cassini, has plunged conclusively into a fiery and permanent retirement. There are several other maker-friendly, data-streaming services and/or IoT platforms available as alternatives. The three we recommend are Blynk, ThingSpeak, and Cayenne. You can read our blog post on the topic for an overview and helpful links for each platform. The code in this tutorial will need to be adjusted to work with the other data streams.

As an example, try looking at the Photon Remote Water Level Sensor Tutorial which uses ThingSpeak.

Build a portable gas monitor to check for dangerous levels of hazardous gases in your home, community, or on the go and prevent your friends from lighting a cigarette during a gasoline fight.*

**Please note that this is solely a movie reference -- gasoline fights should probably be avoided in real life.*

Hazardous Gas Monitor

This tutorial shows you how to build a web-connected "canary" monitor for three hazardous gases: Liquid Propane Gas ("LPG"), Methane (aka natural gas), and Carbon Monoxide ("CO"). Using the Particle Photon microcontroller, the sensor readings are converted into parts-per-million ("PPM") and uploaded to the data.sparkfun.com web service.

Check out the video below to see the Hazardous Gas Monitor in action:

Helpful Background Info

  1. How to set up the Particle Photon.
  2. Pushing data to the data.sparkfun.com web server.
  3. New to relays? Check out this a handy reference.
  4. Here's a helpful overview on the N-Channel MOSFET.
  5. For powering the Photon, here's a thorough guide on the Photon Battery Shield.
  6. Highly recommended to peruse the datasheets for the three gas sensors.
    1. LPG sensor datasheet
    2. Methane sensor datasheet
    3. CO sensor datasheet

Choosing a Battery

The gas sensors used in this project require a fair amount of current, about 0.17 mA each at 5V. To make the system portable, we'll need a high capacity battery. One easy, and affordable, option is to use four (rechargeable) AA batteries in series. These batteries will last about 4 hours.

Another option is to use a lithium ion battery ("LIB"). LIBs have a higher capacity than AAs, but typically run at a lower voltage. If you go with this option, you may need to include a correction factor when you calculate the sensor value or boost the battery voltage with a transistor or other component.

Here's a table that shows the approximate lifetime of a few different battery options.


If all of this sounds confusing, here's a more thorough tutorial.


To follow along with this tutorial, you'll need the following:


Microcontroller and Accessory Components

Gas Sensor Circuit

LPG (MQ6) Gas Sensor
Methane (MQ4) Gas Sensor
Carbon Monoxide (MQ7) Gas Sensor


  • Soldering Iron
  • Wire cutters/strippers
  • Drill
  • Screwdriver
  • Epoxy (or hot glue)