Skip to content

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

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/MKRENV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ int ENVClass::begin()

readHTS221Calibration();

// enable HTS221
i2cWrite(HTS221_ADDRESS, HTS221_CTRL1_REG, 0x80);
// turn on the HTS221 and enable Block Data Update
i2cWrite(HTS221_ADDRESS, HTS221_CTRL1_REG, 0x84);

// configure VEML6075 for 100 ms
i2cWriteWord(VEML6075_ADDRESS, VEML6075_UV_CONF_REG, 0x0010);
Expand All @@ -111,6 +111,9 @@ void ENVClass::end()

float ENVClass::readTemperature(int units)
{
// Wait for ONE_SHOT bit to be cleared by the hardware
while (i2cRead(HTS221_ADDRESS, HTS221_CTRL2_REG) & 0x01);

// trigger one shot
i2cWrite(HTS221_ADDRESS, HTS221_CTRL2_REG, 0x01);

Expand All @@ -131,6 +134,9 @@ float ENVClass::readTemperature(int units)

float ENVClass::readHumidity()
{
//Wait for ONE_SHOT bit to be cleared by the hardware
while (i2cRead(HTS221_ADDRESS, HTS221_CTRL2_REG) & 0x01);

// trigger one shot
i2cWrite(HTS221_ADDRESS, HTS221_CTRL2_REG, 0x01);

Expand Down