good use of MICS-6814 sensor (gaz) ?

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

good use of MICS-6814 sensor (gaz) ?

Post by IHOXOHI » Fri May 15, 2020 6:52 am

Hi,
I'm using a MICS-6814 sensor (from china) which indicate 3 gaz concentrations (N02, NH3 and CO) by a analog sensor... on a pyboard.
Output voltages are very lows.
So, I use a ADS1115 amplificator. The result looks good.
But, I have interrogations about NO2 sensor.
The datasheet of the sensor : https://www.sgxsensortech.com/content/u ... -rev-8.pdf
My simple code :

Code: Select all

from machine import I2C
from ads1x15 import *
from time import sleep

i2c = I2C(2)

adc = ADS1115(i2c = i2c, address = 72, gain = 4)

while True:
    value_no2 = adc.read( rate=0, channel1=0 )
    value_nh3 = adc.read( rate=0, channel1=1 )
    value_co = adc.read( rate=0, channel1=2 )

    print("NO2brut= ", value_no2)
    print("NH3brut= ", value_nh3)
    print("CObrut= ", value_co)

    no2_volt = value_no2 * (0.512/32767)
    nh3_volt = value_nh3 * (0.512/32767)
    co_volt = value_co * (0.512/32767)
    
    print("NO2volt= ", no2_volt, "volt")
    print("NH3volt= ", nh3_volt, "volt")
    print("COvolt= ", co_volt, "volt")

    no2 =  (10) * (value_no2 * (0.512/32767)) 
    nh3 = (100) * (value_nh3 * (0.512/32767))
    co = (1000) * (value_co * (0.512/32767))

    print("NO2= ", no2, "ppm")
    print("NH3= ", nh3, "ppm")
    print("CO= ", co, "ppm")

    sleep(10)
So, results looks goods, but I don't understand the fact that the no2 sensor have a resistor wich get down with an increase of concentration, reverse for 2 others sensor and, in final only the same calcul of concentration looks working for all sensors?

Moreover, I can't display the result on the lcd160cr... a i2c conflict with ads1115? If someone known a solution for display result from ads1115?

Thanks.

IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

Re: good use of MICS-6814 sensor (gaz) ?

Post by IHOXOHI » Fri May 22, 2020 11:01 am

Hi,
Everything is resolved...
This script looks works fine with lcd160 too...

Code: Select all

from machine import I2C
from ads1x15 import *
from time import sleep
import lcd160cr

i2c = I2C(2)

adc = ADS1115(i2c = i2c, address = 72, gain = 4)


lcd = lcd160cr.LCD160CR('X')
lcd.set_orient(lcd160cr.LANDSCAPE)

lcd.set_text_color(lcd.rgb(0, 0, 255), lcd.rgb(0, 0, 0))
lcd.set_font(1, scale=1)

while True:
    value_no2 = adc.read( rate=0, channel1=2 )
    value_nh3 = adc.read( rate=0, channel1=1 )
    value_co = adc.read( rate=0, channel1=0 )

    print("NO2brut= ", value_no2)
    print("NH3brut= ", value_nh3)
    print("CObrut= ", value_co)

    no2_volt = value_no2 * (0.512/32767)
    nh3_volt = value_nh3 * (0.512/32767)
    co_volt = value_co * (0.512/32767)
    
    print("NO2volt= ", no2_volt, "volt")
    print("NH3volt= ", nh3_volt, "volt")
    print("COvolt= ", co_volt, "volt")

    no2 =  value_no2 * (10*(0.512/32767)) 
    nh3 = value_nh3 * (500*(0.512/32767))
    co = value_co * (1000*(0.512/32767))

    print("NO2= ", no2, "ppm")
    print("NH3= ", nh3, "ppm")
    print("CO= ", co, "ppm")

    no2 = round(no2, 3)
    nh3 = round(nh3, 3)
    co = round(co, 3)
    no2 = str(no2)
    nh3 = str(nh3)
    co = str(co)

    lcd.erase()
    lcd.set_pos(0, 0)
    lcd.write("NO2= ")
    lcd.write(no2)
    lcd.write("ppm") 
    lcd.set_pos(0, 20)
    lcd.write("NH3= ")
    lcd.write(nh3)
    lcd.write("ppm")
    lcd.set_pos(0, 40)
    lcd.write("CO= ")
    lcd.write(co)
    lcd.write("ppm")
    sleep(1)


    sleep(1)
I think that values aren't perfectly exacts, but not very far from reality... Maybe I'm completly wrong...
If somoene has an advise for values 's calculation....

I have tested this china sensor with ad1115 and arduino without success... Arduino need a sensor with i2c connection. I think resolution coulden't be as well as with ad1115...

Enjoy!

IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

Re: good use of MICS-6814 sensor (gaz) ?

Post by IHOXOHI » Tue Jul 07, 2020 5:28 pm

After calibration with 2 arduino ; one with the 3 gas sensor (I2c), and the other with an analog MQ-2 sensor ; wich doesn't have exactly same values, I obtain that... in " my normal" testing condition...

Code: Select all

adc = ADS1115(i2c = i2c, address = 72, gain = 5)
        value_no2 = adc.read( rate=0, channel1=0 )
        value_nh3 = adc.read( rate=0, channel1=1 )
        value_co = adc.read( rate=0, channel1=2 )
        no2 =  value_no2 * (80*(0.256/32767)) 
        nh3 = value_nh3 * (4000*(0.256/32767))
        co = value_co * (2500000*(0.256/32767))

IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

Re: good use of MICS-6814 sensor (gaz) ?

Post by IHOXOHI » Mon Jul 20, 2020 10:47 am

Yep,

After testing with a professional co sensor, co gas value is wrong. CO value change when real value has no change...
I don't know for NH3 and NO2 values...
I'm given up with co value of this sensor.

IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

Re: good use of MICS-6814 sensor (gaz) ?

Post by IHOXOHI » Wed Jul 22, 2020 2:21 pm

Finally, co gas woks fine, for sure, with this code:

Code: Select all

adc = ADS1115(i2c = i2c, address = 72, gain = 4)
value_co = adc.read( rate=0, channel1=2 )
co = value_co * (10000*(0.512/32767))
If it's allright you should have 0 in usual situation and nearly 30 ppm when you smoke on the sensor.

I haven't calibrate NO2 and NH3 gas with a proffessional sensor like for co gas, but for moment there isn't big problem in comparaison with values of the I2c 3 gas sensor by groove on arduino (wich, for me, is wrong of 30 ppm for co gas in normal condition with 0 ppm).

If someone know a method for test these gas...

Post Reply