Git Product home page Git Product logo

co2sensor's Introduction

Overview

Library allows to read and calibrate modules based on CO2 sensor.

TGS4161

TGS4161

MG811

MG811

Pinout

  • VCC - stabilized voltage (5V for TGS4166 and 6V for MG811)
  • GND - ground
  • AOUT - link to an analog input of Arduino.
  • DOUT - digital value indicates whether current concentration exceeds some thretshold value (can be adjusted by potentiometer)
  • TCM - temperature compensation (I have no details)

TGS4161 wiring

Module wiring in Fritzing

Calibration Theory

General information

Before calibration it is necessary to refresh the room. Then we treat concentration of co2 as 400 ppm.

Concentration calculation

Sensor provides a value (voltage between 0 and 5 V) which we need to convert to a concentration value by formula:

c=d^((a-v)/b)

where

  • c - co2 concentration in ppm
  • d - some constant. 400 in our case.
  • v - input from AOUT in millivolts
  • a - a parameter which we'll change during calibration. (Initially 1500)
  • b - a constant. 600 in our case

Software calibration

In order to calibrate we should modify a value using this formula

a := v + b*(Ln(c1)/Ln(d))

where

c1 - is the current real concentration value. For example for well refreshed room it will be 400 ppm.

Actually we always take d = c1 in such case our calculation will be simpler and we do not need calculate Ln. Then actual adjustment formula is just

a := v + b

If we decide to change c1 then we should change b and d constants using such formulas

  • d := c1
  • b := 100*Ln(c1)

Hardware calibration

The module contains 2 potentiometers.

  • Left - adjusts threshold of DOUT
  • Rigth - hardware sensor calibration

Usage

Class constructor accepts one parameter - analog input of arduino. Specify the number of analog input linked to AOUT of the module (A0, A1, A2 etc)

The example of arduino sketch is here.

CO2 concentration impact on humans

CO2 impact

From here

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.