Merge branch 'master' of mjesec.ffzg.hr:/git/Arduino
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 3 May 2015 13:04:55 +0000 (15:04 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 3 May 2015 13:04:55 +0000 (15:04 +0200)
wlan_si/Makefile [new file with mode: 0644]
wlan_si/wlan_si.ino [new file with mode: 0644]

diff --git a/wlan_si/Makefile b/wlan_si/Makefile
new file mode 100644 (file)
index 0000000..b1b4134
--- /dev/null
@@ -0,0 +1,11 @@
+all:
+       echo "flash serial"
+
+pi=10.60.1.201
+
+flash:
+       scp `ls -t /tmp/build*.tmp/*.hex | head -1` pi@${pi}:/tmp/arduino.hex
+       ssh pi@${pi} sudo avrdude -c linuxgpio -p atmega328p -U flash:w:/tmp/arduino.hex
+
+serial:
+       ssh pi@${pi} microcom -p /dev/ttyAMA0 -s 9600
diff --git a/wlan_si/wlan_si.ino b/wlan_si/wlan_si.ino
new file mode 100644 (file)
index 0000000..37ee00e
--- /dev/null
@@ -0,0 +1,41 @@
+#include <Wire.h>
+#include <Adafruit_MPL115A2.h>
+
+Adafruit_MPL115A2 mpl115a2;
+
+int led = 5; // LED on d5
+int pir = 6; // PIR on d6
+
+// hardware based on https://dev.wlan-si.net/wiki/Telemetry/sensgw
+// original software https://github.com/SloMusti/sensgw
+
+void setup(void) 
+{
+  Serial.begin(9600);
+  Serial.println("Hello!");
+  
+  Serial.println("Getting barometric pressure ...");
+  mpl115a2.begin();
+  
+  pinMode(led, OUTPUT);
+  pinMode(pir, INPUT);
+}
+
+void loop(void) 
+{
+  digitalWrite(led, HIGH);
+
+  float pressureKPA = 0, temperatureC = 0;    
+
+  mpl115a2.getPT(&pressureKPA,&temperatureC);
+  Serial.print("Pressure="); Serial.print(pressureKPA, 4); Serial.print(" kPa ");
+  Serial.print("Temp="); Serial.print(temperatureC, 1); Serial.print(" C");
+
+  Serial.print(" PIR="); Serial.print( digitalRead(pir) );
+
+  Serial.println();
+
+  digitalWrite(led, LOW);
+  
+  delay(1000);
+}