-
Notifications
You must be signed in to change notification settings - Fork 184
Update luftdaten.py with better error handling and logging #81
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
Labels
enhancement
New feature or request
Comments
roscoe81
added a commit
to roscoe81/enviroplus-python
that referenced
this issue
Aug 9, 2020
Add Logging, PMS5003 Checksum exception and Luftdaten exception handling as per Issue pimoroni#81
Merged
JWCook
pushed a commit
to JWCook/rpi-enviro-monitor
that referenced
this issue
Nov 9, 2021
Initial Commit Documentation Fixed badge URLs Fixes/improvements from pypa/sampleproject Get lib name automatically for install endpoints Fixed linting error Script for setting up git remotes Synced with bootstrap Start gas and tests Clarified pin use, fixed missing setup Added examples rename envirophatplus -> enviroplus README board name change Updated install/uninstall scripts Adding a couple of new examples Update gas.py Changing references to MICS6812 to MICS6814 Adding new Luftdaten example Enable i2c and SPI Tweaking temp compensation value Fix for PMS5003 ReadTimeoutError Adding all-in-one example Improvements to compensated temperature code flake8 fiddling Update README.md Exclude fonts from DoS check Updated README.rst Fix in lieu of pimoroni#1 Fix PM10 label unit Decode fix for pimoroni#3 Switch to v2 installer Add Raspbian Lite dependencies for pimoroni#6 Update README install instructions Add links & blurb to README Recommend OLI install Back up to /boot to survive OLI rm Add PIL for pimoroni#6 adding install notes for python-pil, python-setuptools Add setuptools minimum version trap config.txt probably doesn't support inline comments pimoroni#9 Packaging fixes from boilerplate Add pip for pimoroni#6, correct indendation Bootstrap with python-configparser from apt Install improvements Create RESOURCES_DIR early Ensure required dependencies are installed Create all-in-one-no-pm.py Example for all of the sensors built in, omitting the optional particulate matter sensor. Add ADC channel support into gas module Add example to demo ADC channel usage Expand test coverage, bugfix Adding delay to avoid rate-limiting by Luftdaten +x Switch temp comp method for pimoroni#28 Update all-in-one-no-pm.py added decoding of bytestring to provide Python3 compatibility. Update all-in-one.py added decoding of bytestring to provide Python3 compatibility. Update luftdaten.py added decoding of bytestring to provide Python3 compatibility. Merged cipy-master Dropped obsolete .decode() testing all examples, with corrections for Python3 support allow temperature reads to converge a bit faster use generic variables; handle pms5003.ReadTimeoutError use generic variables in -no-pm code too improved logging with timestamps (instead of print) catching the correct ReadTimeoutError for pms5003 Replaced exception pass with log warning Fix typo Transitional fix for new LTR559 library Added a new combined mode example This is a modification of all-in-one.py. It adds another mode where all EnviroPlus and PMS5003 sensor readings are combined on one screen. Each variable that is displayed can have custom warning limits assigned which change the color of the text according to a predefined RGB palette. It allows for a quick glance of all sensor readings at once in order to jugde if everything is OK in the air or to quickly pinpoint a sensor reading that requires attention. In addition, the new combined mode saves each reading as soon as it is received for graphing later. As in all-in-one.py, moving your finger close to the proximity sensor switches the mode. Fixed graphing problem for PMS5003 results The PMS5003 library returns integers. This causes the current formula for color scaling of the graph to not work properly because of integer division instead of float division. Converting the PMS5003 results from int to float solves the problem. Adding all in one weather and light display example Adding Python 3 shebang Python 3-related fixes, moving to pip fonts, fixing Astral errors. Remove inappropriate sleep between reads The PMS5003 seems to buffer unread samples. If you are reading at a lower rate than it takes readings, then a progressively larger delay will occur between changes in actual PM levels and indicated PM levels. To see the issue: 1) run this example with the `time.sleep(1)` *included* 2) wait a few minutes 3) burn a piece of paper near the sensor and wait for the reported PM levels to spike With the sleep included, there is a delay between introducing smoke and seeing reported levels rise (often a few minutes or longer). With the sleep removed you will see reported levels update almost immediately. The correct way to use the sensor is to read as fast as the sensor allows, and not make any assumptions about what rate samples will be published at Noise library and examples for basic FFT and frequency binning Tidy up noise examples Add dtoverlay for mic Add DocStrings and linting Fix noise-profile example Add deps for noise measurement Fix launch bug in all-in-one-no-pm.py Launching all-in-one-no-pm.py results in an error due to line 57. FontSize should be replaced with the variable font_size, to run line 57 without error. Sleep before first PMS5003 reading Prep for v0.0.2 Update README for 0.0.2 Address Issue pimoroni#55 Fix noise_floor bug Test tweaks and linting I've re-written the tests to use conftest.py to set up and tear down mock modules via fixtures. I have also linted the examples, removing redundant linebreaks, commenting out unused variables and attempting to simplify long lines. Test noise, fix gas Move package and requires to setup.cfg Drop Python 2.6 Catch pimoroni#61 with tests and fix Include python cffi in setup dependencies Added supported board images and example Correcting examples Adds mqtt example (pimoroni#68) Adds mqtt example by @robmarkcole - see also: https://github.com/robmarkcole/rpi-enviro-mqtt Added user projects section to README Update mqtt-all.py Fix combined.py indentation for Python 3.x Experimental fix to communicate Py version reqs for pimoroni#78 Minute instead month in backup file name Fix for the DATESTAMP variable, to show proper file name. Added user project: enviroplus_exporter Add GitHub actions workflow Remove .travis.yml Update python versions for CI (pimoroni#96) * Drop Python 3.4 - GitHub reports it as not found, despite it being in the list it links to!?!?!? * Fix Coveralls Add two third party projects to the README adds username and password parameters to mqtt-all adds username and password check fix checking for username and password Adding MQTT Username / Password & TLS Config Signed-off-by: James Sutton <[email protected]> Tweaking the arguments for MQTT TLS Signed-off-by: James Sutton <[email protected]> Adding MQTT Username / Password & TLS Config Signed-off-by: James Sutton <[email protected]> Add support for ADS1115 Use the auto-detect feature of the ADS1015 library to support reading the gas sensor via an ADS1115. Add support for ADS1115 Switch README to markdown (drop dependency on pandoc) Update luftdaten.py Add Logging, PMS5003 Checksum exception and Luftdaten exception handling as per Issue pimoroni#81 Update luftdaten.py Added suggested changes but removed "logging.info('Luftdaten Climate Success', values)", since I found it redundant, given the use of "logging.info("Luftdaten Response: OK")" in Line 215. Drop Python2 support. Linting fixes Add available() method to gas sensor This change catches an IOError when setting up the gas sensor and provides an `available()` method for determining if a sensor is present. Trigger tests Test read_all throws exception when unavailable Fixup tests for ADC detect. Update changelog & readme Drop Python2 from Makefile Correct README to python3 Direct users toward Python3, install explicitly Add check-install.py debug script
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can see a few improvements to
luftdaten.py
which may be worth incorporating:update_time = time.time()
to beforesend_to_luftdaten
so the data sending function has the full 145??? seconds to retry sending the values. Though I can't see any fearture for sending a timestamp to luftdaten.enviroplus-python/examples/all-in-one-no-pm.py
Lines 22 to 31 in 7452b88
Need to ensure instructions aren't broken: https://learn.pimoroni.com/tutorial/sandyj/enviro-plus-and-luftdaten-air-quality-station
Should probably attempt to log to
/tmp/luftdaten.log
since the instructions linked above do not pipe error output anywhere useful.Additionally it might be worth authoring a systemd unit for running and maintaining the script.
The text was updated successfully, but these errors were encountered: