GithubHelp home page GithubHelp logo

fjebaker / mq7 Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 6.0 33 KB

Arduino / AVR library for MQ7 carbon monoxide detector.

License: GNU General Public License v3.0

C++ 100.00%
arduino mq7 carbon-monoxide carbon-monoxide-sensor co-sensor gas-sensor mcu microcontroller arduino-library

mq7's Introduction

MQ7 carbon monoxide detector library for Arduino

Features

This library implements an MQ7 class with the following features:

  • device calibration
  • read carbon monoxide parts per million (ppm)

Quick-start guide

After downloading the library, load the MQ7_Example.ino example sketch onto your device, with

  • analog out connected to A2
  • GND connected to GND
  • Vin connected to 5V

Upload the sketch, and then monitor serial. The example sketch will calibrate the device over 15 seconds, and then print the carbon monoxide ppm once every second to the serial console.

Detailed guide

In the MQ7 Data sheet is provided the typical behaviour of the device. The carbon monoxide ppm is a function of the surface resistance divided by a reference resistance, following the general exponential equation

NB: the plot in the data sheet has reversed axes.

The reference resistance is defined by the constraint

Using this point, and PPM(0.4) ~ย 400, one can calculate the coefficients of fit with

or

which are defined in MQ7.h. The library then calibrates R0 by continuously recalculating the value every second for CALIBRATION_SECONDS (TODO: until delta based condition met). As such, this calibration function must be called in setup() to avoid faulty data.

The R0 is calculated by assuming clean air (approx 10 ppm of carbon monoxide) -- it is therefore best to perform this calibration outside. You can read in the value calculated for R0 using the getR0 function.

Alternatively, as the data sheet recommends, the device should be calibrated after ambient on-time of 48 hours -- thus, it would be recommended for accurate use, to leave the device on for some hours in clean air, and then call calibrate() and getR0 to read in an accurate calibration value (though in practice I do not know if this mitigates errors enough to be worth the effort).

In MQ7.h, uncomment the line

#define _R0 0.025	

and put in your R0 value. Doing this will override the calibrate() method to do nothing, so there would be no need to call it under these conditions.

References

mq7's People

Contributors

fjebaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mq7's Issues

MQ7 with Esp32

Dear sir
Thank you for the great work.
I have a question.
Can I use the library with an Esp32?

voltage

Hi, Your code is working for me, it shows around 8.79 PPM, I dont know why, after a time it starts increasing :
21:07:15.528 -> PPM = 8.76
21:07:20.551 -> PPM = 8.88
21:07:24.535 -> PPM = 8.97
21:07:26.546 -> PPM = 9.02
21:07:30.559 -> PPM = 9.11
21:07:37.558 -> PPM = 9.22
21:07:40.545 -> PPM = 9.25
21:07:41.525 -> PPM = 9.27
ETC.
I'm not really in the electronics, but I read that this sensor neeeds 1.4V to measure and 5V to heat, and I've been watching really complicated projects with voltage regulators and other devices to manage the voltage, because if you dont use it right, the sensor will be damaged etc.. Im wondering how this very simple connection with just 3 wires(not even the digital output of the sensor) would work fine. Thanks for your answer! (and sorry for my mistakes:D)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.