- Sat Oct 10, 2015 4:14 pm
#31053
in general it won't be necessary to implement the status polling.
if you look at the sparkfun lib for example, you see that after issuing the "read humidity" command they explicitly wait the max. conversion time given in the datasheet before they try to read the result from the sensor.
Code: Select all//Request a humidity reading
Wire.beginTransmission(HTDU21D_ADDRESS);
Wire.write(TRIGGER_HUMD_MEASURE_NOHOLD); //Measure humidity with no bus holding
Wire.endTransmission();
//Hang out while measurement is taken. 50mS max, page 4 of datasheet.
delay(55);
//Comes back in three bytes, data(MSB) / data(LSB) / Checksum
Wire.requestFrom(HTDU21D_ADDRESS, 3);
this is good practice unless you have tight (unpredictable) timing where you can't afford "delay()'s".
Then you would poll the status regularily between your other tasks and read the result when conversion is ready.