SigFox Device Firmware

Arduino IDE

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.


SigFox library

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.

SigFox class
  • SigFox.begin(): Initializes the Sigfox library and module.
  • SigFox.beginPacket(): Begins the process of sending a packet.
  • SigFox.print(val): Sends characters data to the SigFox's backend. This data is sent as a character or series of characters (HEX String).
  • SigFox.write(val): Sends binary data to the SigFox's backend. This data is sent as a byte or series of bytes.
  • SigFox.endPacket(): Called after writing SigFox data to the remote connection, completes the process of sending a packet started by beginPacket (use "SigFox.endPacket(true)" to wait for downlink data response). Returns an int: 1 if the packet was sent successfully, 0 if there was an error.
  • SigFox.parsePacket(): Checks for the presence of a SigFox packet, and reports the size.
  • SigFox.available(): Get the number of bytes (characters) available for reading. This is data that's already arrived and stored in a receive buffer (which holds 8 bytes).
  • SigFox.read(): Reads incoming SigFox data and returns the first byte of incoming SigFox data available.
  • SigFox.end(): De-initializes the Sigfox library and module.

See the SigFox library documentation for more methods and informations: Arduino SigFox library.

SigFox downlink example

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.


Ask command to Omnyvore

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);

commandsPage

The command has to be setted from Omnyvore as a retained command.