48 lines
872 B
C++
Executable file
48 lines
872 B
C++
Executable file
|
|
int anemometerRotations = 0;
|
|
unsigned long currentTime = 0;
|
|
|
|
float fetchTemperature() {
|
|
//return 10;
|
|
return bme.readTemperature();
|
|
}
|
|
|
|
float fetchPressure() {
|
|
//return 10;
|
|
return bme.readPressure() / 100.0F;
|
|
}
|
|
|
|
float fetchHumidity() {
|
|
return bme.readHumidity();
|
|
}
|
|
|
|
float fetchLight() {
|
|
uint16_t red, green, blue, white;
|
|
|
|
while(!apds.colorDataReady()){
|
|
delay(5);
|
|
}
|
|
|
|
apds.getColorData(&red, &green, &blue, &white);
|
|
return white;
|
|
}
|
|
|
|
void _anemometerInterrupt() {
|
|
anemometerRotations++;
|
|
#ifdef DEBUG
|
|
Serial.print("*");
|
|
#endif
|
|
}
|
|
|
|
float fetchWindspeed() {
|
|
anemometerRotations = 0;
|
|
currentTime = millis();
|
|
int interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
|
|
|
|
attachInterrupt(interruptNumber, _anemometerInterrupt, RISING);
|
|
delay(1000 * 5);
|
|
detachInterrupt(interruptNumber);
|
|
|
|
return (float)anemometerRotations / 5.0 * 2.4;
|
|
}
|
|
|