Open
Description
In the file "SparkFun_Photon_Weather_Shield_Particle_Library/firmware/SparkFun_Photon_Weather_Shield_Library.cpp", in the function "makeMeasurment()", there waiting with a delay and a timeout. That can be removed.
Explanation: Common-mistakes#1
The Wire.endTransmission() is not checked for an error, so I seen no reason to check for the number of received bytes. However, to keep that functionality of the code, it can be replaced by checking Wire.available() just once.
This:
Wire.requestFrom(ADDRESS,nBytes);
//Wait for data
int counter = 0;
while (Wire.available() < nBytes){
delay(1);
counter ++;
if (counter >100){
// Timeout: Sensor did not return any data
return 100;
}
}
could be replaced by this:
Wire.requestFrom(ADDRESS,nBytes);
if(Wire.available() != nBytes){
return 100;
}
Metadata
Metadata
Assignees
Labels
No labels