File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ int HTS221Class::begin()
57
57
readHTS221Calibration ();
58
58
59
59
// enable HTS221
60
- i2cWrite (HTS221_CTRL1_REG, 0x80 );
60
+ i2cWrite (HTS221_CTRL1_REG, 0x84 );
61
61
62
62
return 1 ;
63
63
}
@@ -72,6 +72,9 @@ void HTS221Class::end()
72
72
73
73
float HTS221Class::readTemperature (int units)
74
74
{
75
+ // Wait for trigger a new read operation
76
+ while (HTS221_CTRL2_REG) & 0x01 );
77
+
75
78
// trigger one shot
76
79
i2cWrite (HTS221_CTRL2_REG, 0x01 );
77
80
@@ -92,6 +95,9 @@ float HTS221Class::readTemperature(int units)
92
95
93
96
float HTS221Class::readHumidity ()
94
97
{
98
+ // Wait for trigger a new read operation
99
+ while (HTS221_CTRL2_REG) & 0x01 );
100
+
95
101
// trigger one shot
96
102
i2cWrite (HTS221_CTRL2_REG, 0x01 );
97
103
@@ -102,8 +108,8 @@ float HTS221Class::readHumidity()
102
108
103
109
// read value and convert
104
110
int16_t hout = i2cRead16 (HTS221_HUMIDITY_OUT_L_REG);
105
-
106
- return (hout * _hts221HumiditySlope + _hts221HumidityZero) ;
111
+ float reading = hout * _hts221HumiditySlope + _hts221HumidityZero;
112
+ return reading ;
107
113
}
108
114
109
115
int HTS221Class::i2cRead (uint8_t reg)
You can’t perform that action at this time.
0 commit comments