-
Notifications
You must be signed in to change notification settings - Fork 4
Adding Humidity and Temperature compensation to SGP40 in preperation for VOC Algorithm #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ll as a raw measurement that takes temp and humidity as inputs for humidity compensation raw measurements on the sgp40
… datasheet table 9 where the default humidity is 50, not 49.999. It's a small change but it might make refering to the datasheet more clear.
…8 now calls generate_crc
…_READ_CMD or the calculated command can be used. measure_raw takes in temp and humidity and prepares the measure command and calls raw allowing for humidity compensation on the raw reading
Thanks for your contribution I saw that you changed the command lists already. Thanks.
Did you build the documentation, have not try that kind of table before so not sure how sphinx will treat it. (just curious) Thanks again :) |
And that point brings us here (which I think is the heart of the issues of this pull request):
Looking just a little further at its structure I could get around this by adding a Then relatedly Looking forward, I could avoid the issue and completely hide I felt this was a good point to make a pull request because I think (and could be wrong) that the VOC Algorithm from this point on does not interact with the sgp40. So if a microcontroller is tight on space and can send the raw humidity-compensated value from the sgp40's readings to another system, you could just run the VOC Algorithm on that secondary system. Anyway, thanks for the feedback! I'll clean up the prints and add some more documentation to the comments! |
No problem Thank you I have other comments, more related with the code than the
yes normally all the Adafruit libraries are setup to crate virtual environments and work with pre-commit, So I strongly recommend using this tool as it will do pylint and black at the same time for you. so the command will be
Yes it is. Is the easiest way that would work 95% of the time. Another way is to create a free account in readthedocs and import you repos and build the documentation there. we would need in the other 5% as sometimes documents render locally are no the same as with the CI (but we would get there when we get there) Non Breaking ChangesYes, we try to avoid this as much as possible, or to do them in a way of changes will not affect old code, so you would probably see in helpers library a lot of kwargs, as more and more functionalities are added. But if we need to break old code, there has to be a a good reason: major improvement, compatibility, Bug fix. raw_functionBut regarding your question a good way on what to do with the function is here Documenting FunctionsCircuitPython has a mixed way of documenting functions and parameters, but how to do it is explained in the design guide, or you could use other libraries as an example Other Unspoken GuidelinesCircuitPython use a lot of tuples instead of lists, and bytearrays, so when you return values, return them as tuples. CircuitPython likes to work with Properties as for the end user is easier to understand. |
I'd like to add an example for the And to that point, how do I adjust the requirements to state that for humidity compensated raw values, (and for the VOC Algorithm) it will need a second sensor? |
Interesting... we are uncharted waters here then, however I thought the sensor included a T/H already |
…ep similar functions near each other, removed debug prints, and added some comments to clarify how to use the measure_raw class function. Readme has been updated with an example usage, and the simpletest.py now reflects the measure_raw sample, though it's commented out due to external dependencies
I messed something up with the documentation but I'm new to sphinx so that's far from surprising. Additionally, I'm going to remove reference to the |
If you need help with the documentation I could help with that (I have done my share part of documentation) So I could commit to your branch. It is up to you :) |
Certainly! I don't actually know where to begin looking for this warning treated as error issue
I'm sure it's a simple problem, and I'll pull your commit if you like--but because I want to get better at it I'm going to read through the commit to see the difference between mine and yours and will probably ask you questions if you don't mind. |
Lets discuss in the dev channel it would help other folks :) |
Thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing major
Things related to this particular PR
Name of the function
parameter documentation
and quickstart correction
Co-authored-by: jposada202020 <[email protected]>
Co-authored-by: jposada202020 <[email protected]>
Co-authored-by: jposada202020 <[email protected]>
Co-authored-by: jposada202020 <[email protected]>
Co-authored-by: jposada202020 <[email protected]>
Co-authored-by: jposada202020 <[email protected]>
Co-authored-by: jposada202020 <[email protected]>
Co-authored-by: jposada202020 <[email protected]>
Co-authored-by: jposada202020 <[email protected]>
Co-authored-by: jposada202020 <[email protected]>
…larified the temperature type for the celsius to ticks conversion
There's a few more mentions of busio to clean up, but I'm not 100% clear as to why it's being removed? Is it a library/set of functions that are being removed in favor of a simpler 'board' import? And is bus device different from busio? |
Thanks. use the busio is deprecated. sometimes it could cause conflicts in the bus. So we underwent a big update in all the libraries and learning guides, to update this. there will be some that have that busio reference, but we are moving away from this. |
we wait a little to see if other folks want to chime in, But I think we are pretty much good to go. |
Ok those last four changes should remove the comments and usage of busio from everything but the conf.py file which references it in the template generated comment. I think that should cover the full pull request--busio and register have been removed from reference, and the sgp40 now has a measure_raw method which takes in temperature and relative humidity to return a humidity compensated reading. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_BME280 to 2.6.5 from 2.6.4: > Moved default branch to main > Merge pull request adafruit/Adafruit_CircuitPython_BME280#52 from jposada202020/memory_otimization > Moved CI to Python 3.7 Updating https://github.com/adafruit/Adafruit_CircuitPython_HTU31D to 1.1.1 from 1.1.0: > Merge pull request adafruit/Adafruit_CircuitPython_HTU31D#6 from gmparis/main > Moved CI to Python 3.7 > Added help text and problem matcher > Added pull request template Updating https://github.com/adafruit/Adafruit_CircuitPython_ICM20X to 2.0.8 from 2.0.7: > Linted > Moved default branch to main > Moved CI to Python 3.7 > Added help text and problem matcher > Added pull request template Updating https://github.com/adafruit/Adafruit_CircuitPython_IRRemote to 4.1.0 from 4.0.6: > Moved default branch to main > Merge pull request adafruit/Adafruit_CircuitPython_IRRemote#42 from danielballan/nonblocking > Moved CI to Python 3.7 > Added help text and problem matcher > Added pull request template Updating https://github.com/adafruit/Adafruit_CircuitPython_L3GD20 to 2.3.6 from 2.3.5: > Merge pull request adafruit/Adafruit_CircuitPython_L3GD20#23 from jposada202020/correcting_measuremnt_units > Moved default branch to main > Moved CI to Python 3.7 > Added help text and problem matcher > Added pull request template Updating https://github.com/adafruit/Adafruit_CircuitPython_SGP40 to 1.1.0 from 1.0.3: > Merge pull request adafruit/Adafruit_CircuitPython_SGP40#4 from CrakeNotSnowman/voc_algorithm_dev > Moved CI to Python 3.7 > Added help text and problem matcher > Added pull request template Updating https://github.com/adafruit/Adafruit_CircuitPython_SHTC3 to 1.1.2 from 1.1.1: > Moved default branch to main > Merge pull request adafruit/Adafruit_CircuitPython_SHTC3#11 from jposada202020/master > Moved CI to Python 3.7 > Added help text and problem matcher > Added pull request template Updating https://github.com/adafruit/Adafruit_CircuitPython_SI4713 to 1.3.2 from 1.3.1: > Moved default branch to main > Merge pull request adafruit/Adafruit_CircuitPython_SI4713#20 from jposada202020/solving_station_information Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1306 to 2.11.6 from 2.11.5: > Corrected url > Merge pull request adafruit/Adafruit_CircuitPython_SSD1306#64 from jposada202020/correcting_example_link Updating https://github.com/adafruit/Adafruit_CircuitPython_Colorsys to 2.0.1 from 2.0.0: > Moved default branch to main > Merge pull request adafruit/Adafruit_CircuitPython_Colorsys#17 from GomiHgy/patch-1 > Moved CI to Python 3.7 > Added help text and problem matcher > Added pull request template Updating https://github.com/adafruit/Adafruit_CircuitPython_FunHouse to 2.1.4 from 2.1.3: > Merge pull request adafruit/Adafruit_CircuitPython_FunHouse#17 from jposada202020/adding_new_guides
In short this lets a user provide temperature (in C) and humidity (in percentage) to the SGP40 for a humidity compensated raw value reading.
Humidity compensation is necessary for the VOC algorithm mentioned in #2 and this should help implement the VOC algorithm over the next week or two.
There is a spelling correction and I adjusted the _READ_CMD byte array to match the provided byte array in the SGP40 data sheet (table 9). This shouldn't have a large impact on anyone's code since the byte array was generated used input humidity of 49.999%, and the datasheet example used an input of 50%.
The checksum
_check_crc8
was adjusted to call a new function--generate_crc which is basically the original _check_crc8 with the adjustment that it returns the crc byte.Temperature and Humidity are converted to their 'tick' value according to the equation in the datasheet.
And
measure_raw
takes in the temperature and humidity, converts them to ticks, then generates a measure command hex array. Once the measure_command is generated it calls raw to handle the communication.