File tree 7 files changed +31
-21
lines changed
7 files changed +31
-21
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
2
* FILE: PietteTech_DHT.cpp
3
- * VERSION: 0.3
3
+ * VERSION: 0.4
4
4
* PURPOSE: Spark Interrupt driven lib for DHT sensors
5
5
* LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
6
6
*
7
7
* S Piette (Piette Technologies) [email protected]
8
8
* January 2014 Original Spark Port
9
9
* October 2014 Added support for DHT21/22 sensors
10
10
* Improved timing, moved FP math out of ISR
11
+ * September 2016 Updated for Particle
11
12
*
12
13
* Based on adaptation by niesteszeck (github/niesteszeck)
13
14
* Based on original DHT11 library (http://playgroudn.adruino.cc/Main/DHT11Lib)
@@ -133,7 +134,7 @@ int PietteTech_DHT::acquire() {
133
134
return DHTLIB_ERROR_ACQUIRING;
134
135
}
135
136
136
- int PietteTech_DHT::acquireAndWait (uint32_t timeout= 0 ) {
137
+ int PietteTech_DHT::acquireAndWait (uint32_t timeout) {
137
138
acquire ();
138
139
uint32_t start = millis ();
139
140
uint32_t wrapper;
Original file line number Diff line number Diff line change 1
1
/*
2
2
* FILE: PietteTech_DHT.h
3
- * VERSION: 0.3
3
+ * VERSION: 0.4
4
4
* PURPOSE: Spark Interrupt driven lib for DHT sensors
5
5
* LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
6
6
*
7
7
* S Piette (Piette Technologies) [email protected]
8
8
* January 2014 Original Spark Port
9
9
* October 2014 Added support for DHT21/22 sensors
10
10
* Improved timing, moved FP math out of ISR
11
+ * September 2016 Updated for Particle
11
12
*
12
13
* Based on adaptation by niesteszeck (github/niesteszeck)
13
14
* Based on original DHT11 library (http://playgroudn.adruino.cc/Main/DHT11Lib)
27
28
28
29
#include " application.h"
29
30
30
- #define DHTLIB_VERSION " 0.3 "
31
+ #define DHTLIB_VERSION " 0.4 "
31
32
32
33
// device types
33
34
#define DHT11 11
@@ -65,7 +66,7 @@ class PietteTech_DHT
65
66
void begin (uint8_t sigPin, uint8_t dht_type, void (*isrCallback_wrapper)());
66
67
void isrCallback ();
67
68
int acquire ();
68
- int acquireAndWait (uint32_t );
69
+ int acquireAndWait (uint32_t timeout = 0 );
69
70
float getCelsius ();
70
71
float getFahrenheit ();
71
72
float getKelvin ();
Original file line number Diff line number Diff line change 1
1
/*
2
- * FILE: DHT_2sensor.ino
3
- * VERSION: 0.3
2
+ * FILE: DHT_2sensor.cpp
3
+ * VERSION: 0.4
4
4
* PURPOSE: Example that uses DHT library with two sensors
5
5
* LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
6
6
*
12
12
* January 2014 Original Spark Port
13
13
* October 2014 Added support for DHT21/22 sensors
14
14
* Improved timing, moved FP math out of ISR
15
+ * September 2016 Updated for Particle
15
16
*/
16
17
// NOTE DHT_REPORT_TIMING requires DHT_DEBUG_TIMING in PietteTech_DHT.h for debugging edge->edge timings
17
18
// #define DHT_REPORT_TIMING
18
19
19
- #include " PietteTech_DHT/PietteTech_DHT.h"
20
+ #include " PietteTech_DHT/PietteTech_DHT.h" // Uncomment if building in IDE
21
+ // #include "PietteTech_DHT.h" // Uncomment if building using CLI
20
22
21
23
#define DHTTYPEA DHT22 // Sensor type DHT11/21/22/AM2301/AM2302
22
24
#define DHTPINA 3 // Digital pin for comunications
@@ -58,6 +60,7 @@ void setup()
58
60
Serial.begin (9600 );
59
61
while (!Serial.available ()) {
60
62
Serial.println (" Press any key to start." );
63
+ Particle.process ();
61
64
delay (1000 );
62
65
}
63
66
Serial.println (" DHT Example program using 2 DHT sensors" );
Original file line number Diff line number Diff line change 1
1
/*
2
- * FILE: DHT_example.ino
3
- * VERSION: 0.3
2
+ * FILE: DHT_example.cpp
3
+ * VERSION: 0.4
4
4
* PURPOSE: Example that uses DHT library with two sensors
5
5
* LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
6
6
*
14
14
* January 2014 Original Spark Port
15
15
* October 2014 Added support for DHT21/22 sensors
16
16
* Improved timing, moved FP math out of ISR
17
+ * September 2016 Updated for Particle
17
18
*/
18
19
19
- #include " PietteTech_DHT/PietteTech_DHT.h"
20
+ #include " PietteTech_DHT/PietteTech_DHT.h" // Uncomment if building in IDE
21
+ // #include "PietteTech_DHT.h" // Uncomment if building using CLI
20
22
21
23
// system defines
22
24
#define DHTTYPE DHT22 // Sensor type DHT11/21/22/AM2301/AM2302
@@ -39,6 +41,7 @@ void setup()
39
41
Serial.begin (9600 );
40
42
while (!Serial.available ()) {
41
43
Serial.println (" Press any key to start." );
44
+ Particle.process ();
42
45
delay (1000 );
43
46
}
44
47
Serial.println (" DHT Example program using DHT.acquire and DHT.aquiring" );
Original file line number Diff line number Diff line change 1
1
/*
2
- * FILE: DHT_simple.ino
3
- * VERSION: 0.3
2
+ * FILE: DHT_simple.cpp
3
+ * VERSION: 0.4
4
4
* PURPOSE: Example that uses DHT library with two sensors
5
5
* LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
6
6
*
11
11
* January 2014 Original Spark Port
12
12
* October 2014 Added support for DHT21/22 sensors
13
13
* Improved timing, moved FP math out of ISR
14
+ * September 2016 Updated for Particle
14
15
*/
15
16
16
17
#include " PietteTech_DHT/PietteTech_DHT.h" // Uncomment if building in IDE
17
- // #include "PietteTech_DHT.h" // Uncommend if building using CLI
18
+ // #include "PietteTech_DHT.h" // Uncomment if building using CLI
18
19
19
20
#define DHTTYPE DHT22 // Sensor type DHT11/21/22/AM2301/AM2302
20
- #define DHTPIN 2 // Digital pin for communications
21
+ #define DHTPIN 3 // Digital pin for communications
21
22
22
23
// declaration
23
24
void dht_wrapper (); // must be declared before the lib initialization
@@ -31,6 +32,7 @@ void setup()
31
32
Serial.begin (9600 );
32
33
while (!Serial.available ()) {
33
34
Serial.println (" Press any key to start." );
35
+ Particle.process ();
34
36
delay (1000 );
35
37
}
36
38
Serial.println (" DHT Example program using DHT.acquireAndWait" );
Original file line number Diff line number Diff line change
1
+ firmware/PietteTech_DHT.cpp
2
+ firmware/PietteTech_DHT.h
3
+ firmware/examples/DHT_simple.cpp
4
+ #firmware/examples/DHT_example.cpp
5
+ #firmware/examples/DHT_2sensor.cpp
6
+
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments