Start listening to the sensor right after releasing the start signal … #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi all,
Here is my pull request for the changes I have done relate to how the library sends the start signal to the sensor and the hope is it will solve and that it will have the effect of a closed #48. It also relates to PR #51 and PR #58.
Firstly, there is an unnecessary wait of 250ms before the start signal. This is the reason I started to look at fixing the init sequence. I remember reading that it could be needed by those not using a pull up, in 85a02c7. ( If that were the case, the pin is set HIGH in begin(), it could be set again before exiting the read method. The pin state should stay HIGH as no other read can be made in the following two seconds, so more than enough time to cover that 250ms that I would like to have removed. We would also need to make sure the first read is done after proper period if sensor needs time to wake up upon start. )
Second, from what I conclude after a read of the datasheet and from what I have read on several forums, the MCU should only pull the line LOW for a period of time and then leave the line to the sensor. There is a possible variable amount of time before the sensor will signal its LOW and HIGH for ~80us each while preparing the data. This part
was changed for a busy-wait loop to ensure the library gets it at a correct time and not have the guess the wait period for all possible sensors. This has made the delayMicroseconds() calls redundant. That should also satisfy the change that was originally suggested by Wolfgang and referenced in 5ed9818.
The changes' goal is to ensure the MCU and sensor do not talk at the same time. A few comments were also added to support the code changes.
Thank you,
Pascal