/
SendBoolean.ino
55 lines (41 loc) · 1.22 KB
/
SendBoolean.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
SigFox Send Boolean tutorial
This sketch demonstrates how to send a simple binary data ( 0 or 1 ) using a MKR Fox 1200.
If the application only needs to send one bit of information the transmission time
(and thus power consumption) will be much lower than sending a full 12 bytes packet.
This example code is in the public domain.
*/
#include <SigFox.h>
// We want to send a Boolean value to signal a binary event
// like open/close or on/off
bool value_to_send = true;
#define DEBUG 1
void setup() {
if (DEBUG){
Serial.begin(9600);
while (!Serial) {};
}
// Initialize the Sigfox module
if (!SigFox.begin()) {
if (DEBUG){
Serial.println("Sigfox module unavailable !");
}
return;
}
// If we want to to debug the application, print the device ID to easily find it in the backend
if (DEBUG){
SigFox.debug();
Serial.println("ID = " + SigFox.ID());
}
delay(100);
// Compose a message as usual; the single bit transmission will be performed transparently
// if the data we want to send is suitable
SigFox.beginPacket();
SigFox.write(value_to_send);
int ret = SigFox.endPacket();
if (DEBUG){
Serial.print("Status : ");
Serial.println(ret);
}
}
void loop(){}