2018-06-23 20:13:33 +02:00
|
|
|
|
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 19:10:31 +01:00
|
|
|
//return 10;
|
2017-11-20 20:42:02 +01:00
|
|
|
return bme.readTemperature();
|
|
|
|
}
|
|
|
|
|
|
|
|
float fetchPressure() {
|
2017-12-09 19:10:31 +01:00
|
|
|
//return 10;
|
2017-11-20 20:42:02 +01:00
|
|
|
return bme.readPressure() / 100.0F;
|
2017-11-07 22:20:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
float fetchHumidity() {
|
2017-11-20 20:42:02 +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;
|
|
|
|
|
2018-07-12 22:30:30 +02:00
|
|
|
while(!apds.colorDataReady()) {
|
2017-11-20 20:42:02 +01:00
|
|
|
delay(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
apds.getColorData(&red, &green, &blue, &white);
|
|
|
|
return white;
|
2017-11-12 21:37:55 +01:00
|
|
|
}
|
|
|
|
|
2018-06-23 20:13:33 +02:00
|
|
|
void _anemometerInterrupt() {
|
2017-11-12 21:37:55 +01:00
|
|
|
anemometerRotations++;
|
2018-06-23 20:13:33 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
Serial.print("*");
|
|
|
|
#endif
|
2017-11-12 21:37:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
float fetchWindspeed() {
|
|
|
|
anemometerRotations = 0;
|
|
|
|
currentTime = millis();
|
|
|
|
int interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
|
|
|
|
|
2018-06-23 20:13:33 +02:00
|
|
|
attachInterrupt(interruptNumber, _anemometerInterrupt, RISING);
|
2017-11-12 21:37:55 +01:00
|
|
|
delay(1000 * 5);
|
|
|
|
detachInterrupt(interruptNumber);
|
|
|
|
|
|
|
|
return (float)anemometerRotations / 5.0 * 2.4;
|
2017-11-07 22:20:14 +01:00
|
|
|
}
|
2018-07-11 11:12:53 +02:00
|
|
|
|
|
|
|
// Copied from https://arduinodiy.wordpress.com/2016/12/25/monitoring-lipo-battery-voltage-with-wemos-d1-minibattery-shield-and-thingspeak/
|
|
|
|
float getBatteryVoltage() {
|
|
|
|
uint16_t raw = analogRead(A0);
|
|
|
|
float volt = raw / 1023.0;
|
|
|
|
volt = volt * 4.2;
|
|
|
|
return volt;
|
|
|
|
}
|
2017-12-09 19:10:31 +01:00
|
|
|
|