示例#1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="T:Meadow.TinyCLR.Sensors.Barometric.BME280" /> class.
        /// </summary>
        /// <param name="i2c">I2C Bus to use for communicating with the sensor</param>
        /// <param name="busAddress">I2C address of the sensor (default = 0x77).</param>
        public Bme280(string i2cBus, I2cAddress busAddress = I2cAddress.Adddress0x77)
        {
            var settings   = new I2cConnectionSettings((byte)busAddress, 100_000); //The slave's address and the bus speed.
            var controller = I2cController.FromName(i2cBus);
            var i2c        = controller.GetDevice(settings);

            _bme280 = new Bme280I2C(i2c, (byte)busAddress);
            Init();
        }
示例#2
0
        public Bme280(string spiBus, GpioPin chipSelect)
        {
            var settings = new SpiConnectionSettings()
            {
                ChipSelectType = SpiChipSelectType.Gpio,
                ChipSelectLine = chipSelect,
                Mode           = SpiMode.Mode1,
                ClockFrequency = 4_000_000,
            };

            var controller = SpiController.FromName(spiBus);
            var spi        = controller.GetDevice(settings);

            _bme280 = new Bme280Spi(spi, chipSelect);
            Init();
        }