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
Renesas HS300x Sensor Support #63016
Renesas HS300x Sensor Support #63016
Conversation
8b4b168
to
98be9d2
Compare
drivers/sensor/hs300x/hs300x.c
Outdated
return -ENOTSUP; | ||
} | ||
|
||
rc = hs300x_start_measurement(dev); |
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.
Not sure it's worth a dedicated function?
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.
done
ebc8239
to
12a8b3b
Compare
I messed up when rebasing this branch with the main branch (very new to the Zephyr Git workflow) and can't seem to recover. I'm going to close this pull request, go away and learn/practice the work flow and then create a new PR that also addresses the comments made. The time you spent reviewing was not a waste, I'll be sure to incorporate the comments. |
git rebase origin/main --interactive and then just delete that commit that's not yours? |
Thanks for the suggestion, however I have compounded the problem while trying to fix it (new to using git rebase). Quicker if i just create a new branch and PR (once I have added the features requested in the comments). |
I see. FWIW you should also be able to do a hard reset to any of your previous commits, which SHAs still show up on this PR or which you could also find via |
12a8b3b
to
e9aa919
Compare
Thanks for the tip about |
drivers/sensor/hs300x/hs300x.c
Outdated
{ | ||
const struct hs300x_config *cfg = dev->config; | ||
|
||
if (!device_is_ready(cfg->bus.bus)) { |
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.
if (!device_is_ready(cfg->bus.bus)) { | |
if (!i2c_is_ready_dt(cfg->bus)) { |
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.
done
drivers/sensor/hs300x/hs300x.h
Outdated
struct hs300x_config { | ||
struct i2c_dt_spec bus; | ||
}; | ||
|
||
struct hs300x_data { | ||
int16_t t_sample; | ||
uint16_t rh_sample; | ||
}; |
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.
Not enough here to justify having a separate private include file. Please move into hs300x.c
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.
done
test_i2c_hs300x: hs300x@44 { | ||
compatible = "renesas,hs300x"; | ||
reg = <0x44>; | ||
}; |
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.
Address should be incremented by one from the last one. Note this is just a build test that will not execute on hardware so the address doesn't need to match the sensor datasheet
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.
thanks, hadn't realized the address should be incremented.
samples/sensor/hs300x/README.rst
Outdated
@@ -0,0 +1,65 @@ | |||
.. _hs300x_sample: | |||
|
|||
HS300X Sample |
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.
We want to stop introducing new driver-specific sensor samples, and instead use more generic ones for each sensor type. See samples/sensor/accel_polling
and samples/sensor/magn_polling
for example
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.
makes sense. do you want me to create a generic sample for temperature and humidity sensors, based on one of these samples? something like samples/sensor/temp_hum_polling
perhaps?
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.
That would be great, thank you
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.
Maybe simply repurpose/rename the dht
sample?
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.
ok, I will look at creating a generic temperature/humidity sample based on the existing dht
sample.
e9aa919
to
8e4f72a
Compare
25f1fc3
to
5634408
Compare
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.
Needs a rebase
samples/sensor/hs300x/README.rst
Outdated
@@ -0,0 +1,65 @@ | |||
.. _hs300x_sample: | |||
|
|||
HS300X Sample |
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.
That would be great, thank you
5634408
to
9029c32
Compare
9029c32
to
2b310a7
Compare
@kartben please revisit |
break; | ||
} | ||
|
||
printk("%16s: temp is %d.%d oC humidity is %d.%d %%RH\n", dev->name, |
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.
printk("%16s: temp is %d.%d oC humidity is %d.%d %%RH\n", dev->name, | |
printk("%16s: temp is %d.%d °C humidity is %d.%d %%RH\n", dev->name, |
Also, maybe the format should be %d.%02d
, having so many digits feels odd.
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.
I changed oC
to °C
, however when I tried the %d.%02d
modification I found it did not do what I thought it would... After some reading it seems that (unless I have missed something) the width format specifier defines the minimum number of characters to be printed but it does not truncate the value if it is larger. Therefore there was no change in the output (in most cases) and so I left formatting as it was...
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.
Ah! of course... my bad. So also need to divide val2 by 10000, right?
printk("T: %d.%02d\n", temp.val1, temp.val2 / 10000); |
hs300x@44: temp is 25.31129 oC humidity is 30.391259 %RH | ||
hs300x@44: temp is 25.51272 oC humidity is 30.446194 %RH | ||
hs300x@44: temp is 25.51272 oC humidity is 30.372947 %RH | ||
hs300x@44: temp is 25.51272 oC humidity is 30.391259 %RH | ||
hs300x@44: temp is 25.31129 oC humidity is 30.372947 %RH | ||
hs300x@44: temp is 25.31129 oC humidity is 30.354635 %RH | ||
hs300x@44: temp is 25.51272 oC humidity is 30.372947 %RH | ||
hs300x@44: temp is 25.51272 oC humidity is 30.372947 %RH | ||
hs300x@44: temp is 25.51272 oC humidity is 30.391259 %RH | ||
hs300x@44: temp is 25.51272 oC humidity is 30.446194 %RH | ||
hs300x@44: temp is 25.51272 oC humidity is 30.531648 %RH |
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.
update to use "°" and possibly the newer format as per my other 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.
done, but see comment above.
harness_config: | ||
type: one_line | ||
regex: | ||
- "[0-9A-Za-z_,+-.]*@[0-9A-Fa-f]*: temp is (.*) oC humidity is (.*) %RH" |
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.
ditto
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.
done
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.
Sorry for the delay! The new generic sample is great, thanks for this!
A few remaining comments that are hopefully not too nitpicky :)
4e99762
to
8ee123d
Compare
bae5576
to
91cabaa
Compare
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.
Thanks! My latest comment is not asking you for yet another update, to be clear :)
@MaureenHelm we should probably now just remove the existing /dht
sample, right?
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.
we should probably now just remove the existing /dht sample, right?
Yes, but it would be nice to port boards/nrf52dk_nrf52832.overlay
in the process
Ya although tbh I am not a big fan of overlay files that imply manual wiring and breadboarding, especially if the README does not really provide guidance for beginners re: wiring for beginners (as this is virtually the only audience for which such overlay could really be useful IMO). OTH the overlay still kind of make sense in this particular example of the DHT22/11, I guess, as it showcases the use of the In any case, the deletion of the legacy dht sample is for another PR to address which I'll likely look into at some point :) |
@iandmorris please rebase to solve the conflict. |
Adds support for Renesas HS3001 and HS3003 temperature/humidity sensors connected via an I2C bus. Signed-off-by: Ian Morris <ian.d.morris@outlook.com>
This simple application periodically prints the temperature and humidity measured by one or more digital humidity/temperature sensors. Signed-off-by: Ian Morris <ian.d.morris@outlook.com>
91cabaa
to
ce99f40
Compare
Added driver and sample application for the Renesas HS3001 and HS3003 temperature/humidity sensors.
Tested using a Nucleo-F401RE, Click shield for Nucleo-64 and Temp&Hum Click 18 (HS3003) and Temp& Hum Click 17 (HS3001). The only difference between the HS3001 and HS3003 is the accuracy of the relative humidity measurements.