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: htu21d relative humidity and temperature sensor driver #10110
base: master
Are you sure you want to change the base?
Conversation
@gschorcht: I could review this PR, but I don't have the hardware to test it. Should I still review? To me the advantage of not using clock stretching to allow using multiple I2C device on the same bus is obvious. Is there any technical argument to not use this approach in the
Note: I did not look yet into either this code or the |
I'm in the middle of a moving, so I won't be able to test this soon. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
PR is waiting for review. |
Needs rebase |
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'm not convinced by the proposed API.
I don't see a real benefit from the user point of view in having a couple functions htu21d_measure_tmp/htu21d_fetch_tmp over a single function htu21d_read_temperature
. It would make the API more natural, compared to other sensors. Then USE_HTU21D_BLOCKING
could also be removed.
In a way, htu21d_read could be split into 2 functions htu21d_read_temperature
and htu21d_read_humidity
.
Otherwise, the driver implementation looks good. Maybe you could also add a README.md file with the test application.
MODULE = htu21d | ||
|
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.
MODULE = htu21d |
} \ | ||
} | ||
|
||
/** Forward declaration of functions for internal use */ |
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.
/** Forward declaration of functions for internal use */ | |
/* Forward declaration of functions for internal use */ |
@@ -175,6 +175,10 @@ ifneq (,$(filter hts221,$(USEMODULE))) | |||
FEATURES_REQUIRED += periph_i2c | |||
endif | |||
|
|||
ifneq (,$(filter htu21d,$(USEMODULE))) | |||
FEATURES_REQUIRED += periph_i2c |
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.
FEATURES_REQUIRED += periph_i2c | |
FEATURES_REQUIRED += periph_i2c | |
USEMODULE += xtimer |
Because there's a strong dependency on xtimer in the driver implementation.
return HTU21D_OK; | ||
} | ||
|
||
static const uint8_t _times_tmp[] = { 85, 22, 43, 11 }; |
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.
Could we have some defines for this constants ?
return HTU21D_OK; | ||
} | ||
|
||
/** Functions for internal use only */ |
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.
/** Functions for internal use only */ | |
/* Functions for internal use only */ |
Could this replace the This would also be greatly beneficial in case someone (for whatever reason) connects a bunch of temperature+humidity sensors of the various flavors, as with the single driver only ROM space for one implementation would be needed. |
Please rebase. There are also some pending review comments. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Contribution description
This PR adds a driver for the TE Connectivity HTU21D humidity and temperature sensor. The driver could also be used with Sensirion SHT21 and with SI7021.
The sensor only supports single measurements and polling. This driver provides also
drivers/saul
capabilities.Please note:
Even though the HTU21D driver also works with SI7021 sensor for which
drivers/si70xx
already exists, there are the following differences:drivers/si70xx
checks some registers during intialization that do no exist in HTU21D sensor (heater control register and revision registers).drivers/si70xx
uses clock stretching which blocks the bus and the master during the measurement which can take up to 85 ms.drivers/htu21d
does not use clock stretching to avoid this blocking.drivers/si70xx
does not implement the CRC check whiledrivers/htu21d
implement and use it.As an alternative, I could provide a PR that
drivers/si70xx
so that it would also work also with HTU21D,drivers/include/htu21d.h
anddrivers/htu21d/include/htu21d_params.h
which just redefine symbols with prefixhtu21d_
, andtests/driver_htu21d
as test application.I have it already realized also in that way and could provide it. The same could be done for SHT21.
But please keep in mind that a pseudo/wrapper module would use
drivers/si70xx
which blocks the bus and the master while waiting for measurement results.Testing procedure
USEMODULE=htu21d make flash -C tests/saul BOARD=...