# DIY weather station /w Enviro+ (MICS6814) - Converting Ohms to PPM

Hi there,

first off: this is not an openHAB-related topic but I wanted to post anyway because you guys always helped me =) (thanks for that)!

I ordered an Enviro+ sensor board (https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-enviro-plus) to build a Raspberry-based weather station. Assembling was quite easy and I came up with a self-written .py that reads sensor data and sends it to an MQTT broker.

openHAB subscribes to that MQTT broker and integrating the topics into OH works like a charm. Furthermore Iām persisting data in InfluxDB and visualize it in Grafana.

On the Enviro+ board, thereās a MICS6814 sensor for measuring āreducingā, āoxidisingā and NH3 gas(es). As the measurements are converted to Ohms Iād like to convert them into PPM to get a better understanding about air quality. Of course you could also monitor the Ohms and track air quality via them, but thatās not what Iād like to achieve.

So my question to all of you, who already did a similar conversion, is how I could tackle this. Iāve found a fact sheet @ https://www.sgxsensortech.com/content/uploads/2015/02/1143_Datasheet-MiCS-6814-rev-8.pdf, but at least the āreducingā graphās Y-axis only reaches to RS/R0 = 10.

• redu = 504 kOhm
• oxid = 27 kOhm
• NH3 = 369 kOhm

As always many thanks for your time, have a nice day!
Chris

What are the formulas?
Apply the formulas inside the python script BEFORE sending on MQTT and you will the ācorrectā values into openHAB

The key here is that you need to find you what are the mathematical formulae to convert the ohm value from the sensor into ppm

Hi Vincent,

unfortunately there are no formulas, just these diagrams with RS/R0 over PPM.

Please donāt get me wrong, Iām not assuming that anyone here is providing a working conversion for my specific case. Iām just looking if anyone has an approach on converting Ohms to PPM when it comes to eletrical sensors.

Many thanks for your reply and your tip with including that conversion into .py-script, Iām aware of that :). Iāll investigate further and if I find a solution Iāll post here!

KR
Chris

According to this site, PPM is

a method of stating a componentās tolerance value by specifying how many parts per million units a component may vary from its nominal value.

Put another way, itās a way to determine the tolerances of the electrical component. Iām definitely no expert, but I donāt think there is a single calculation that will work here. Every resistor and capacitor will have itās own individual set of tolerances. One of the examples from that site might be informative:

Letās say we a 1Mā¦ resistor.

A 1Mā¦ resistor is a resistor that has a color code of brown-black-green. It has a nominal value of 1,000,000ā¦.

Now letās say this resistor has a parts per million specification of 5000ppm. This means that for every 1,000,000 ohms of resistance that this resistor has, the resistance can vary as much as 5000 ohms. This means that this 1Mā¦ can have a resistance 5000 ohms below or above 1,000,000 ohms, which means its resistance can be as low as 995,000ā¦ or as high as 1,005,000ā¦ or somewhere in between.

Is that what you are after, or are you hoping to be able to convert the Ohms to a PPM of the gases you are sensing? If itās the latter, you canāt get there from here.

In gas work, ppm is a measure of concentration. Just another way to express percentage or ratio.

I think OP needs his sensor maker to cough up the needed formulae ?

Hi there,

many thanks for the links. Iāve found a C++ library @ [1] https://github.com/Seeed-Studio/Mutichannel_Gas_Sensor/blob/master/MutichannelGasSensor.cpp where the author is starting conversion at line 349 and below.

Curious about lines like āc = pow(ratio1, -1.179)*4.385ā I thought about exponential curves and stumbled upon a YT-video @ [2] https://www.youtube.com/watch?v=fBo3Yq9LK1U where a guy is explaining how to read that charts and get equations in the format Y = a *x ^b out of it.

So I started again with the fact-sheet of my initial post and tried myself, being able to reconstruct almost the same values like the library in [1].

Iām testing right now and try to evaluate if the āgeneratedā PPM could make sense in terms of common PPMs.

Thanks for your replies @rlkoshak and @rossko57!

That makes sense. Looking at the charts on the data sheet they are in a log10 scale. You canāt get a straight line on that sort of chart without there being exponential curves.

Comment only - that is a curious device. You seem to have to know what gases may be present before decoding what the output means. Reading XX might mean high AA% ammonia or BB% ethanol or CC% carbon monoxide or ā¦

My 2 cents having spent most of my 40+ year career in R&D, I have had some experience with gas sensors. As far as I know there is no such thing as a universal sensor and each sensor needs to be calibrated for the gas of interest. This requires measuring and plotting resistance (ohms) as a function of gas concentration(ppm). A regression analysis is performed using the data collected, and unless you know with certainty otherwise, a straight line is assumed over the range of concentrations of interest, so ohms=a +m(conc) where āaā is the y-axis intercept and āmā is slope of the line. If the range of interest is broad and the sensor has non-linearity then a quadratic or power law fit can be used. The sensor mfg should provide this info ( at least generically if not specifically for that particular sensor) with sale of the sensor.

2 Likes

Hi @rossko57,
the MICS6814 has 3 different sensors, one for reducing gases, one for oxidising gases and one for NH3. Depending on what youād like to āconvertā (Iām writing this in " ", because I donāt think that this citizen science device will be able to replace professional sensors that are thoroughly calibrated) youāve to apply your individually generated exponential curves.

For the moment Iām therefore āconvertingā CO and NO2.

Hi @John_Siemon,
as itās my first touching point with that stuff (enviromental data on a citizen science base) I wanted to start a small project because Iām interested in such appliances (especially for Raspberry). I read an article about the Enviro+ sensor board in a Pi magazine and ordered it with the intention toā¦

• learn sth about enviromental data
• learn a bit of Python
• make use of a MQTT broker
• play around with my unused RPI

Thanks for clarifying how itās properly done - for the moment Iām trying to calibrate NO and CO2 as thereās a professional station around that provides official calibrated and open data.

CO (official): 0.3mg/mĀ³ eq. ~ 0.262ppm @ 28.01 g/mol
NO2 (official): 9Āµg/mĀ³ eq. ~ 0.005 ppm @ 46.01 g/mol

So Iāll tweak a bit to get that CO right and then I guess Iām done.

Finally, something Iād like to add here - of course I donāt have intentions to take that collected data serious in any way. For me itās a project that helps me learning new stuff with the idea to get a rough idea if air quality is improving or worsening.

Have a nice day and KR,
Chris

Those arenāt bad readings; I was wondering whether it was sensitive enough for any useful measurement of environmental atmosphere (as opposed to gross contaminants like a propane leak)

I think openHABs `Number:Dimensionless` type supports ppm units already. If the g/mol and g/mĀ³ are common units, you could raise a request to have those added too for general benefit. My science is rusty, but those are properly āratiosā and so Dimensionless as well?

Hi guys,

after a few days of testing and tweaking Iām happy with the results. Also I donāt have any remarkable jitters (< 0,1%), so I can say that the sensor is providing stable readings (yes, at different temperatures and humidities).

Here are the main steps;

• Read sensor-data with Python-library (these values are in Ohms for that specific sensor)
• Based on diagrams in sensorās fact sheet: build the exponential curve based on the gas youād like to convert (in my case CO and NO2)
• Put the Ohms in that equation (be careful if the diagrams are in Ohm or kOhm) to get PPM
• Optional: Further conversion to mg/mĀ³ [1]
• Optional: Sending data to MQTT
• Optional: openHAB subscribing to MQTT-topics
• Optional: openHAB persisting data in InfluxDB
• Optional: Grafana visualizing data from InfluxDB

In my case I was able to validate my readings via a nearby official and calibrated station.

[1] If youāre interested into further conversion like PPM to mg/mĀ³ have a look into https://www.teesing.com/files/source/understanding-units-of-measurement.pdf.

Donāt hesitate to drop me a line here, Iāll elaborate further if itās of interest.

@rossko57 - my items are numbers (float) with their unit defined specifically.

Hi, Iāve actually purchased the same hardware, with the same goal in mind, just havenāt had a chance to work it together yet. Feel like sharing your code & details of how it all works?

Thanks

Hi! I have the same problem. Anyone can share the code to build the exponential curve based on the gas?

Thanks

HI @Zylan, Hi @dta,

unfortunately Iām very busy at the moment, so I canāt go into details. What may help you for sure is Paul van Haastrechtās Excel on GitHub - https://github.com/paulvha/multichannel-gas.

If you take a look into āmics 6814.xlsā, youāll find the curves youāre looking for! These differ only slightly from mine. So @dta thereās no ācodeā to build the curves - youāve to read them on your own from the fact-sheet.

@Zylan you can take a look into the shipped .py-files to get an idea of how to read sensor data.

KR

Hi @csi_oh,

Thanks for your feedback and time. So, I donāt want the code to create the curves, only a code that converts Ohms to ppm ā¦ if possible.

Thanks again,
Joan

Hi,

have you looked into this? Starting line 345ff.

Hereās some code that will do the conversion based on the datasheet graphs. Theyāre developed by undertaking a log-log linear regression. You will need to define R0 for each sensor, based on each sensorās resistance in air. That allows you to undertake calibration. I havenāt included any temperature or humidity compensation at this stage.

Hope it helps.

red_r0 = 200000
ox_r0 = 20000
nh3_r0 = 750000

red_in_ppm = math.pow(10, -1.25 * math.log10(gas_data.reducing/red_r0) + 0.64)
ox_in_ppm = math.pow(10, math.log10(gas_data.oxidising/ox_r0) - 0.8129)
nh3_in_ppm = math.pow(10, -1.8 * math.log10(gas_data.nh3/nh3_r0) - 0.163)
return red_in_ppm, ox_in_ppm, nh3_in_ppm

2 Likes

Hi @Roscoe27,

The numbers here for the RED, OX and NH3 R0. Are they some rough estimates or ballpark figures? Iāve tried using this function and check the result on the sensor data sheet charts and it works out well.

So far I was just recording the kOhm output for each sensor and what always surprises me is how OX reading goes up whenever I open the window. The readouts would normally be around 22 kOhm, with opened window would go to 30-35 kOhm. I would really like to see how much ppm of NO2 are we talking about here.

You need to measure the resistances in āstandard airā (i.e. with the normal levels of gas concentrations found in air) to obtain the three R0 resistance levels. They form the baselines against which RS is measured as each gas concentration varies from āstandard airā. The algorithms are then applied to RS/R0 for each sensor. I donāt think you can specifically measure NO2, just the combination of oxidising gases as per the datasheet graphs.