Beispiel #1
0
 public BMP085()
 {
     driver = new I2cDriver(SDAPIN.ToProcessor(), SCLPIN.ToProcessor());
     connection = new Bmp085I2cConnection(driver.Connect(ADDRESS));
 }
Beispiel #2
0
        /// <summary>
        /// Gets the altitude.
        /// </summary>
        /// <param name="connection">The BMP085 connection.</param>
        /// <param name="sealevelPressure">The sealevel pressure.</param>
        /// <returns>The altitude</returns>
        public static Length GetAltitude(this Bmp085I2cConnection connection, UnitsNet.Pressure sealevelPressure)
        {
            var pressure = connection.GetPressure();

            return(Length.FromMeters(44330 * (1.0 - Math.Pow(pressure.Pascals / sealevelPressure.Pascals, 1 / 5.255))));
        }
        /// <summary>
        /// Gets the altitude.
        /// </summary>
        /// <param name="connection">The BMP085 connection.</param>
        /// <param name="sealevelPressure">The sealevel pressure, in hPa.</param>
        /// <returns>The altitude, in meters</returns>
        public static decimal GetAltitude(this Bmp085I2cConnection connection, decimal sealevelPressure)
        {
            var pressure = connection.GetPressure();

            return((decimal)(44330 * (1.0 - Math.Pow((double)(pressure / sealevelPressure), 0.1903))));
        }
Beispiel #4
0
        /// <summary>
        /// Gets the sea-level pressure.
        /// </summary>
        /// <param name="connection">The BMP085 connection.</param>
        /// <param name="currentAltitude">The current altitude.</param>
        /// <returns>The pressure.</returns>
        public static UnitsNet.Pressure GetSealevelPressure(this Bmp085I2cConnection connection, Length currentAltitude)
        {
            var pressure = connection.GetPressure();

            return(UnitsNet.Pressure.FromPascals(pressure.Pascals / Math.Pow(1.0 - currentAltitude.Meters / 44330, 5.255)));
        }
        /// <summary>
        /// Gets the sea-level pressure.
        /// </summary>
        /// <param name="connection">The BMP085 connection.</param>
        /// <param name="currentAltitude">The current altitude, in meters.</param>
        /// <returns>The pressure, in hPa.</returns>
        public static decimal GetSealevelPressure(this Bmp085I2cConnection connection, decimal currentAltitude)
        {
            var pressure = connection.GetPressure();

            return((decimal)((double)pressure / Math.Pow(1.0 - (double)currentAltitude / 44330, 5.255)));
        }