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:
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.