The open-source Arduino Software (IDE) is available to write code and upload it to the board. The Arduino environment can be also extended through the use of libraries (e.g. SigFox library). Libraries provide extra functionality for use in sketches, e.g. working with hardware or manipulating data. To use a library in a sketch, select it from Sketch > Import Library.
Arduino IDE is available at the following link for Windows, Mac OS X, and Linux: Arduino IDE.
This library allows you to use the ATMEL SigFox transceiver (ATAB8520E) on the Arduino MKRFOX1200 board. It is therefore possible to communicate with the SigFox Database to send and receive data.
See the SigFox library documentation for more methods and informations: Arduino SigFox library.
Use the following code to send data and get a response:
SigFox.begin(); // Start the module
SigFox.beginPacket(); // Begin to send packet
SigFox.print(yourdata);
int ret = SigFox.endPacket(true); // send buffer to SIGFOX network and wait for a response
if (ret > 0) {
Serial.println("No transmission");}
else {
Serial.println("Transmission ok");}
char inData[8]; // Allocate some space for the string
char inChar; // Where to store the character read
byte index = 0; // Index into array; where to store the character
if (SigFox.parsePacket()) {
Serial.println("Response from server: ");
while (SigFox.available()) { // Downlink message of 8 bytes
if(index < 8) {
inChar = SigFox.read(); // Read a character
inData[index] = inChar; // Store it
index++; // Increment where to write next
inData[index] = '\0'; // Null terminate the string
}
}
}
SigFox.end();
A downlink message must contain 8 bytes data.
Use the ask command feature to ask Omnyvore if there is a pending message for a device. To make a command request use "SigFox.print(val)" to send hex data with the following value:
val = [c}"commandtopic" (replace "commandtopic" with the correct command topic setted from Omnyvore).
In the following example we're asking command to Omnyvore at command topic "50":
SigFox.beginPacket();
SigFox.print("[c}50");
int ret = SigFox.endPacket(true);
The command has to be setted from Omnyvore as a retained command.