Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Ambient2Click"/> class.
        /// </summary>
        /// <param name="socket">The socket on which the Ambient2Click module is plugged on MikroBus.Net board</param>
        /// <param name="slaveAddress">The address of the module.</param>
        public Ambient2Click(Hardware.Socket socket, I2CAddresses slaveAddress)
        {
            _socket = socket;
            _sensor = I2cController.FromName(socket.I2cBus).GetDevice(new I2cConnectionSettings((Int32)slaveAddress, 100000));

            if (GetDeviceId() != 0x3001)
            {
                throw new DeviceInitialisationException("Ambient2 Click not found on the I2C Bus.");
            }

            WriteRegister(ConfigurationRegister, new Byte[] { 0xC8, 0x10 }); // Reset to Factory Default.
        }
Exemple #2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BME280" /> class.
        /// </summary>
        /// <param name="socket">The socket on which the WeatherClick module is plugged on MikroBus.Net board</param>
        /// <param name="slaveAddress">The address of the module.</param>
        public BME280(Hardware.Socket socket, I2CAddresses slaveAddress)
        {
            _sensor = I2cController.FromName(socket.I2cBus).GetDevice(new I2cConnectionSettings((Int32)slaveAddress, 100000));

            Reset(ResetModes.Soft);

            if (DeviceId != 0x60)
            {
                throw new DeviceInitialisationException();
            }

            SetRecommendedMode(RecommendedModes.WeatherMonitoring);  // Minimal consumption at startup (other than PowerModes.Off, of course)

            ReadCalibrationData();
        }
Exemple #3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BME280" /> class.
        /// </summary>
        /// <param name="socket">The socket on which the WeatherClick module is plugged on MikroBus.Net board</param>
        /// <param name="slaveAddress">The address of the module.</param>
        public BME280(int i2cBus, I2CAddresses slaveAddress)
        {
            //_socket = socket;
#if (NANOFRAMEWORK_1_0)
            _sensor = I2cDevice.Create(new I2cConnectionSettings(i2cBus, (int)slaveAddress, I2cBusSpeed.StandardMode));
#else
            _sensor = I2cController.FromName(socket.I2cBus).GetDevice(new I2cConnectionSettings((Int32)slaveAddress, 100000));
#endif

            Reset(ResetModes.Soft);

            if (DeviceId != 0x60)
            {
                throw new DeviceInitialisationException();
            }

            SetRecommendedMode(RecommendedModes.WeatherMonitoring);  // Minimal consumption at startup (other than PowerModes.Off, of course)

            ReadCalibrationData();
        }