-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: sensor: Add ROHM BH1750 driver #51268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: sensor: Add ROHM BH1750 driver #51268
Conversation
MaureenHelm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my first driver, and I wonder if you are interested in having it upstream.
Yes, thank you for the contribution!
The sensor has several working modes, and I have picked up the mode "one-time high resolution mode"; there are also five other modes that I can implement (including low resolution, continuous...). Do you want I implement all of them?
It's not required. If you want to add them, please do that in a follow up PR after this PR gets merged.
I have also a sample code, tell me if it needs to be part of the PR.
We are trying to reduce the number of driver-specific samples. If you're interested in helping create a generic light sensor sample similar to samples/sensor/accel_polling/ and samples/sensor/magn_polling/ and enabling the sample for this sensor, it would be a welcome addition.
The code is based on the Bosch BME280 source code.
If you've copied code from somewhere, please keep the original copyright and add your own copyright in a new line.
Please add this sensor tests/drivers/build_all/sensor to ensure the driver gets built in CI
984c7a2 to
f454dff
Compare
MaureenHelm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, thank you.
Please review and address the failed twister checks.
f454dff to
70da6e0
Compare
MaureenHelm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review and address the failed twister checks.
This still needs to be addressed
93a713b to
dd53f9f
Compare
drivers/sensor/bh1750/bh1750.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaureenHelm: as for 51269
You don't need floating point math for this
do you prefer the former solution with long long unsigned?
static int bh1750_channel_get(const struct device *dev,
enum sensor_channel chan,
struct sensor_value *val)
{
struct bh1750_data *data = dev->data;
long long unsigned tmp;
switch (chan) {
case SENSOR_CHAN_LIGHT:
tmp = 1000000UL * data->raw_val / 1.2;
val->val1 = tmp / 1000000;
val->val2 = tmp % 1000000;
break;
default:
return -EINVAL;
}
return 0;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaureenHelm do you want me to switch back to long long unsigned for that driver as well?
dd53f9f to
08799fb
Compare
757455f to
b1e2204
Compare
This adds support for ROHM BH1750 the i2c light sensor. Signed-off-by: Gaël PORTAY <[email protected]>
b1e2204 to
2f26479
Compare
|
@MaureenHelm ping? |
This change is now upstream[1]. [1]: zephyrproject-rtos/zephyr#51268
This driver is updated[1]. [1]: zephyrproject-rtos/zephyr#51268
Another driver is now upstream[1]. [1]: zephyrproject-rtos/zephyr#51268
|
I am closing the MR, since another driver for this hardware was merged in #43086. |
Dear Maintainers,
This is my first driver, and I wonder if you are interested in having it upstream.
The sensor has several working modes, and I have picked up the mode "one-time high resolution mode"; there are also five other modes that I can implement (including low resolution, continuous...). Do you want I implement all of them?
I have also a sample code, tell me if it needs to be part of the PR.
The code is based on the Bosch BME280 source code.
Kind Regards,
Gaël
This adds support for ROHM BH1750 the i2c light sensor.
Signed-off-by: Gaël PORTAY [email protected]