//
// Based on tutorial: http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-hc-sr501-motion-sensor-tutorial/
-int pirValue; // Place to store read PIR Value
int64_t machineId;
// Key and data
char keyBuffer[80];
// Machine ID
sprintf(keyBuffer, "%04x", machineId);
// Motion detection
- sprintf(dataBuffer, "motion-detected");
+ sprintf(dataBuffer, "%s -> motion-detected", Time.timeStr().c_str());
Particle.publish(keyBuffer, dataBuffer);
delay(1000);
rm -f *.bin
particle compile photon
-flash0:
- particle flash IoT-0 photon*.bin
+flash8:
+ particle flash IoT-8 photon*.bin
-flash1:
- particle flash IoT-1 photon*.bin
+flash9:
+ particle flash IoT-9 photon*.bin
+
+flash10:
+ particle flash IoT-10 photon*.bin
PHONY += clean
clean:
compile:
rm -f *.bin
particle compile photon
-
-flash0:
- particle flash IoT-0 photon*.bin
-flash1:
- particle flash IoT-1 photon*.bin
+flash3:
+ particle flash IoT-3 photon*.bin
+
+flash4:
+ particle flash IoT-4 photon*.bin
+
+flash5:
+ particle flash IoT-5 photon*.bin
+
+flash6:
+ particle flash IoT-6 photon*.bin
+
+flash7:
+ particle flash IoT-7 photon*.bin
+
+flash11:
+ particle flash IoT-11 photon*.bin
+
+flash12:
+ particle flash IoT-12 photon*.bin
+
+flash13:
+ particle flash IoT-13 photon*.bin
PHONY += clean
clean:
#include "application.h"
#include "DHT.h"
-SYSTEM_MODE(SEMI_AUTOMATIC)
-SYSTEM_THREAD(ENABLED)
-
// System defines
// Arduino
#define DHTPIN 2 // Data pin
digitalWrite(PWRPIN, HIGH);
// Arduino DHT
dht.begin();
- // Connect to WiFi and Particle cloud
- // Wait for a maximum amount of time - sleep if WiFi is not connected
- // Wake up and try again afterwards
- // TODO: either use this or just WiFi connection (below)
- Particle.connect();
- if (!waitFor(Particle.connected, RETRY_TIME))
- System.sleep(SLEEP_MODE_DEEP, RETRY_SLEEP_TIME);
// Prepare device key from MAC (just last 2 of 6 digits)
byte mac[6];
//
// Based on tutorial: http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-hc-sr501-motion-sensor-tutorial/
+SYSTEM_MODE(SEMI_AUTOMATIC)
+SYSTEM_THREAD(ENABLED)
+
int pirValue; // Place to store read PIR Value
int64_t machineId;
// Key and data