@@ -179,25 +179,25 @@ class SHT2xSensor : public SHTI2cSensor
179
179
bool readSample () override
180
180
{
181
181
uint8_t data[EXPECTED_DATA_SIZE];
182
- uint8_t cmd[mCmd_Size * 2 ];
182
+ uint8_t cmd[mCmd_Size ];
183
183
184
184
// SHT2x sends T and RH in two separate commands (different to other sensors)
185
185
// so we have to spit the command into two bytes and
186
186
// have to read from I2C two times with EXPECTED_DATA_SIZE / 2
187
187
188
+ // read T from SHT2x Sensor
188
189
// Upper byte is T for SHT2x Sensors
189
190
cmd[0 ] = mI2cCommand >> 8 ;
190
- // Lower byte is RH for SHT2x Sensors
191
- cmd[1 ] = mI2cCommand & 0xff ;
192
-
193
- // read T from SHT2x Sensor
194
191
if (!readFromI2c (mWire , mI2cAddress , cmd, mCmd_Size , data,
195
192
EXPECTED_DATA_SIZE / 2 , mDuration )) {
196
193
DEBUG_SHT (" SHT2x readFromI2c(T) false\n " );
197
194
return false ;
198
195
}
196
+
199
197
// read RH from SHT2x Sensor
200
- if (!readFromI2c (mWire , mI2cAddress , &cmd[1 ], mCmd_Size , &data[3 ],
198
+ // Lower byte is RH for SHT2x Sensors
199
+ cmd[0 ] = mI2cCommand & 0xff ;
200
+ if (!readFromI2c (mWire , mI2cAddress , cmd, mCmd_Size , &data[3 ],
201
201
EXPECTED_DATA_SIZE / 2 , mDuration )) {
202
202
DEBUG_SHT (" SHT2x readFromI2c(RH) false\n " );
203
203
return false ;
0 commit comments