DEV Community

Austin Spivey for Wia

Posted on

Setup an Arduino MKR FOX 1200 and Publish an Event to Wia

Components

  • Arduino MKRFox1200
  • Sigfox Antenna
  • Micro USB to USB

Setup Your Environment

If you have not already done, download and install the Arduino IDE for your chosen operating system here.

  • Open the IDE and go to Tools > Boards > Board Manager
  • Search for the Arduino SAMD Boards
  • Install the board's core library

alt text
Arduino board manager

Connect the Board to your Computer

Using a micro USB cable, connect the micro USB port on the board to the USB port on your computer.

Install required Libraries

  • Go to Sketch > Include Libraries > Manage Libraries
  • Type SigFox into the search bar and click the first option. A button will appear in the bottom right of the box that will allow you to install the library

Repeat install for libraries:

  • Arduino Low Power
  • RTCzero alt text Sigfox Library

Select Board and Port

Once you've got it connected to your computer, in the Arduino IDE, Select Tools

  • Select the Arduino MRKFox1200 board
  • Select the correct port (Arduino MRKfox1200 should be on the port name): If no name is displayed, you can find the port with the following steps:

Linux and Mac OS X

  • Download and install the FTDI drivers from here. Select the appropriate version for your operating system and architecture
  • Open a terminal window and run the command ls /dev/tty*
  • Look for a device with the name that begins with /dev/tty e.g. /dev/tty.usbmodemPy343431 on MAC or /dev/ttyUSB0/dev/ttyACM0 on Linux

Note: For Linux, you may need to run the two commands below. Once you've completed that, reboot your computer. This will add permissions that will allow you to upload a sketch to the board.

sudo usermod -a -G tty ${USER}
sudo usermod -a -G dialout ${USER}

Windows

  • Download and install the FTDI drivers from here. Select the appropriate version for your operating system and architecture
  • Open the Windows start menu and search for Device Manager
  • The COM port for the Pycom device will be listed as USB Serial Device or something similar
  • Keep note of the COM port (e.g. COM4)

Install the required libraries

Create a new Sketch

Create a new file called sketch_sigfox_init.ino and add the code below.

sketch_main.ino

 #include <SigFox.h>   // must include the SigFox library

void setup() {
  Serial.begin(9600); 
  while(!Serial) {}; //waits for Serial to be available
  if (!SigFox.begin()) { //ensures SigFox is connected
    Serial.println("Shield error or not present!");
    return;
  }

  String version = SigFox.SigVersion();
  String ID = SigFox.ID();
  String PAC = SigFox.PAC();

  Serial.println("ID  = " + ID);
  Serial.println("PAC = " + PAC);

  delay(100);

  // Send the module to the deepest sleep
  SigFox.end();
}

void loop() {
}
Enter fullscreen mode Exit fullscreen mode

The code above just waits until the Serial has begun. This makes sure Sigfox is connected and prints the Device ID and PAC number of the Device.

Upload Code to the Board

Click Sketch > Upload to upload the code to your Device to retrieve the ID and PAC number of the device.

View the Serial Monitor

  • Click the Screen Monitor icon on the right hand side
  • In the monitor, it should display the ID and PAC for the device alt text Board ID and Pac Numbers

Register Device with Sigfox

  • Click here to register the Device with Sigfox
  • Choose the provider Arduino from the list Then, choose the appropriate country alt text Sigfox providers

Enter Device information

  • Enter the ID and PAC of your device into Sigfox alt text Sigfox Device ID and PAC

Once entered, you must sign in or sign up to a Sigfox account to view your Device on the Sigfox Dashboard.

The Code

Create a new file called sketch_sigfox.ino and add the code below.Make sure that:

  • Tools > Boards is set to Arduino MRKfox1200
  • Tools > Port is set to the port of the board

Sigfox

 #include <SigFox.h>   // must include the SigFox library

void setup() {
  Serial.begin(9600); 
  while(!Serial) {}; //waits for Serial to be available
  if (!SigFox.begin()) { //ensures SigFox is connected
    Serial.println("Shield error or not present!");
    return;
  }
  Serial.print("sending");
  Serial.print(SigFox.internalTemperature())
  SigFox.begin();
  SigFox.beginPacket();
  SigFox.print(SigFox.internalTemperature()); //content of the packet

  SigFox.endPacket();
  Serial.print("sent");
}
void loop() {
  while(1);
}
Enter fullscreen mode Exit fullscreen mode
  • SigFox.beginPacket() & SigFox.endPacket() are the wrappers for the payload
  • The data is placed between the wrappers and has a max size of 12 Bytes
  • Strings will be converted to hexadecimal

Upload the Code

  • Click Sketch > Upload to upload the code for MRKfox1200
  • You can view the output from the serial monitor on the right of the screen

Receiving the Message on Sigfox dashboard

  • Go to the Sigfox dashboard, the link is here
  • On your Sigfox account, click on the Device tab, click on your Device ID and click Messages
    alt text
    Sigfox message

  • The payload will be displayed in hexadecimal

  • Convert to ASCII to view your message

Connecting Sigfox with Wia

  • First, Sigfox must be integrated with Wia to see your Sigfox messages in Wia
  • The tutorial can be accessed here

Receiving the message on Wia

If the callback has been properly setup between Sigfox and Wia, the message should also be displayed in Wia

alt text

  • Go to your Space that has your Sigfox integration
  • Click on Device that matches the Sigfox device on the Sigfox website
  • Click on the events tab and Sigfox message should be displayed

alt text

If you need any help with getting setup or you don't understand the tutorial, tweet us, email support@wia.io or chat on Intercom.

Top comments (0)