weatherstation/firmware/sensors.ino

31 lines
621 B
C++

int anemometerRotations = 0;
unsigned long currentTime = 0;
float fetchTemperature() {
return 22.5; // XXX: Dummy value
}
float fetchHumidity() {
return 60.0; // XXX: Dummy value
}
float fetchLight() {
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;
}