projects
/
iotcloud.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
15d472a
)
Powering up sensor using an I/O pin to turn it off when PHOTON goes into deep sleep.
author
rtrimana
<rtrimana@uci.edu>
Mon, 16 Apr 2018 16:09:07 +0000
(09:09 -0700)
committer
rtrimana
<rtrimana@uci.edu>
Mon, 16 Apr 2018 16:09:07 +0000
(09:09 -0700)
version2/src/C/Sensor-Arduino.ino
patch
|
blob
|
history
diff --git
a/version2/src/C/Sensor-Arduino.ino
b/version2/src/C/Sensor-Arduino.ino
index 48614b21c8ff16ce01220b21ddf6e3c6978463bf..214447e6368c2e91887ec2033405074871deb3b2 100644
(file)
--- a/
version2/src/C/Sensor-Arduino.ino
+++ b/
version2/src/C/Sensor-Arduino.ino
@@
-6,10
+6,11
@@
// System defines
// Arduino
// System defines
// Arduino
-#define DHTPIN 2 // what pin we're connected to
+#define DHTPIN 2 // Data pin
+#define PWRPIN D5 // Power pin
#define DHTTYPE DHT22 // DHT 22 (AM2302)
// IoTCloud
#define DHTTYPE DHT22 // DHT 22 (AM2302)
// IoTCloud
-#define SLEEP_TIME 1
800
// Sleep time in seconds
+#define SLEEP_TIME 1
0
// Sleep time in seconds
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
@@
-33,6
+34,13
@@
void setup() {
// firmware onto the Particle board.
// e.g. sudo screen /dev/ttyACM0
// firmware onto the Particle board.
// e.g. sudo screen /dev/ttyACM0
+ // We use one I/O pin to power the sensor so
+ // that we can make it go to sleep when we go into
+ // deep sleep.
+ pinMode(PWRPIN, OUTPUT);
+ // Turn on sensor
+ digitalWrite(PWRPIN, HIGH);
+
// Prepare device key from MAC (just last 2 of 6 digits)
byte mac[6];
WiFi.macAddress(mac);
// Prepare device key from MAC (just last 2 of 6 digits)
byte mac[6];
WiFi.macAddress(mac);
@@
-86,6
+94,9
@@
void loop() {
iKeyA->releaseRef();
iValueA->releaseRef();
iKeyA->releaseRef();
iValueA->releaseRef();
+
+ // Turn off sensor
+ digitalWrite(PWRPIN, LOW);
System.sleep(SLEEP_MODE_DEEP, SLEEP_TIME);
}
System.sleep(SLEEP_MODE_DEEP, SLEEP_TIME);
}