dj_janker
Posts: 59
Joined: Thu Jan 08, 2015 6:15 pm

python for mq-135 sensor

Fri Jun 05, 2015 1:41 pm

Hi,
somebody knows any python script to read in real time the differents parameters of the mq-135 sensor?
I would like to make a air quality sensor with my Rpi, but I haven´t found any python...

ghp
Posts: 1418
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: python for mq-135 sensor

Fri Jun 05, 2015 4:28 pm

Hello,

there is a nice arduino-related tutorial for MQ 135 in http://playground.arduino.cc/Main/MQGasSensors.

Assuming it is this sensor mentioned there, it provides a single voltage output only for it whatever the sensor is measuring.
Unfortunately, this voltage is 0 to 5V (at least it is possible to be in this range), so you need
- an ADC-Converter like MCP3002 or MCP3202, which is inexpensive, running from 3.3V
- a voltage divider on the input, which brings down 5V to 3.3V

The load resistor can form a voltage divider when you use two resistors in series, for RL = 20kOhm, the 'ground resistor' is 13kOhm and 6.8 kOhm to the sensors output. Be sure the voltage divider is build 'rock solid', specially the ground connection in order to prevent 5V to flow into precious ADC.

Now the question has changed to 'how to connect and run a MCP3002, MCP3202'.
On my web page, there is a sketch on how to connect the MCP3202 (text in german) http://heppg.de/ikg/wordpress/?p=134

There is quite a lot of sample code for these devices.

Regards
Gerhard

dj_janker
Posts: 59
Joined: Thu Jan 08, 2015 6:15 pm

Re: python for mq-135 sensor

Sat Jun 06, 2015 6:03 am

I have several MCP3008 and MCP23017
could them work?

ghp
Posts: 1418
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: python for mq-135 sensor

Sat Jun 06, 2015 6:12 am

Hello,

MCP3008 is an ADC converter. Give it a try.

Regards,
Gerhard

magearlik
Posts: 9
Joined: Sat Jun 20, 2015 9:35 am

Re: python for mq-135 sensor

Sat Jun 20, 2015 10:21 am

Why do I need an analog converter when I have digital out? This is what I have:

http://www.ebay.com.au/itm/251930629656 ... EBIDX%3AIT

ghp
Posts: 1418
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: python for mq-135 sensor

Sat Jun 20, 2015 9:03 pm

Hello,
this module obviously has a comparator 'on board', so not only the bare sensor.
Of course you can use digital output here; possibly you need a voltage divider to adjust the 5V-level to the 3.3V-Level.
Regards,
Gerhard

Return to “Python”