Code Monkey home page Code Monkey logo

Comments (5)

OttoWinter avatar OttoWinter commented on August 16, 2024

These are just analog sensors - they give the gas value as an analog voltage reading. So the adc sensor supports MQ-2s already. All you need will be to come up with a formula that converts the analog voltage reading to a gas reading (for example from datasheet)

Please see TEMT6000 example for how to do this.

from esphome-core.

BrownC0de avatar BrownC0de commented on August 16, 2024

Thanks for the quick response and information. And one little questin.
In my sensors sketch:
`float BaseMQ::calculateResistance(int rawAdc) const {
// float vrl = rawAdc*(5.0 / 1023); // Так по класcике
float vrl = rawAdc * (5.0 / 1551); // Так у нас
float rsAir = (5.0 - vrl) / vrl * getRL();
if (_corr_factor_set) {
rsAir = rsAir / _corr_factor;
}
Help me write the formula for - lambda correctly
Thx.

from esphome-core.

OttoWinter avatar OttoWinter commented on August 16, 2024

It's not too hard to convert it. You can pretty much copy paste it:

float vrl = x * 5.0;
// you didn't post getRL method, so no way I know what that does
float rsAir = (5.0 - vrl) / vrl * getRL();
return rsAir;

Also I can tell you your formula is probably wrong. The * 5.0 looks a lot like you're using 5V voltage level, but the ESP operates at 3.3V which would require you to use some external circuitry to scale the voltage.

from esphome-core.

BrownC0de avatar BrownC0de commented on August 16, 2024

This sensor works from 5 volts (as far as I know), but the terminal gives 5.0 volts
getRL - This probably means
protected:
unsigned long readScaled(float a, float b) const;
virtual float getRoInCleanAir() const = 0;
virtual int getRL() const = 0;
And
private:
// Резистор установленный на плату (кОм)
virtual int getRL() const { return 1; }
// коэффициент чистого воздуха
virtual float getRoInCleanAir() const { return 9.83; }

from esphome-core.

Esiravegna avatar Esiravegna commented on August 16, 2024

Based on my experience, the analgo reader of the ESP8266 doesn't sit along well with the MQ2. I had better luck using an arduino as an I2C slave, reading the sensors with that and then the i2C to the ESP8266

from esphome-core.

Related Issues (20)

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.