Skip to content

Commit bcae2b6

Browse files
vcolellawinkj
authored andcommitted
Implement comments from #37
1 parent 8c77fea commit bcae2b6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

SHTSensor.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,25 +179,25 @@ class SHT2xSensor : public SHTI2cSensor
179179
bool readSample() override
180180
{
181181
uint8_t data[EXPECTED_DATA_SIZE];
182-
uint8_t cmd[mCmd_Size * 2];
182+
uint8_t cmd[mCmd_Size];
183183

184184
// SHT2x sends T and RH in two separate commands (different to other sensors)
185185
// so we have to spit the command into two bytes and
186186
// have to read from I2C two times with EXPECTED_DATA_SIZE / 2
187187

188+
// read T from SHT2x Sensor
188189
// Upper byte is T for SHT2x Sensors
189190
cmd[0] = mI2cCommand >> 8;
190-
// Lower byte is RH for SHT2x Sensors
191-
cmd[1] = mI2cCommand & 0xff;
192-
193-
// read T from SHT2x Sensor
194191
if (!readFromI2c(mWire, mI2cAddress, cmd, mCmd_Size, data,
195192
EXPECTED_DATA_SIZE / 2, mDuration)) {
196193
DEBUG_SHT("SHT2x readFromI2c(T) false\n");
197194
return false;
198195
}
196+
199197
// 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],
201201
EXPECTED_DATA_SIZE / 2, mDuration)) {
202202
DEBUG_SHT("SHT2x readFromI2c(RH) false\n");
203203
return false;

0 commit comments

Comments
 (0)