-
Notifications
You must be signed in to change notification settings - Fork 9
fix hang due to powerdown of hts221 sensor #6
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
Conversation
UPDATE: seems that also calling two times the read like: float celsius = ENV.readTemperature();
celsius = ENV.readTemperature(); rise the issue, then maybe is better move the delay on the read instead of the end. |
1118ae6
to
acfa7ae
Compare
fix the hang issue due to consecutive reads of the temperature register porting of arduino-libraries/Arduino_MKRENV#6
fix the hang issue due to consecutive reads of the temperature register porting of arduino-libraries/Arduino_MKRENV#6
After some testing, I don't think this is the best solution, I found better results by added the following to the start of
This is based on the data sheet, section 7.4:
What do you think? I think we should also consider to set the |
yes as discussed i think that the problem of the sensor is that we make operation while the sensor is involved in conversion operation, this should work, let me test, about the BDU yes i think too we need because:
|
Ok works !! i'll add also the BDU |
fix the hang issue due to consecutive reads of the temperature register porting of arduino-libraries/Arduino_MKRENV#6
src/MKRENV.cpp
Outdated
@@ -141,8 +147,8 @@ float ENVClass::readHumidity() | |||
|
|||
// read value and convert | |||
int16_t hout = i2cRead16(HTS221_ADDRESS, HTS221_HUMIDITY_OUT_L_REG); | |||
|
|||
return (hout * _hts221HumiditySlope + _hts221HumidityZero); | |||
float reading = hout * _hts221HumiditySlope + _hts221HumidityZero; |
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 think this change is unnecessary for the fix.
src/MKRENV.cpp
Outdated
@@ -87,7 +87,7 @@ int ENVClass::begin() | |||
readHTS221Calibration(); | |||
|
|||
// enable HTS221 |
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 think we should update the comment as well?
src/MKRENV.cpp
Outdated
@@ -111,6 +111,9 @@ void ENVClass::end() | |||
|
|||
float ENVClass::readTemperature(int units) | |||
{ | |||
// Wait for trigger a new read operation |
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 are waiting here for hardware, to reset the bit to set to zero as stated in datasheet comment.
4a11f83
to
2d2bba9
Compare
fix the hangs due to consecutive HTS221 readings
fix the hang issue due to consecutive reads of the temperature register porting of arduino-libraries/Arduino_MKRENV#6
fix the hang issue due to consecutive reads of the temperature register porting of arduino-libraries/Arduino_MKRENV#6
fix the hang issue due to consecutive reads of the temperature register porting of arduino-libraries/Arduino_MKRENV#6
Introducing a delay before the power off of the hts in the end function the seems that allow to fix the issue due a power cycle of the module in loop.
this change seems that allow to power down the sensor without generate the issue
the test sketch is:
with @facchinm have also check that the delay could be reduce to 50, we have choose 80 to give a higher tollerance.
cc/ @sandeepmistry @facchinm please make test, i have tested on wifi1010 + MKRENV shield
i'll try to take a look to the datasheet to check the register and sensor operation to see if compliant whit this change.
This change should be also ported on https://github.com/arduino-libraries/Arduino_HTS221/tree/master/src