pi_weather.core.sensors.bmp390.handler module¶
Logic to handle and remotely-manage the BMP390 sensor
- class pi_weather.core.sensors.bmp390.handler.BMP3XX[source]¶
Bases:
objectBMP3XX base class
- begin()[source]¶
Function to initialize the sensor
- Returns:
Initialization status (boolean := True indicates initialization succeed, False otherwise)
- Return type:
- property get_pressure: float | int¶
Function to get pressure measurement value from register (working range := (300‒1250 hPa))
If the reference value is provided before, the absolute value of the current position pressure is calculated according to the calibrated sea level atmospheric pressure
- property get_temperature: float | int¶
Function to get pressure measurement value from register (working range := (-40 ‒ +85 °C))
- calibrated_absolute_difference(altitude)[source]¶
Function which takes the given current location altitude as the reference value to eliminate the absolute difference for subsequent pressure and altitude data
- property get_altitude: float¶
Function to calculate and return the altitude based on the atmospheric pressure measured by the sensor
If the reference value is provided before, the absolute value of the current position pressure is calculated according to the calibrated sea level atmospheric pressure
(see formula: https://www.weather.gov/media/epz/wxcalc/pressureAltitude.pdf)
- Returns:
Altitude (unit: m)
- Return type:
- set_power_mode(mode)[source]¶
Function to configure the measurement mode and power mode
- SLEEP_MODE (Sleep mode): It will be in sleep mode by default after power-on reset. In this mode,no
measurement is performed and power consumption is minimal. All registers are accessible for reading the chip ID and compensation coefficient.
- FORCED_MODE (Forced mode): In this mode, the sensor will take a single measurement according to the selected
measurement and filtering options. After the measurement is completed, the sensor will return to sleep mode, and the measurement result can be obtained in the register.
- NORMAL_MODE (Normal mode): Continuously loop between the measurement period and the standby period.
The output data rates are related to the ODR mode setting.
- set_oversampling(press_osr_set, temp_osr_set)[source]¶
Function to set up the oversampling config for pressure + temperature measurements OSR stands for over-sampling register
- There are 6 pressure oversampling modes:
BMP3XX_PRESS_OSR_SETTINGS[0], Pressure sampling×1, 16 bit / 2.64 Pa (Recommend temperature oversampling×1)
BMP3XX_PRESS_OSR_SETTINGS[1], Pressure sampling×2, 16 bit / 2.64 Pa (Recommend temperature oversampling×1)
BMP3XX_PRESS_OSR_SETTINGS[2], Pressure sampling×4, 18 bit / 0.66 Pa (Recommend temperature oversampling×1)
BMP3XX_PRESS_OSR_SETTINGS[3], Pressure sampling×8, 19 bit / 0.33 Pa (Recommend temperature oversampling×2)
BMP3XX_PRESS_OSR_SETTINGS[4], Pressure sampling×16, 20 bit / 0.17 Pa (Recommend temperature oversampling×2)
BMP3XX_PRESS_OSR_SETTINGS[5], Pressure sampling×32, 21 bit / 0.085 Pa (Recommend temperature oversampling×2)
- There are 6 temperature oversampling modes:
BMP3XX_TEMP_OSR_SETTINGS[0], Temperature sampling×1, 16 bit / 0.0050 °C
BMP3XX_TEMP_OSR_SETTINGS[1], Temperature sampling×2, 16 bit / 0.0025 °C
BMP3XX_TEMP_OSR_SETTINGS[2], Temperature sampling×4, 18 bit / 0.0012 °C
BMP3XX_TEMP_OSR_SETTINGS[3], Temperature sampling×8, 19 bit / 0.0006 °C
BMP3XX_TEMP_OSR_SETTINGS[4], Temperature sampling×16, 20 bit / 0.0003 °C
BMP3XX_TEMP_OSR_SETTINGS[5], Temperature sampling×32, 21 bit / 0.00015 °C
- filter_coefficient(iir_config_coef)[source]¶
Function to set IIR filter coefficient (IIR filtering)
Infinite impulse response (IIR)
The environmental pressure is subject to many short-term changes, caused e.g. by slamming of a door or window, or wind wing into the sensor. To suppress these disturbances in the output data without causing additional interface traffic and processor work load, the BMP390 features an internal IIR filter. It effectively reduces the bandwidth of the output signals.
Docs: https://en.wikipedia.org/wiki/Infinite_impulse_response
- Configurable mode:
BMP3XX_IIR_CONFIG_COEF_0, BMP3XX_IIR_CONFIG_COEF_1, BMP3XX_IIR_CONFIG_COEF_3, BMP3XX_IIR_CONFIG_COEF_7, BMP3XX_IIR_CONFIG_COEF_15, BMP3XX_IIR_CONFIG_COEF_31, BMP3XX_IIR_CONFIG_COEF_63, BMP3XX_IIR_CONFIG_COEF_127
- set_output_data_rates(odr_set)[source]¶
Function to set output data rate
- Here are the available modes:
BMP3XX_ODR_200_HZ, BMP3XX_ODR_100_HZ, BMP3XX_ODR_50_HZ, BMP3XX_ODR_25_HZ, BMP3XX_ODR_12P5_HZ, BMP3XX_ODR_6P25_HZ, BMP3XX_ODR_3P1_HZ, BMP3XX_ODR_1P5_HZ, BMP3XX_ODR_0P78_HZ, BMP3XX_ODR_0P39_HZ, BMP3XX_ODR_0P2_HZ, BMP3XX_ODR_0P1_HZ, BMP3XX_ODR_0P05_HZ, BMP3XX_ODR_0P02_HZ, BMP3XX_ODR_0P01_HZ, BMP3XX_ODR_0P006_HZ, BMP3XX_ODR_0P003_HZ, BMP3XX_ODR_0P0015_HZ
- set_common_sampling_mode(mode)[source]¶
Function to set the sampling mode to the sensor
- There are 6 commonly used sampling modes:
ULTRA_LOW_PRECISION: Ultra-low precision, suitable for monitoring weather (lowest power consumption), the power is mandatory mode.
LOW_PRECISION: Low precision, suitable for random detection, power is normal mode
NORMAL_PRECISION1: Normal precision 1, suitable for dynamic detection on handheld devices (e.g. on mobile phones), power is normal mode
NORMAL_PRECISION2: Normal precision 2, suitable for drones, power is normal mode
HIGH_PRECISION: High precision, suitable for low-power handled devices (e.g. mobile phones), power is normal mode
ULTRA_PRECISION: Ultra-high precision, suitable for indoor navigation, its acquisition rate will be extremely low, and the acquisition cycle is 1000 ms.
- enable_data_ready_interrupt()[source]¶
Function to enable the interrupt for the signal triggered when data is ready :return: Nothing
- Return type:
- enable_fifo_wtm_interrupt(wtm_value)[source]¶
Function to enable the interrupt for the water level signal
- enable_fifo_full_interrupt()[source]¶
Function to enable the interrupt of the signal that the sensor FIFO is full
As the interrupt pin is unique, the three interrupts are set to be used separately, please note the other two interrupt functions when using
- Returns:
Nothing
- Return type:
- _get_coefficients()[source]¶
Function to get the calibration data in the NVM register of the sensor
- Returns:
Nothing
- Return type:
- _compensate_data(adc_p, adc_t)[source]¶
Function to compensate the original values (pressure + temperature) from the measured data (directly from registers). It uses the calibration data (from registers data) retrieved at base class init.
# Docs on computation over calib. data := Datasheet, p28, Trimming Coefficient listing in register map with size and sign attributes
- _get_reg_temp_press_data()[source]¶
Function to get and return raw measurement data from the registers (uncompensated and calibrated pressure + temperature)
- _get_sensor_time()[source]¶
Function to get and return sensor time from registers
- Returns:
Sensor time data
- Return type:
- get_fifo_temp_press_data()[source]¶
Function to get and return cached data from the FIFO (pressure + temperature)
- get_fifo_length()[source]¶
Function to return the FIFO cached data size (range of return value is := (0-511))
- Returns:
FIFO cached data size
- Return type:
- empty_fifo()[source]¶
Function to clear cached data in the FIFO without changing its settings
- Returns:
Nothing
- Return type:
- reset()[source]¶
Function to reset and restart the sensor, then restoring the sensor configuration to the default configuration
- Returns:
Nothing
- Return type:
- class pi_weather.core.sensors.bmp390.handler.BMP3XXI2C(i2c_addr=119, bus=1)[source]¶
Bases:
BMP3XXBMP3XXI2C class Use the I2C protocol to drive the pressure sensor