I was considering the following as a first project and wanted to get some advice if it's worthwhile.


I'm always paranoid that I left the stove on when I leave the house. I want to use a Raspberry Pi as a sensor to detect if:

  1. There is a flame left on
  2. The flame went out and gas is leaking


I think I would need:

  1. Gas detection connector
  2. Heat detection connector
  3. Motion detector/camera (if someone's present I don't want anything triggered)

This tutorial mentions the MQ-2 sensor that seems good enough for gas detection. I haven't looked much into the heat aspect yet.


  1. Is this too much for a first project? I'm good with Python and Unix scripting but I haven't actually put together anything requiring a breadboard before. (I've built computers in the past.)
  2. Most of these sensors are focused toward Arduinos. Would this be a better project for an Arduino? I want to get experience with a Raspberry Pi, but maybe I shouldn't be too stuck on a certain architecture?

(1) The first tricky part will probably be debugging the I2C connection on the gas sensor you mentioned. If you have access to an oscilloscope, this will most likely be much less difficult. Motion detection can be simple or extremely difficult. If you opt for simple, you'll likely end up using something like this where it outputs a simple logic level to indicate the presence of motion. If you go with a camera, OpenCV is a pretty good free library, but you could spend a lot of time getting it to do what you want.

For measuring temperature, you might consider using something like an IR sensor (for example) so you can avoid putting your electronics close to an open flame.

(2) I would imagine the reason similar projects use arduino is because unless you're using a webcam, the Pi is probably overkill. Apart from that, the Pi might be desireable for you if you would like to write your program in Python.

  • 1
    Gas sensors aren't usually I2C based. They are fundamentally simple analog (one output, no timing) devices, and most commonly come on a breakout with an additional digital out (again, no timing involved) which will read high when the sensor goes over a threshold and low otherwise. This can be connected to a GPIO on the pi as long as you power the sensor with 3.3V (or else use an appropriate divider on the output). A commonplace butane lighter is useful for experimentation ;)
    – goldilocks
    Apr 28 '17 at 14:44
  • Right, the article describes using an external I2C ADC to read the gas sensor output. This is actually a benifit of using the arduino instead which I hadn't considered. With an arduino you could connect the gas sensor to an internal ADC to read more than just a logic level from the gas sensor without the cost of an external ADC. Apr 28 '17 at 14:53
  • Using an ADC is nicer because then you can get an actual reading, as opposed to just a threshold digital trigger. If you get one with a little screw potentiometer to set the sensitivity, you can then fine tune that and use the ADC for something else once it is worked out.
    – goldilocks
    Apr 28 '17 at 14:57

As the tutorial tells, you need a ADC to do the measurements, but if you do have the skill in python / bash, I would not see a problem with you doing this. Breadboard connections are given, so you should be able to do this.

Not the answer you're looking for? Browse other questions tagged or ask your own question.