Skip to content
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

Add temperature compensation to ultrasonic distance measurements #619

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

hayschan
Copy link
Contributor

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:

  • Added ultrasonic_measure_temp_compensated function for temperature-compensated distance measurements in meters.
  • Added ultrasonic_measure_cm_temp_compensated function for temperature-compensated distance measurements in centimeters.
  • Defined SPEED_OF_SOUND_AT_0C_M_S macro to replace the magic number 331.4, clarifying the code and facilitating future adjustments.
  • Updated the 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.

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:
- Added `ultrasonic_measure_temp_compensated` function for temperature-compensated distance measurements in meters.
- Added `ultrasonic_measure_cm_temp_compensated` function for temperature-compensated distance measurements in centimeters.
- Defined `SPEED_OF_SOUND_AT_0C_M_S` macro to replace the magic number 331.4, clarifying the code and facilitating future adjustments.
- Updated the `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.
@UncleRus
Copy link
Owner

Now that's high-quality PR. Thank you!

@UncleRus UncleRus merged commit acedb7a into UncleRus:master Mar 15, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants