Class BME280

    • Constructor Detail

      • BME280

        public BME280()
               throws RuntimeIOException
        Creates an instance that uses I2C. Assumes I2C bus 1 and the default I2C address (0x76); all other I2C instantiation parameters are set to the default.
        Throws:
        RuntimeIOException - if instance cannot be created
      • BME280

        public BME280​(int bus,
                      int address)
               throws RuntimeIOException
        Creates an instance that uses I2C. The caller must provide the I2C bus number and the I2C address; all other I2C instantiation parameters are set to the default.
        Parameters:
        bus - I2C bus number
        address - device address
        Throws:
        RuntimeIOException - if instance cannot be created
      • BME280

        public BME280​(int chipSelect)
               throws RuntimeIOException
        Creates an instance that uses SPI. The caller must provide the chip select line; all other SPI instantiation parameters are set to the default.
        Parameters:
        chipSelect - the chip select line used
        Throws:
        RuntimeIOException - if instance cannot be created
      • BME280

        public BME280​(int controller,
                      int chipSelect,
                      int frequency,
                      SpiClockMode mode)
               throws RuntimeIOException
        Creates an instance that uses SPI. The caller must provide all SPI instantiation parameters.
        Parameters:
        controller - the SPI controller used
        chipSelect - the chip select line used
        frequency - the frequency used
        mode - the clock mode used
        Throws:
        RuntimeIOException - if an error occurs
    • Method Detail

      • setStandbyAndFilterModes

        public void setStandbyAndFilterModes​(BME280.StandbyDuration standbyDuration,
                                             BME280.FilterCoefficient filterCoefficient)
        Sets the standby duration for normal mode and the IIR filter coefficient.
        Parameters:
        standbyDuration - standby duration
        filterCoefficient - IIR filter coefficient
      • waitDataAvailable

        public boolean waitDataAvailable​(int interval,
                                         int maxIntervals)
        Waits for data to become available.
        Parameters:
        interval - sleep interval
        maxIntervals - maximum number of intervals to wait
        Returns:
        true if data available, false if not
      • isDataAvailable

        public boolean isDataAvailable()
        Indicates if data is available.
        Returns:
        rue if data available, false if not
      • getValues

        public float[] getValues()
        Reads the temperature, pressure, and humidity registers; compensates the raw values to provide meaningful results.
        Returns:
        array in order of: temperature, pressure, humidity
      • getTemperature

        public float getTemperature()
        Reads the temperature, pressure, and humidity registers; compensates the raw values to provide meaningful results.
        Specified by:
        getTemperature in interface ThermometerInterface
        Returns:
        temperature
      • getPressure

        public float getPressure()
        Reads the temperature, pressure, and humidity registers; compensates the raw values to provide meaningful results.
        Specified by:
        getPressure in interface BarometerInterface
        Returns:
        pressure in hectoPascals (hPa)
      • getRelativeHumidity

        public float getRelativeHumidity()
        Reads the temperature, pressure, and humidity registers; compensates the raw values to provide meaningful results.
        Specified by:
        getRelativeHumidity in interface HygrometerInterface
        Returns:
        humidity
      • reset

        public void reset()
        Resets the device.