weatherstation/firmware/sensors.ino

45 lines
829 B
Arduino
Raw Normal View History

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-12-09 18:07:46 +01:00
return 10;
//return bme.readTemperature();
2017-11-20 20:42:02 +01:00
}
float fetchPressure() {
2017-12-09 18:07:46 +01:00
return 10;
//return bme.readPressure() / 100.0F;
2017-11-07 22:20:14 +01:00
}
float fetchHumidity() {
2017-12-09 18:07:46 +01:00
//return bme.readHumidity();
2017-11-07 22:20:14 +01:00
}
float fetchLight() {
2017-11-20 20:42:02 +01:00
uint16_t red, green, blue, white;
while(!apds.colorDataReady()){
delay(5);
}
apds.getColorData(&red, &green, &blue, &white);
return white;
2017-11-12 21:37:55 +01:00
}
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
}