static void Main(string[] args) { using (BMP180 bmp180 = new BMP180()) { try { var temperature = bmp180.ReadTemperature(); var pressure = bmp180.ReadPressure(); var altitude = bmp180.ReadAltitude(); var p0 = bmp180.ReadSeaAltitude(); Console.WriteLine("Temperature {0}.{1} *C", temperature / 10, temperature % 10); Console.WriteLine("Pressure {0} Bar", pressure); Console.WriteLine("Altitude {0:0.##} mts", altitude); Console.WriteLine("Sealevel Pressure {0} Pa", p0); } catch (Exception ex) { var st = new StackTrace(ex, true); var frame = st.GetFrame(0); var line = frame.GetFileLineNumber(); Console.WriteLine("[{0}]: {1}", line, ex.Message); } } }
private static void DirectReadThread() { Debug.Print("____________Sensor Data using direct read methods____________"); while (true) { Debug.Print("Temperature - " + _bmp180.ReadTemperature().ToString("f2") + (_bmp180.TemperatureUnit == TemperatureUnits.Celsius ? "°C" : _bmp180.TemperatureUnit == TemperatureUnits.Fahrenheit ? " °F" : "°K")); Debug.Print("Temperature RawData - " + (_bmp180 as ITemperature).RawData); Debug.Print("SLC Compensated Pressure - " + Pressure.ToInchesHg(_bmp180.ReadPressure()).ToString("f1") + " in Hg"); Debug.Print("Uncompensated Pressure - " + Pressure.ToInchesHg(_bmp180.ReadPressure(PressureCompensationModes.Uncompensated)).ToString("f1") + " in Hg"); Debug.Print("Pressure RawData - " + (_bmp180 as IPressure).RawData); Debug.Print("Altitude - " + Altitude.ToFeet(_bmp180.ReadAltitude()) + " feet"); Debug.Print("\n"); Thread.Sleep(5000); } }
private static void Main() { _bmp180 = new BMP180(Hardware.SocketOne) { OverSamplingSetting = BMP180.Oss.UltraHighResolution, TemperatureUnit = TemperatureUnits.Celsius }; Debug.WriteLine("BMP180 Demo"); Debug.WriteLine("Is a BMP180 connected? " + _bmp180.IsConnected()); Debug.WriteLine("BMP180 Sensor OSS is - " + _bmp180.OverSamplingSetting + "\n"); while (true) { Debug.WriteLine($"Temperature : {_bmp180.ReadTemperature():F2} °C"); Debug.WriteLine($" Pressure : {_bmp180.ReadPressure():F1} Pascals"); Debug.WriteLine($" Altitude : {_bmp180.ReadAltitude():F0} meters\n"); Thread.Sleep(2000); } }