File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ SigFox Send Boolean tutorial
3+
4+ This sketch demonstrates how to send a simple binary data ( 0 or 1 ) using a MKRFox1200.
5+ If the application only needs to send one bit of information the transmission time
6+ (and thus power consumption) will be much lower than sending a full 12 bytes packet.
7+
8+ This example code is in the public domain.
9+ */
10+
111#include < SigFox.h>
2- #define VALUE_TO_SEND 1
12+
13+ // We want to send a boolean value to signal a binary event
14+ // like open/close or on/off
15+
16+ bool value_to_send = true ;
17+
318#define DEBUG 1
19+
420void setup () {
521
622 if (DEBUG){
723 Serial.begin (9600 );
824 while (!Serial) {};
925 }
1026
27+ // Initialize the SigFox module
1128 if (!SigFox.begin ()) {
1229 if (DEBUG){
1330 Serial.println (" Sigfox module unavailable !" );
1431 }
1532 return ;
1633 }
34+
35+ // If we wanto to debug the application, print the device ID to easily find it in the backend
1736 if (DEBUG){
1837 SigFox.debug ();
1938 Serial.println (" ID = " + SigFox.ID ());
2039 }
40+
2141 delay (100 );
22- int ret = SigFox.sendBit (VALUE_TO_SEND);
42+
43+ // Compose a message as usual; the single bit transmission will be performed transparently
44+ // if the data we want to send is suitable
45+ SigFox.beginPacket ();
46+ SigFox.write (value_to_send);
47+ int ret = SigFox.endPacket ();
48+
2349 if (DEBUG){
2450 Serial.print (" Status : " );
2551 Serial.println (ret);
You can’t perform that action at this time.
0 commit comments