10
10
#include < Wire.h>
11
11
#include < SI7021.h>
12
12
#include < SPI.h>
13
+ #include < SPIFlash.h>
13
14
#include < EEPROM.h>
14
15
15
16
// Define a static node address, remove if you want auto address assignment
21
22
#define CHILD_ID_BATT 199
22
23
23
24
// Pin definitions
25
+ #define TEST_PIN A0
24
26
#define RESET_CFG_PIN A1
25
27
#define LED_PIN A2
26
28
30
32
#define FORCE_TRANSMIT_INTERVAL 30
31
33
32
34
SI7021 humiditySensor;
35
+ SPIFlash flash (8 , 0xEF30 );
36
+
33
37
MySensor gw;
34
38
35
39
// Sensor messages
@@ -53,10 +57,13 @@ void setup() {
53
57
54
58
// First check if we should boot into clear eeprom mode
55
59
pinMode (RESET_CFG_PIN, INPUT);
60
+ pinMode (TEST_PIN,INPUT);
56
61
digitalWrite (RESET_CFG_PIN, HIGH); // Enable pullup
62
+ digitalWrite (TEST_PIN, HIGH);
63
+ if (!digitalRead (TEST_PIN)) testMode ();
57
64
if (!digitalRead (RESET_CFG_PIN)) resetEEP ();
58
65
digitalWrite (RESET_CFG_PIN, LOW);
59
-
66
+ digitalWrite (TEST_PIN,LOW);
60
67
digitalWrite (LED_PIN, HIGH);
61
68
62
69
#ifdef NODE_ADDRESS
@@ -196,3 +203,28 @@ void switchClock(unsigned char clk)
196
203
CLKPR = clk;
197
204
sei ();
198
205
}
206
+
207
+ void testMode ()
208
+ {
209
+ if (humiditySensor.begin ())
210
+ if (flash.initialize ())
211
+ {
212
+ while (1 )
213
+ {
214
+ digitalWrite (LED_PIN, HIGH);
215
+ delay (800 );
216
+ digitalWrite (LED_PIN, LOW);
217
+ delay (200 );
218
+ }
219
+ }
220
+ else
221
+ {
222
+ while (1 )
223
+ {
224
+ digitalWrite (LED_PIN, HIGH);
225
+ delay (200 );
226
+ digitalWrite (LED_PIN, LOW);
227
+ delay (200 );
228
+ }
229
+ }
230
+ }
0 commit comments