Micro Python - Calculate speed of sound with temperature and humidity

Raspberry Pi Pico
Below will allow you to create accurate speed of sound calculations taking into consideration temperature and humidity in micro python.

Tested on a Raspberry Pi Pico W.


The results of the code below is not quite exact, but its pretty close.




MICRO PYTHON CODE:

from math import sqrt


def speed_of_sound(temperature, humidity):

    c = 331.3 * sqrt(1 + (temperature/273.15)) + 0.606 * temperature * sqrt(humidity/100) - 5.6 * (1 - humidity/100)

    return c


# Example usage

temperature = 10.0 # in degrees Celsius

humidity = 90.0 # as a percentage


speed = speed_of_sound(temperature, humidity)

print("The speed of sound in air at {0}°C and {1}% humidity is {2:.2f} m/s".format(temperature, humidity, speed))



Popular posts from this blog

Review - E-Yooso Z-88 Keyboard

Replacing Viking GB455 Mulcher Blades