Exemple #1
0
        private static void Main()
        {
            _bmp085 = new BMP085(Hardware.SC20100_1, Hardware.SC20100_1.Int)
            {
                OverSamplingSetting = BMP085.Oss.UltraHighResolution,
                TemperatureUnit     = TemperatureUnits.Celsius
            };

            Debug.WriteLine("BMP085 Demo");
            Debug.WriteLine($"BMP085 Sensor OSS is - {_bmp085.OverSamplingSetting}\n");

            while (true)
            {
                Debug.WriteLine($"Temperature : {_bmp085.ReadTemperature():F2} °C");
                Debug.WriteLine($"   Pressure : {_bmp085.ReadPressure():F1} Pascals");
                Debug.WriteLine($"   Altitude : {_bmp085.ReadAltitude():F0} meters\n");
                Thread.Sleep(2000);
            }
        }
Exemple #2
0
        public static string OneWire_Temperaturea()
        {
            // Change this your correct pin!
            Cpu.Pin myPin = (Cpu.Pin)FEZ_Pin.Digital.Di4;

            OneWire ow = new OneWire(myPin);
            ushort  temperature;

            {
                BMP085 pressureSensor = new BMP085(0x77, BMP085.DeviceMode.UltraLowPower);

                string temperature_Pressure;
                if (ow.Reset())
                {
                    ow.WriteByte(0xCC);     // Skip ROM, we only have one device
                    ow.WriteByte(0x44);     // Start temperature conversion

                    while (ow.ReadByte() == 0)
                    {
                        ;                          // wait while busy
                    }
                    ow.Reset();
                    ow.WriteByte(0xCC);                          // skip ROM
                    ow.WriteByte(0xBE);                          // Read Scratchpad

                    temperature  = ow.ReadByte();                // LSB
                    temperature |= (ushort)(ow.ReadByte() << 8); // MSB

                    temperature_Pressure = "Temperature: " + temperature / 16 + "\n" + "BMP085 Pascal: " + pressureSensor.Pascal +
                                           "   BMP085 InchesMercury: " + pressureSensor.InchesMercury.ToString("F2") + "   BMP085 Temp*C: " + pressureSensor.Celsius.ToString("F2");
                }
                else
                {
                    temperature_Pressure = "Temperature Device is not Detected";
                }

                ow.Dispose();
                Thread.Sleep(1000);
                return(temperature_Pressure);
            }
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            using (_bmp = new BMP085())
            {
                try
                {
                    _bmp.Connect();

                    var temp     = _bmp.getTemperature();
                    var pressure = _bmp.getPressure();
                    var alt      = _bmp.getAltitude(10);
                    var seal     = _bmp.getSealevelPressure(10);

                    txtTemp.Text = temp.ToString();
                    txtHumi.Text = pressure.ToString();
                }
                catch (Exception ex)
                {
                    Windows.UI.Popups.MessageDialog dlg = new Windows.UI.Popups.MessageDialog(ex.Message, "Error!");
                }
            }
        }