Skip to content

Commit 17d981e

Browse files
committed
EventTrigger example: use Serial1 and explain why
1 parent 669979d commit 17d981e

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

examples/EventTrigger/EventTrigger.ino

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ volatile int alarm_source = 0;
2121
void setup() {
2222

2323
if (debug == true) {
24-
Serial.begin(115200);
25-
while (!Serial) {}
24+
25+
// We are using Serial1 instead than Serial because we are going in standby
26+
// and the USB port could get confused during wakeup. To read the debug prints,
27+
// connect pins 13-14 (TX-RX) to a 3.3V USB-to-serial converter
28+
29+
Serial1.begin(115200);
30+
while (!Serial1) {}
2631
}
2732

2833
if (!SigFox.begin()) {
@@ -38,12 +43,12 @@ void setup() {
3843
SigFox.debug();
3944
}
4045

41-
// attach pin 1 and 2 to a switch and enable the interrupt on voltage falling event
42-
pinMode(1, INPUT_PULLUP);
43-
LowPower.attachInterruptWakeup(1, alarmEvent1, FALLING);
46+
// attach pin 0 and 1 to a switch and enable the interrupt on voltage falling event
47+
pinMode(0, INPUT_PULLUP);
48+
LowPower.attachInterruptWakeup(0, alarmEvent1, FALLING);
4449

45-
pinMode(2, INPUT_PULLUP);
46-
LowPower.attachInterruptWakeup(2, alarmEvent2, FALLING);
50+
pinMode(1, INPUT_PULLUP);
51+
LowPower.attachInterruptWakeup(1, alarmEvent2, FALLING);
4752
}
4853

4954
void loop()
@@ -56,7 +61,7 @@ void loop()
5661
SigFox.begin();
5762

5863
if (debug == true) {
59-
Serial.println("Alarm event on sensor " + String(alarm_source));
64+
Serial1.println("Alarm event on sensor " + String(alarm_source));
6065
}
6166
delay(100);
6267

@@ -72,13 +77,13 @@ void loop()
7277

7378
if (debug == true) {
7479
if (ret > 0) {
75-
Serial.println("No transmission");
80+
Serial1.println("No transmission");
7681
} else {
77-
Serial.println("Transmission ok");
82+
Serial1.println("Transmission ok");
7883
}
7984

80-
Serial.println(SigFox.status(SIGFOX));
81-
Serial.println(SigFox.status(ATMEL));
85+
Serial1.println(SigFox.status(SIGFOX));
86+
Serial1.println(SigFox.status(ATMEL));
8287

8388
// Loop forever if we are testing for a single event
8489
while (1) {};

0 commit comments

Comments
 (0)