Add temperature compensation to ultrasonic distance measurements #619
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.
This commit introduces temperature compensation to the ultrasonic sensor distance measurement functions, enhancing accuracy across a range of environmental conditions. The speed of sound varies with air temperature, impacting the precision of ultrasonic distance measurements.
Changes include:
ultrasonic_measure_temp_compensated
function for temperature-compensated distance measurements in meters.ultrasonic_measure_cm_temp_compensated
function for temperature-compensated distance measurements in centimeters.SPEED_OF_SOUND_AT_0C_M_S
macro to replace the magic number 331.4, clarifying the code and facilitating future adjustments.ultrasonic.h
header file to include prototypes for the new functions, alongside detailed comments explaining their usage, parameters.These enhancements allow users to obtain more accurate distance measurements from ultrasonic sensors in environments where temperature varies, without impacting existing functionality or requiring changes to existing code that utilizes the library.