コード例 #1
0
        public static void Execute()
        {
            var settings = BME280Driver.GetSpiConnectionSettings(G120E.GpioPin.P2_27);

            var controller = SpiController.FromName(G120E.SpiBus.Spi0);

            var device = controller.GetDevice(settings);

            var driver = new BME280Driver(device);

            driver.Initialize();

            driver.ChangeSettings(
                BME280SensorMode.Forced,
                BME280OverSample.X1,
                BME280OverSample.X1,
                BME280OverSample.X1,
                BME280Filter.Off);

            driver.Read();

            Debug.WriteLine("Pressure: " + driver.Pressure);
            Debug.WriteLine("Humidity: " + driver.Humidity);
            Debug.WriteLine("Temperature:" + driver.Temperature);
        }
コード例 #2
0
        public static void Main()
        {
            var settings = BME280Driver.GetI2CConnectionSettings(BME280Address.Primary);

            var controller = I2cController.FromName(G120E.I2cBus.I2c0);

            var device = controller.GetDevice(settings);

            var driver = new BME280Driver(device);

            driver.Initialize();

            driver.ChangeSettings(
                BME280SensorMode.Forced,
                BME280OverSample.X1,
                BME280OverSample.X1,
                BME280OverSample.X1,
                BME280Filter.Off);

            while (true)
            {
                driver.Read();

                Debug.WriteLine("Pressure: " + driver.Pressure);
                Debug.WriteLine("Humidity: " + driver.Humidity);
                Debug.WriteLine("Temperature:" + driver.Temperature);

                Thread.Sleep(1000);
            }
        }
コード例 #3
0
        public static void Main()
        {
            Console.WriteLine("nanoFramework BME280 Sample!");

            Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
            Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);

            var settings = BME280Driver.GetI2CConnectionSettings(BME280Address.Secondary);

            var device = I2cDevice.FromId("I2C1", settings);

            var driver = new BME280Driver(device);

            driver.Initialize();

            driver.ChangeSettings(
                BME280SensorMode.Forced,
                BME280OverSample.X1,
                BME280OverSample.X1,
                BME280OverSample.X1,
                BME280Filter.Off);

            Console.WriteLine(" ---------------- ");

            while (true)
            {
                driver.Read();

                Console.WriteLine("Pressure: " + driver.Pressure.ToString("N2"));
                Console.WriteLine("Humidity: " + driver.Humidity.ToString("N2"));
                Console.WriteLine("Temperature:" + driver.Temperature.ToString("N2"));
                Console.WriteLine(" ---------------- ");

                Thread.Sleep(1000);
            }
        }