Using MQ-7 carbon monoxide sensor module on Raspberry Pi

Source: Internet
Author: User

MQ-7 Carbon Monoxide Sensor Module Introduction

Brief description:

First, size:32mm x22mm x27mm length x width x Height

Second, the main chip:LM393,MQ-7 gas sensor

Three, the operating voltage: DC 5 Volts

Four, Characteristics:

1, with signal output indication.

2. Dual signal output (analog output and TTL level output)

3,theTTL Output valid signal is low level. (When the output low signal light, can be directly connected to single-chip microcomputer)

4, the analog output 0~5v voltage, the higher the concentration voltage higher.

5, the carbon monoxide has a high sensitivity and good selectivity.

6.Long service life and reliable stability

V. Application:

Carbon monoxide detection device for home and environment. Suitable for the detection of carbon monoxide, gas and so on.

Below start the operation under the Raspberry Pi

1. Installing the WIRINGPI,Gpio Programming Library

git:git clone git://

After you download the source code, compile and install it.

2. Connect the MQ-7 VCC interface to the 5v interface GND grounding wire.

Here I use MQ-7 's do interface, will do the excuse to receive GPIO0 above.

Refer to:

Preparatory work:

(1) The sensor is warmed up for about 20 seconds first.
(2) The sensor is placed in a non-measured gas place, clockwise adjustment of the potentiometer, adjust to the indicator light, and then turn counterclockwise half turn, adjust to the light is not lit, and then close to the measured gas, LED light, leaving the measured gas, led off, it proves that the sensor is good!

3. Writing code

#include <wiringPi.h>#include<stdlib.h>#defineGaspin 0//Define the interface number usedintMain () {//level State    intState ; //Initialize WIRINGPIWiringpisetup (); //set interface as input typePinmode (Gaspin, INPUT);  for (;;) {       //gets the level of the interfaceState=Digitalread (Gaspin); //Output Statusprintf"state =%s\n", state==1?" High":" Low"); Delay ( -); }       return 0; }

4. Compile the code.

gcc -wall-o gascheck GAS.C-LWIRINGPI

5. After executing the Gascheck, the status of the GPIO0 interface will be output at the console.

The final explanation is:

When testing the potentiometer can be adjusted to observe the output of the program running, when the rotation to the indicator light, will be output low state.

Vibration Alarm Sensor Module SW-420 use the same:

Module Features:
1, using the company's production of SW-420 normally closed vibration sensor,.
2, comparator output, signal clean, good waveform, strong driving ability, more than 15mA
3. Operating voltage 3.3v-5v
4. Output form: Digital switching output (0 and 1)
5, with fixed bolt hole, easy to install
6, small board PCB size: 3.2cm x 1.4cm
7. Using wide voltage LM393 comparator

8. Do output high active, indicating a vibration

Instructions for using the module:

1, the product does not vibrate, the vibration switch is closed conduction state, output output low level, green indicator light;

2, product vibration, vibration switch instantaneous disconnection, output output high level, green LED does not light;

3, the output can be directly connected with the single-chip microcomputer, through the single-chip microcomputer to detect high and low levels, thus to detect whether the environment has vibration, play an alarm role

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.