Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports for MQ analog sensor for air quality #14581

Merged
merged 8 commits into from
Jan 24, 2022

Conversation

francescoadriani
Copy link

Description:

It's support the analog sensor for quality air (also for esp-32)
-added on list of assignable pins in module
-with adcparams can choose whic mqx you have with seconds param ex: adcparam 10 4 (you have the mq-04)
immagine_2022-01-23_172341

Related issue (if applicable): fixes #

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.4.9
  • The code change is tested and works with Tasmota core ESP32 V.2.0.2.1
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

It's support the analog sensor for quality air (also for esp-32)
-added on list of assignable pins in module
-with adcparams can choose wich mqx you have with seconds param ex: adcparam 10 4 (you have the mq-04)
tasmota/xsns_02_analog.ino Outdated Show resolved Hide resolved
tasmota/xsns_02_analog.ino Outdated Show resolved Hide resolved
tasmota/xsns_02_analog.ino Outdated Show resolved Hide resolved
tasmota/xsns_02_analog.ino Outdated Show resolved Hide resolved
@arendst arendst merged commit 6ecfc31 into arendst:development Jan 24, 2022
arendst added a commit that referenced this pull request Jan 24, 2022
Add support for MQ analog sensor for air quality by Francesco Adriani (#14581)
@erdinguma
Copy link

Issuing command: adcparam 10 4 is not changing the sensor from the default MQ2 to MQ4. Any guidance?

@barbudor
Copy link
Contributor

@erdinguma Did you correctly configured your ADC input in the GPIO configuration ?

@erdinguma
Copy link

erdinguma commented Mar 14, 2022

@barbudor Yes. Selected “ADC MQ” and I am reading values. Just need to change it to MQ 4.

image

image

@rice103
Copy link

rice103 commented Mar 14, 2022

The help update has not yet been released but you need to change a & b exponential regression params via adcparams.
Syntax is AdcParam1 <ANALOG_MQ_TYPE> <(ANALOG_MQ_A> <ANALOG_MQ_B> <ANALOG_MQ_RatioMQCleanAir>
Last params is not used for now, could be 0

@erdinguma
Copy link

It worked!
Mq-4 command: AdcParam 10, 4.00, 1012.70, -2.79, 4.40

@rice103
Copy link

rice103 commented Mar 14, 2022

Yeah!

@erdinguma
Copy link

erdinguma commented Mar 15, 2022

For future enhancement, considering high sensitivity of the sensor to humidity and temperature, I inferred from documentation the following relationship of ratio (rs/r0) to temp and humidity.
(From documentation)
image

(T & H Interpolation)
image

Ratio adjustment factor (F) for Temp T and Humdity H:
F = 5.693977721259878 + -0.023280722319645328 * T + -0.24767739454737786 * H + 0.00054602964962393 * T^2 + -0.0001297777486611509 * T * H + 0.004485775052457577 * H^2 + -7.564523748530513e-06 * T^3 + 1.277287227509287e-06 * T^2 * H + 1.2323178573075948e-06 * T * H^2 + -2.5805390257858728e-05 * H^3

@rice103
Copy link

rice103 commented Mar 17, 2022

Is not simple link two sensor value.. But could be a starting point for future developments

@erdinguma
Copy link

Yes. I am thinking to implement something similar to Sensirion SGP40 or SGP41 which reads another sensor, SHT4x to compensate VOC sensing for temp and humidity. (I realize SGP41 itself hasn't even been ported to Tasmota yet)

In the interim, I thought to post my compensation formula because it can be used in post processing of data after received from MQTT and it would make a significant difference in results even if not processed at firmware level in real time.

@Links2004
Copy link

Hi,
2 questions to the code.

  • from where do the values for ANALOG_MQ_A, ANALOG_MQ_B and ANALOG_MQ_RatioMQCleanAir come from?
    I like to use a MQ-135 and cant find the values needed.

  • based on the datasheet of the MQ-7 it needs some voltage changes, is this Implemented in the code and if yes how to configure the PIN for it?

image

@francescoadriani
Copy link
Author

francescoadriani commented Jun 1, 2022

@Links2004 #14581 (comment)
No voltage changes implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants