2 #include <Adafruit_MPL115A2.h>
4 Adafruit_MPL115A2 mpl115a2;
6 int led = 5; // LED on d5
7 int pir = 6; // PIR on d6
9 // hardware based on https://dev.wlan-si.net/wiki/Telemetry/sensgw
10 // original software https://github.com/SloMusti/sensgw
12 float runningAverage(float M) {
14 static float LM[LM_SIZE]; // LastMeasurements
15 static byte index = 0;
17 static byte count = 0;
19 // keep sum updated to improve speed.
24 index = index % LM_SIZE;
25 if (count < LM_SIZE) count++;
33 Serial.println("Hello!");
35 Serial.println("Getting barometric pressure ...");
46 digitalWrite(led, HIGH);
48 float pressureKPA = 0, temperatureC = 0;
50 mpl115a2.getPT(&pressureKPA,&temperatureC);
52 if ( count++ % 10 == 0 ) {
53 Serial.print("Pressure="); Serial.print(runningAverage(pressureKPA), 4); Serial.print(" kPa ");
54 Serial.print("Temp="); Serial.print(temperatureC, 1); Serial.print(" C");
56 Serial.print(" PIR="); Serial.print( digitalRead(pir) );
58 Serial.print(" A0="); Serial.print( analogRead(0) );
63 runningAverage(pressureKPA);
66 digitalWrite(led, LOW);