RAK 7204 LPP Payload - Indoor Air Quality

Is the Payload called (by default) Analogue Input 4 in Cayenne, the following IAQ (Indoor Air Quality) ?

I get a value of about 24.25

You can check this out.

Hi,@patmolloy
About the Air Quality of RAK7204(with BME680 sensor) isn’t gived IAQ but the air resistance value. https://community.bosch-sensortec.com/t5/Knowledge-base/BME680-gas-sensor-series-design-guide/tac-p/7199#M32


How to convert to IAQ you could refer to their official library:https://github.com/BoschSensortec/BSEC-Arduino-library.

Thanks!

This is not so good, though. I do not see a way on TTN (or Cayenne) to get from Air Resistance to IAQ. I cannot use any of their libraries in the LoRaWAN use case.

Pat

I’m interested too!
I understand it would require a converter from the measurement in ohms to IAQ.
Quite right?

FROM:

BME680 IAQ Example

Using the BME680 to measure temperature, pressure, humidity and air quality.

The sensor is used to obtain the so-called Gas Resistance and then calculate an Index of Air Quality (IAQ) from a combination of humidity and the gas content readings of the air, optionally temperature could be added too, but omittied in this example.

The index is a function of humidity which contributes up to 25% and gas concentrations that contributes up to 75%. See slide1.jpg for details of the IAQ index formulation.

In this current version only Humidity and Gas concentrations are used for the index, but adding temperature woudl be straightforward on the basis that temperatures for humans that are too high or low add to the overal Air Quality index along with Humidity and Gas concetrations.

Humidity is measured between 0 - 100% and is universally accepted as being optimal when it is 40% and where in this index the contribution will be 0, but at a Humidity reading of 0%, the contribution increases to 25% and similarly when humidity reaches 100% it contributes 25% to the index. See Slide1 for details.

Gas concentrations for normal breathable air with no pollutants (no adverse gases) corresponds to the sensors highest resitance output of 50,000 ohms or more. The sensor normally outputs a Gas resistance value ranging from a low of 50ohm to a high of 50,000ohm and beyond. A linear relationship is assumed and the output scaled accordingly between 0 and 75% for the range 50-50,000 ohms.

The result of combining humidity and gas measurements into an in index is a qualitative and so-called IAQ - Indoor Air Quality index value scaled from 0-100% (where 100% is good). This is then scaled again from 0-500 where a 500 value is bad and descriptive values are applied in stages from good to hazardous air quality.

There is no definitive (ISO Standard) method for calculating an IAQ.

(c) d.l.bird 2018 all rights reserved and as per the Licence agreements listed in my software.

This IAQ and the ideas and concepts is Copyright (c) David Bird 2018. All rights to this IAQ and software are reserved. Any redistribution or reproduction of any part or all of the contents in any form is prohibited other than the following:

  1. You may print or download to a local hard disk extracts for your personal and non-commercial use only.
  2. You may copy the content to individual third parties for their personal use, but only if you acknowledge the author David Bird as the source of the material.
  3. You may not, except with my express written permission, distribute or commercially exploit the content.
  4. You may not transmit it or store it in any other website or other form of electronic retrieval system for commercial purposes.

The above copyright (‘as annotated’) notice and this permission notice shall be included in all copies or substantial portions of the IAQ index and Software and where the software use is visible to an end-user.

Hi there,

Sorry to revive this post, but this seems the best fitting thread for this, as I was looking at this as well.

I could not find it anywhere else, but as I was also interested in getting an IAQ value out of this, I created a converter for at least TTN, that returns the IAQ as a percentage as well as level as per first post. You will need to paste the following script into the converter portion of the payload ( and also include the default RAK decoder to make sense of the data first). I made use of the code that was provided for an Arduino implementation, and most of it is vanilla C syntax, so very close to the original, apart from the gas calculation, which seemed to calculate the wrong results at first, hence includes my own adaption.

// Modified from https://github.com/G6EJD/BME680-Example
/*
 This software, the ideas and concepts is Copyright (c) David Bird 2018. All rights to this software are reserved.
 
 Any redistribution or reproduction of any part or all of the contents in any form is prohibited other than the following:
 1. You may print or download to a local hard disk extracts for your personal and non-commercial use only.
 2. You may copy the content to individual third parties for their personal use, but only if you acknowledge the author David Bird as the source of the material.
 3. You may not, except with my express written permission, distribute or commercially exploit the content.
 4. You may not transmit it or store it in any other website or other form of electronic retrieval system for commercial purposes.
 The above copyright ('as annotated') notice and this permission notice shall be included in all copies or substantial portions of the Software and where the
 software use is visible to an end-user.
 
 THE SOFTWARE IS PROVIDED "AS IS" FOR PRIVATE USE ONLY, IT IS NOT FOR COMMERCIAL USE IN WHOLE OR PART OR CONCEPT. FOR PERSONAL USE IT IS SUPPLIED WITHOUT WARRANTY 
 OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 See more at http://www.dsbird.org.uk
*/  

function Converter(decoded, port) {
  
  var converted = {}; // init object to be returned in the end
  
  var  hum_weighting = 0.25; // so hum effect is 25% of the total air quality score
  var  gas_weighting = 0.75; // so gas effect is 75% of the total air quality score
  var hum_reference = 40;
  
  
  var gas_reference = decoded.gasResistance; // assign decoded gasResistance in kOhm
  
    //Calculate humidity contribution to IAQ index
  var current_humidity = decoded.humidity;
  if (current_humidity >= 38 && current_humidity <= 42)
    hum_score = 0; // Humidity +/-5% around optimum 
  else
  { //sub-optimal
    if (current_humidity < 38) 
      hum_score = hum_weighting * 100 * ((hum_reference - current_humidity)/hum_reference);
    else
    {
      hum_score = hum_weighting * 100 * (current_humidity - hum_reference)/(100-hum_reference);
    }
  }

   //Calculate gas contribution to IAQ index
  var gas_lower_limit = 5;   // Bad air quality limit
  var gas_upper_limit = 50;  // Good air quality limit 
  var gas_delta = gas_upper_limit - gas_lower_limit; // delta between upper and lower limit to simplify equation later
  if (gas_reference > gas_upper_limit) gas_reference = gas_upper_limit; 
  if (gas_reference < gas_lower_limit) gas_reference = gas_lower_limit;
  gas_score = gas_weighting * 100 * ((gas_upper_limit - gas_reference )/ gas_delta);
  
  //Combine results for the final IAQ index value (0-100% where 100% is good quality air)
  converted.IAQ = hum_score + gas_score;
  
  var IAQ_text = "Air quality is ";
  var score = converted.IAQ*5;
  if      (score >= 301)                  IAQ_text += "Hazardous";
  else if (score >= 201 && score <= 300 ) IAQ_text += "Very Unhealthy";
  else if (score >= 176 && score <= 200 ) IAQ_text += "Unhealthy";
  else if (score >= 151 && score <= 175 ) IAQ_text += "Unhealthy for Sensitive Groups";
  else if (score >=  51 && score <= 150 ) IAQ_text += "Moderate";
  else if (score >=   0 && score <=  50 ) IAQ_text += "Good";
  converted.IAQText = IAQ_text;
  
  // re-add the previously decoded values
  converted.temperature = decoded.temperature;
  converted.humidity = decoded.humidity;
  converted.gasTesistance = decoded.gasResistance;
  
  return converted;
}

I had to slightly adjust the default RAK decoder to remove the units from the numbers in the following lines - I know, hacky, I guess one could substring these out or parse float? - I have never used Javascript before, so please feel free to modify:

 myObj.humidity = parseFloat(((parseShort(str.substring(4, 6), 16) * 0.01 / 2) * 100).toFixed(1));//unit:%RH

and

myObj.gasResistance = parseFloat((parseShort(str.substring(4, 8), 16) * 0.01).toFixed(2));//unit:KΩ

I have no idea how to do this in Cayenne, but maybe someone else can take this further for any other solutions.

cheers

Edit: since I got it wrong the first time, I just made the changes necessary to reflect the graphs, which the calculations now do. However, since then, I have also looked a bit further, and these calculations might not be a true reflection of the IAQ. In fact, the readings I get tell me, that it is hazardous, which I am not sure I can agree with and it might require some fine-tuning to get it right.

The sensor relies on a closed-source library that decides when it needs data to come up with the IAQ that the published table of results is derived from.

I did have an idea about remoting the requests from the library on a server back to the device but it’s not a priority as it is likely to kill the downlinks - I’m more inclined to creating firmware that includes the Bosch sensor library and directly transmit the IAQ, bearing in mind this may require a power supply as it won’t sleep as much as a normal LoRa node.

Yes, that is also something that I have found out by reading through the linked GitHub comments on another project. The problem will be, that multiple readings are likely necessary, as well as maybe continuous operation for the gas sensor to work properly.