2017-11-12 21:37:55 +01:00
|
|
|
int anemometerRotations = 0;
|
|
|
|
unsigned long currentTime = 0;
|
2017-11-07 22:20:14 +01:00
|
|
|
|
|
|
|
float fetchTemperature() {
|
2017-11-12 21:37:55 +01:00
|
|
|
return 22.5; // XXX: Dummy value
|
2017-11-07 22:20:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
float fetchHumidity() {
|
2017-11-12 21:37:55 +01:00
|
|
|
return 60.0; // XXX: Dummy value
|
2017-11-07 22:20:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
float fetchLight() {
|
2017-11-12 21:37:55 +01:00
|
|
|
return 2000.4; // XXX: Dummy value
|
|
|
|
}
|
|
|
|
|
|
|
|
void anemometerInterrupt() {
|
|
|
|
anemometerRotations++;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2017-11-07 22:20:14 +01:00
|
|
|
}
|
|
|
|
|