Skip to content

IRNAS/irnas-bmv080-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IRNAS BMV080 driver zephyr

This driver is used for BOSCH's BMV080 sensor. This driver is intended for use with Zephyr.

Important

The driver uses BOSCH's SKD for BMV080, but does not provide the library by itself due to licensing restrictions. The users need to acquire it on their own behalf. More information regarding SDK acquisition can be found here.

Instalation

To use this driver add the below snippet to you west.yml file:

- name: irnas-bmv080-driver
  repo-path: irnas-bmv080-driver
  path: irnas/irnas-bmv080-driver
  remote: irnas
  revision: v1.0.0

After adding the above snippet to your west.yml file, run east update in your terminal.

DTS

A node needs to be added to your device-tree file aswell:

If you will be using the I²C(0) connection

&i2c0{
    bmv080: bmv080@54 {
        compatible = "irnas,bmv080";
        label = "bmv080";
        reg = <0x54>;
        status = "okay";
    };
};

If you will be using the SPI(0) connection

&spi0{
    bmv080: bmv080@54 {
        compatible = "irnas,bmv080";
        label = "bmv080";
        reg = <0x54>;
        status = "okay";
    };
};

Warning

SPI communication support has been implemented but not tested. Use at your own risk.

Usage

The driver will initialize at boot and can be accessed via:

const struct device *bmv080_sensor = DEVICE_DT_GET(DT_NODELABEL(bmv080));

The driver exposes internal structure types and function calls to users for users to use freely. From here there are two options for controlling the driver:

Control via Zephyr Sensor API

User can configure and control parts of the sensor with:

  • sensor_attr_set():

    • SENSOR_ATTR_BMV080_INTEGRATION_TIME,

      Set integration time.
      
    • SENSOR_ATTR_BMV080_DUTY_CYCLING_PERIOD,

      Set duty cycling period.
      
    • SENSOR_ATTR_BMV080_DO_OBSTRUCTION_DETECTION,

      Enable/disable obstruction detection.
      
    • SENSOR_ATTR_BMV080_DO_VIBRATION_FILTERING,

      Enable/disable vibration detection.
      
    • SENSOR_ATTR_BMV080_MEASUREMENT_ALGORITHM,

      Set measurement algorithm.
      
  • sensor_attr_get():

    • SENSOR_ATTR_BMV080_ID,

      Get sensor id.
      
    • SENSOR_ATTR_BMV080_INTEGRATION_TIME,

      Get integration time.
      
    • SENSOR_ATTR_BMV080_DUTY_CYCLING_PERIOD,

      Get duty cycling period.
      
    • SENSOR_ATTR_BMV080_DO_OBSTRUCTION_DETECTION,

      Enable/disable obstruction detection.
      
    • SENSOR_ATTR_BMV080_DO_VIBRATION_FILTERING,

      Enable/disable vibration detection.
      
    • SENSOR_ATTR_BMV080_MEASUREMENT_ALGORITHM,

      Get measurement algorithm.
      
  • sensor_sample_fetch()

Fetch sample data from sensor and store it inside data structure.
  • sensor_channel_get():

    Get data from last sensor_sample_fetch()
    
    • SENSOR_CHAN_BMV080_RUNTIME,

      Get the runtime duration at last sample fetch call.
      
    • SENSOR_CHAN_BMV080_PM_1_0_NUMBER,

      Get the number of particles of size PM 1 per cm³ at last sample fetch call.
      
    • SENSOR_CHAN_BMV080_PM_2_5_NUMBER,

      Get the number of particles of size PM 2.5 per cm³ at last sample fetch call.
      
    • SENSOR_CHAN_BMV080_PM_10_NUMBER,

      Get the number of particles of size PM 10 per cm³ at last sample fetch call.
      
    • SENSOR_CHAN_BMV080_PM_1_0_MASS,

      Get the mass of particles of size PM 1 (µg/cm³)
      
    • SENSOR_CHAN_BMV080_PM_2_5_MASS,

      Get the mass of particles of size PM 2.5 (µg/cm³)
      
    • SENSOR_CHAN_BMV080_PM_10_MASS,

      Get the mass of particles of size PM 10 (µg/cm³)
      
    • SENSOR_CHAN_BMV080_OBSTRUCTION,

      Get obstruction detection data.
      
    • SENSOR_CHAN_BMV080_IS_OUTSIDE_MEASUREMENT_RANGE,

      Get data if values are outside of measurement range. (Read more about measurement ranges in the sensors data sheet)
      
    • SENSOR_CHAN_BMV080_EXTENDED_INFO,

      Get extended sensor info. (Read more about extended sensor info in the sensors data sheet)
      
  • direct function calls are described in bmv080_irnas.h.

Direct control via BOSCH's SDK functions

To use BOSCH's SDK the user first needs to get the bmv080_dev pointer from the driver. That can be done using the bmv080_irnas.h exposed function:

Note

The driver will initialize and call bmv080_open() on boot by itself if the node is correctly added to the device dts files.

/**
 * @brief Get the BMV080 sensor handle.
 *
 * NOTE: This function can only be called after a successful call of bmv080_open(), otherwise a NULL
 * pointer is returned.
 *
 * @param dev Pointer to the device structure.
 * @return BMV080 sensor handle if successful, NULL otherwise.
 */
bmv080_handle_t irnasBMV080_get_handle(const struct device *dev);

About

IRNAS implementation of the bme080 sensor driver ported for Zephyr.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors