miguel5612 / MQSensorsLib

We present a unified library for MQ sensors, this library allows to read MQ signals easily from Arduino, Genuino, ESP8266, ESP-32 boards whose references are MQ2, MQ3, MQ4, MQ5, MQ6, MQ7, MQ8, MQ9, MQ131, MQ135, MQ136, MQ303A, MQ309A.
MIT License
169 stars 64 forks source link

MQUnifiedsensor integration with ESPHome #41

Closed gsgameiro closed 2 years ago

gsgameiro commented 3 years ago

I'm not able to make MQUnifiedsensor working with ESPHome. I'm using a tutorial based in Custom Sensor Component but I believe because my code is in C (not C++) I´m not able to declare and initialize in other to set up parameter (board, pin, etc).

When declaring sensor MQUnifiedsensor bmp("ESP8266", 3.3, 10, A0, "MQ-135"); //this in the line that doesn't compile correctly MQUnifiedsensor bmp; //while with this line compile is success but returns are wrong because of set up not done

My code .h ESPHome compiling errors ESPHome config .yaml

Alternative In case there is no way to declare and initialize it, I would like to help you to create methods to initialize (to set up the Board, Pin, Type, Voltage_Resolution, ADC_Bit_Resolution and RatioMQ9CleanAir) if you would like to add it to the library to improve compatibility (I'm new here but I want to help as possible).

I truly believe if we go forward it will get this library more support from the ESPHome community and it will be widely popular on the ESPHome platform.

nukleuz80 commented 3 years ago

Hey there,

i want include it too in esphome. Is it possible?

nukleuz80 commented 3 years ago

Same to me - i want to include but only errors... Do you have a solution for that?

miguel5612 commented 2 years ago

Currently the library is not configured to be compatible with C and yaml for esphome, however if you detail it the library contains all the values implicit in the examples, you have to implement in ESPHome a function that raises values following the exponential equation and after knowing the voltage, calculate the Rs/R0 value and with the equation obtain the PPM, it would be a reengineering applied to esphome, I would suggest you to create a new repository for it and try it since in this repository you can't implement it because it would affect the compilation for arduino.

Show more on this repo: https://github.com/miguel5612/MQSensorsLib_Docs