Skip to content

Conversation

clementlgl
Copy link
Contributor

This pull request adds support for the Omron 2SMPB-02E digital barometric pressure sensor, including the driver and a sample application.

Omron 2SMPB-02E sensor driver integration:

Device tree and vendor bindings:

  • Added device tree bindings for the Omron 2SMPB-02E sensor (omron,2smpb-02e.yaml) and registered the omron vendor prefix (vendor-prefixes.txt).

Sample application and documentation:

  • Added a sample application demonstrating temperature and pressure readings from the 2SMPB-02E sensor.

oki Oki Electric Industry Co., Ltd.
olimex OLIMEX Ltd.
olpc One Laptop Per Child
omron OMRON Corporation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nashif please help review vendor prefix

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd rather have this sensor work with a generic sensor sample than having one sample per sensor, as it wouldn't scale.

I suggest looking at other tph-related samples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've removed the sample.

@clementlgl clementlgl requested a review from decsny October 13, 2025 09:26
Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this sensor to tests/drivers/build_all/sensor

Comment on lines +17 to +43
#define COEFFICIENT_A1_A -6.3E-03
#define COEFFICIENT_A1_S 4.3E-04
#define COEFFICIENT_A2_A -1.9E-11
#define COEFFICIENT_A2_S 1.2E-10
#define COEFFICIENT_BT1_A 1.0E-01
#define COEFFICIENT_BT1_S 9.1E-02
#define COEFFICIENT_BT2_A 1.2E-08
#define COEFFICIENT_BT2_S 1.2E-06
#define COEFFICIENT_BP1_A 3.3E-02
#define COEFFICIENT_BP1_S 1.9E-02
#define COEFFICIENT_B11_A 2.1E-07
#define COEFFICIENT_B11_S 1.4E-07
#define COEFFICIENT_BP2_A -6.3E-10
#define COEFFICIENT_BP2_S 3.5E-10
#define COEFFICIENT_B12_A 2.9E-13
#define COEFFICIENT_B12_S 7.6E-13
#define COEFFICIENT_B21_A 2.1E-15
#define COEFFICIENT_B21_S 1.2E-14
#define COEFFICIENT_BP3_A 1.3E-16
#define COEFFICIENT_BP3_S 7.9E-17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment to document where these coefficients come from

Comment on lines 107 to 111
static int o2smpb_02e_attr_set(const struct device *dev, enum sensor_channel chan,
enum sensor_attribute attr, const struct sensor_value *val)
{
return 0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

Comment on lines 157 to 158
val->val1 = (int32_t)temp;
val->val2 = (int32_t)((temp - val->val1) * 1000000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sensor_value_from_float

Comment on lines 172 to 173
val->val1 = (int32_t)press;
val->val2 = (int32_t)((press - val->val1) * 1000000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sensor_value_from_float

};

#define O2SMPB_02E_INIT(n) \
static struct o2smpb_02e_config o2smpb_02e_config_##n = { \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this const

.i2c = I2C_DT_SPEC_INST_GET(n), \
}; \
static struct o2smpb_02e_data o2smpb_02e_data_##n; \
DEVICE_DT_INST_DEFINE(n, o2smpb_02e_init, NULL, &o2smpb_02e_data_##n, \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use SENSOR_DEVICE_DT_DEFINE

Comment on lines 10 to 19
#define O2SMPB_02_REG_TEMP_TXD0 0xFC
#define O2SMPB_02_REG_TEMP_TXD1 0xFB
#define O2SMPB_02_REG_TEMP_TXD2 0xFA
#define O2SMPB_02_REG_PRESS_TXD0 0xF9
#define O2SMPB_02_REG_PRESS_TXD1 0xF8
#define O2SMPB_02_REG_PRESS_TXD2 0xF7
#define O2SMPB_02_REG_RESET 0xE0
#define O2SMPB_02_REG_CTRL_MEAS 0xF4
#define O2SMPB_02_REG_CHIP_ID 0xD1
#define O2SMPB_02_REG_COE_b00_1 0xA0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really enough to justify having a separate private include. Move the defines to the .c file

compatible: "omron,2smpb-02e"

include: [sensor-device.yaml]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
include: [sensor-device.yaml]
include: [sensor-device.yaml, i2c-device.yaml]

clementlgl and others added 2 commits October 21, 2025 10:02
Support for the OMRON 2SMPB_02E digital barometric pressure sensor.

Signed-off-by: Clément Laigle <[email protected]>
Co-authored-by: Luis Ubieda <[email protected]>
Signed-off-by: Clément Laigle <[email protected]>
@sonarqubecloud
Copy link

@cfriedt cfriedt merged commit fc2e630 into zephyrproject-rtos:main Oct 21, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants