maccoylton / esp-homekit-air-quality-sensor

Apache License 2.0
9 stars 6 forks source link

Mq135 pin missing #2

Closed lizzus closed 5 years ago

lizzus commented 5 years ago

I have not found pin where connect mq135 sensor. I also check inside main file and I see thermometer sensor pin. This is a multi sensor firmware?

maccoylton commented 5 years ago

The mq135 must be connected to the Analog ping, for example pin 2 ADC0 on a WeMos mini

lizzus commented 5 years ago

I’m using a nodemcu. Where I need to connect?

maccoylton commented 5 years ago

image

As above ADC0, on this picture top left pin

lizzus commented 5 years ago

Ok, right and mq135 analog out. Right? Can you check file into release? I try to flash, but is another firmware. Is a thermostat firmware.

lizzus commented 5 years ago

Temp is on GPIO4 - D2. Now i can close :-)

maccoylton commented 5 years ago

Make sure you DO NOT connect the MQsensor directly to a GPIO .. it outputs 5v so you need to use a voltage divider

lizzus commented 5 years ago

i'm using vin port of nodemcu for power mq135 and works fine IMG_7863

maccoylton commented 5 years ago

it;s the output .. looks like a blue wire in your case .. this can output 5v .. it need to go through a voltage divider

lizzus commented 5 years ago

blue connect directly to ADC0 on nodemcu. Works without problem. Whats happened without a voltage divider? MQ135 take voltage from same source (nodemcu)

lizzus commented 5 years ago

IMG_7864 IMG_7865

maccoylton commented 5 years ago

Boards with a usb connector tend to have both +5V and +3V. The ESP chip runs on +3.3V, the analog input ADC0 can take a maxim of 3v, the analog output of the MQ135 can generate up to +5V≤, connecting this directly you module WILL damage your module.

maccoylton commented 5 years ago

Looks like many boards already have a voltage divider, which you can tweak using a restore, see here for an explanation:- https://arduinodiy.wordpress.com/2016/12/25/monitoring-lipo-battery-voltage-with-wemos-d1-minibattery-shield-and-thingspeak/

nhatquang88 commented 5 years ago

So can we use DO instead or AO? Does this sensor is accurate ? thank you

maccoylton commented 5 years ago

If by DO you mean the digital output on he MQ135, the answer is no as this only gives one of two values, high or low, based. Using he analogue init/output allows for a range of values required to calculate concentration of various items measured.

I've no way of testing the accuracy of the sensor, what I have done is test introducing methane close to it, and smoke close to it and it responds in an appropriate manner

nhatquang88 commented 5 years ago

z1368823758395_0e69d5fbd84fd558b5c75716ca5e5713

I connect the sensor today... I tried 2 or 3 sensor but my reading is wrong.. even CO or PM10 density.. I remote the ADO but the reading still the same.. are there anything I did wrong in there? thank you

maccoylton commented 5 years ago

The MQ135 sensor is only capable of sensing a couple of the item on the list above, namely PM10 density and CO level, It will also give an overall air quality level. To sense other gases more sensor are required.

Per my previous reply, depending on which board you are using, you need to bring down the voltage of the output of the MQ125 to the suitable voltage for the input pin you are using in your module. Connecting directly to the ESP module as your picture suggest may cause damage.

What ESP module are you using?
The MQ135 requires +5v?

Can you also provide log file.

nhatquang88 commented 5 years ago

@maccoylton thank you so much for replying. I just put the MQ135 right next to the car exhaust fumes and the CO value and PM10 read very hight then air quality set to Poor immidiately. I measure the voltage of the AO in my board then the maximum it read when I put it in the car exhaust is 3v... . Anyway If I want to bring down the voltage how can I do it? put another resistor to it? I used NodeMcu ESP8266 CH340. MQ135 plug in to 5V sources.

If I want to connect more sensor to read all other value, what Sensor I need to buy and how can I connect it.. Thank you

nhatquang88 commented 5 years ago

B803D813-D9E2-4992-8DFB-30377D52E8A8

lizzus commented 5 years ago

in nodemcu you have only one Analogic input

lizzus commented 5 years ago

I also connected MQ135 sensor directly to nodemcu. It works from 1 month without problem. I don't understand why @maccoylton suggest to use a resistor if mq135 wotk with 5vdc voltage...

nhatquang88 commented 5 years ago

in nodemcu you have only one Analogic input

Do u suggest another board which has many AO input so we can put multi sensor in it?

maccoylton commented 5 years ago

@lizzus Yes it works but there is still a risk. The voltage output by the MQ135 on the analogue pin increase with poorer air quality and decrease with better air quality. The range is very low (good air quality) to +5v (very bad air quality). So if the air quality is really bad you would exceed the maximum voltage the input is capable to accept and risk blowing your ESP Module.

It is your choice, be safe or risk blowing your chip.

ESP8266 Input Voltage Range

The ESP8266 ADC pin input voltage range is 0 to 1V if you’re using the bare chip. However, most ESP8266 development boards come with an internal voltage divider, so the input range is 0 to 3.3V. So, in sumary:

ADC Voltage range in ESP8266 development boards: 0 to 3.3V (for example: ESP8266 12-E NodeMCU Kit, WeMos D1 Mini, …) ADC Voltage range in ESP8266 chip: 0 to 1V (for example: ESP-07 chip, ESP-12E chip, ESP-12F chip,…)

lizzus commented 5 years ago

ok, finally i understand. So, in my case, i need to reduce voltage in Analogic input pin from 5v to 3.3v with a resistor?

maccoylton commented 5 years ago

@nhatquang88 to be safe connect a between the analog output of MQ135 and the analog input of the ESP module. For the nodeMCU, the builtin voltage divider is 220k/100k, so a adding a 180k should ensure 5v is divided to no more than 1v

maccoylton commented 5 years ago

@lizzus yes, so if you are using a Wemos D1 or a NodeMCU then you can stick a 180k resisters inline.