Skip to main content

Module units

Module units 

Source
Expand description

Converting readings between real-world units.

Cheap environmental sensors report whatever unit their datasheet chose - a BME280 gives pressure in pascals, a thermocouple in degrees Celsius - while the person reading a dashboard thinks in another. These are the exact, named conversions for the units the cookbook uses most, so a conversion is a call with an obvious name rather than a magic constant copied into application code.

Functionsยง

celsius_to_fahrenheit
Converts a temperature from degrees Celsius to degrees Fahrenheit.
celsius_to_kelvin
Converts a temperature from degrees Celsius to kelvin.
fahrenheit_to_celsius
Converts a temperature from degrees Fahrenheit to degrees Celsius.
hectopascals_to_pascals
Converts a pressure from hectopascals (millibars) to pascals.
kelvin_to_celsius
Converts a temperature from kelvin to degrees Celsius.
kilopascals_to_pascals
Converts a pressure from kilopascals to pascals.
pascals_to_hectopascals
Converts a pressure from pascals to hectopascals (millibars).
pascals_to_kilopascals
Converts a pressure from pascals to kilopascals.
pascals_to_psi
Converts a pressure from pascals to pounds per square inch.
percent_to_ratio
Converts a percentage to a fraction in 0.0..=1.0.
psi_to_pascals
Converts a pressure from pounds per square inch to pascals.
ratio_to_percent
Converts a fraction in 0.0..=1.0 to a percentage.