added PIR sensor
[Arduino] / wlan_si / wlan_si.ino
1 #include <Wire.h>
2 #include <Adafruit_MPL115A2.h>
3
4 Adafruit_MPL115A2 mpl115a2;
5
6 int led = 5; // LED on d5
7 int pir = 6; // PIR on d6
8
9 // hardware based on https://dev.wlan-si.net/wiki/Telemetry/sensgw
10 // original software https://github.com/SloMusti/sensgw
11
12 void setup(void) 
13 {
14   Serial.begin(9600);
15   Serial.println("Hello!");
16   
17   Serial.println("Getting barometric pressure ...");
18   mpl115a2.begin();
19   
20   pinMode(led, OUTPUT);
21   pinMode(pir, INPUT);
22 }
23
24 void loop(void) 
25 {
26   digitalWrite(led, HIGH);
27
28   float pressureKPA = 0, temperatureC = 0;    
29
30   mpl115a2.getPT(&pressureKPA,&temperatureC);
31   Serial.print("Pressure="); Serial.print(pressureKPA, 4); Serial.print(" kPa ");
32   Serial.print("Temp="); Serial.print(temperatureC, 1); Serial.print(" C");
33
34   Serial.print(" PIR="); Serial.print( digitalRead(pir) );
35
36   Serial.println();
37
38   digitalWrite(led, LOW);
39   
40   delay(1000);
41 }