adafruit / Adafruit_SGP30

Arduino library for SGP30
Other
56 stars 38 forks source link

Add humidity compensation #4

Closed mguntli closed 6 years ago

mguntli commented 6 years ago

The SGP30 features an on-chip humidity compensation for the air quality signals (CO2eq and TVOC) and sensor raw signals (H2-signal and Ethanol_signal). To use the on-chip humidity compensation an absolute humidity value from an external humidity sensor like the SHTxx is required.

mdeyo commented 6 years ago

@mguntli What's your progress on addressing the CI errors? I was about to implement the 'set_Humidity' function as documented in the SGP30 datasheet and could help with this request.

mguntli commented 6 years ago

My implementation is according to the SGP30 datasheet (see function setHumidity). I have forked an own SGP30 library for the particle platform (https://github.com/mguntli/particle-lib-sgp30), and wanted to share back my additions with this pull request.

I would be happy if you could have a look at the CI errors, thanks for that!

Note: The approximation formula to get the absolute humidity [mg/m^3] based on temperature [°C] and humidity [%RH] is the recommended one from Sensirion SGP30 Driver Integration chapter 3.16 https://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/9_Gas_Sensors/Sensirion_Gas_Sensors_SGP30_Driver-Integration-Guide_SW_I2C.pdf

equation
with AH in g/m^3, RH in 0-100%, and t in °C

ladyada commented 6 years ago

hiya just a note - if this isnt compiling, it wasnt tested & we wouldnt merge unless it was tested!

mdeyo commented 6 years ago

Ordered the breakout board because of the SGP30 setHumidity feature and was disappointed to not see it exposed yet. Branch author has setHumidity interface working on his own forked project but renamed the class. Just trying to get that function where more people can use it (also addresses #3).

mguntli commented 6 years ago

I can confirm that I have tested the humidity compensation feature on my Adafruit SGP30, but only with my own fork of the library with different class naming (https://github.com/mguntli/particle-lib-sgp30/pull/1).

SGP30 and SHT31-D: SGP30 and SHT31-D

Absolute Humidity Values in mg/m^3: Absolute Humidity Values

All Values of SGP30 and STH31-D: All Values

mguntli commented 6 years ago

@ladyada Any chance you will merge this pull request?

ladyada commented 6 years ago

it would need to be tested with a sensor and arduino...if you do that on this repo please let us know!

mdeyo commented 6 years ago

@ladyada I finally had time to test the code from his branch "mguntli:feature/adafruit-humidity-compensation" (using commit d5e793e5e0500feb442de5760b8b12b36b49848d) on a Huzzah ESP8266 (using Arduino IDE). It works without errors, both with the setHumidity function commented out (default in his sgp30test example) and with it using the given constant temp+humidity sample values. I also printed the boolean responses from readWordFromCommand to ensure the commands in setHumidity were working. Let me know if you want additional proof of my testing/verification! (Like do you also want it tested on an Arduino?)

ladyada commented 6 years ago

sounds good! pulled :) thank you!!!