Greetings
Iam trying to set up gas monitoring system for air quality with different types of gas sensors. I have a a mics6814 triple gas sensor that I would to set up for air quality gas ppm. I have the gas.py example program from PimoroniI as shown below which gives resistance values only.
#!/usr/bin/env python3
import time
from mics6814 import MICS6814
import logging
gas = MICS6814()
logging.basicConfig(
format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S')
print("""gas.py - Print readings from the MICS6814 Gas sensor.
Press Ctrl+C to exit!
""")
try:
while True:
readings = gas.read_all()
logging.info(" | ".join(str(readings).splitlines()))
time.sleep(1.0)
except KeyboardInterrupt:
pass
I came across the following three equations resistance to ppm from(Roscoe) on the forum. I am a beginner in python programming and want to be able to integrate these equations into the example program to display ppm gas readings.
Heya, could you edit your post to repair the formatting? Like many places on the web, this forum uses Markdown, which uses a few symbols to format text. This means that code can’t be pasted directly into the editor - it needs a slight tweak. Specifically, a block of code needs to start and end with a “code fence”, which is three backticks on their own line.
So try adding them to your code, by clicking on the pencil icon to edit:
```
your code goes here
your code goes here
your code goes here
```
This will ensure readers can see your Python indentation too, which is important.
I am using a Raspberry Pi3g with mics6814.
I also have a few other environmental sensors working fine.
I am not sure how to incorporate those three equations into to the example program and then display the ppm readings on screen. Do I get rid of the “all” reading, are there single “read” commands for each of the three sensors in the mics6814?
Not sure how to proceed.
Thanks for correcting the formatting.
Thanks
Tom
You should be able to get the gas sensor readings separately by doing something like this, if that helps?
import time
from mics6814 import MICS6814
gas = MICS6814()
try:
while True:
oxi_rs = gas.read_oxidising()
red_rs = gas.read_reducing()
nh3_rs = gas.read_nh3()
print(oxi_rs)
print(red_rs)
print(nh3_rs)
time.sleep(1.0)
except KeyboardInterrupt:
pass
I’m not sure why your formulas use two readings each though - perhaps the original code might tell you what red_rs and red_r0 (for example) refer to?