-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add temperature compensation to ultrasonic distance measurements
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.
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters