Esempio n. 1
0
        public async Task <Bmp180SensorData> GetSensorDataAsync(Bmp180AccuracyMode oss)
        {
            // Create the return object.
            var sensorData = new Bmp180SensorData();

            // Read the Uncompestated values from the sensor.
            var tData = await ReadUncompestatedTemperature();

            var pData = await ReadUncompestatedPressure(oss);

            // Keep raw data for debug
            sensorData.UncompestatedTemperature = tData;
            sensorData.UncompestatedPressure    = pData;

            var ut = (tData[0] << 8) + tData[1];
            var up = (pData[0] * 256.0) + pData[1] + (pData[2] / 256.0);

            // Calculate real values
            var b5 = calculateB5(ut);

            var t = (b5 + 8) >> 4;

            sensorData.Temperature = t / 10.0;

            var s = sensorData.Temperature - 25.0;
            var x = (x2 * Math.Pow(s, 2)) + (x1 * s) + x0;
            var y = (y2 * Math.Pow(s, 2)) + (y1 * s) + y0;
            var z = (up - x) / y;

            sensorData.Pressure = (p2 * Math.Pow(z, 2)) + (p1 * z) + p0;

            return(sensorData);
        }
Esempio n. 2
0
        public async Task<Bmp180SensorData> GetSensorDataAsync(Bmp180AccuracyMode oss)
        {
            // Create the return object.
            var sensorData = new Bmp180SensorData();

            // Read the Uncompestated values from the sensor.
            var tData = await ReadUncompestatedTemperature();
            var pData = await ReadUncompestatedPressure(oss);

            // Keep raw data for debug
            sensorData.UncompestatedTemperature = tData;
            sensorData.UncompestatedPressure = pData;

            var ut = (tData[0] << 8) + tData[1];
            var up = (pData[0] * 256.0) + pData[1] + (pData[2] / 256.0);

            // Calculate real values
            var b5 = calculateB5(ut);

            var t = (b5 + 8) >> 4;
            sensorData.Temperature = t/10.0;

            var s = sensorData.Temperature - 25.0;
            var x = (x2 * Math.Pow(s, 2)) + (x1 * s) + x0;
            var y = (y2 * Math.Pow(s, 2)) + (y1 * s) + y0;
            var z = (up - x) / y;

            sensorData.Pressure = (p2 * Math.Pow(z, 2)) + (p1 * z) + p0;

            return sensorData;
        }