Getting Started with the Intel Edison

The Intel Edison is a very capable compute module that runs Linux. It’s an ideal IoT device because it has built-in WiFi and Bluetooth connectivity. This guide will cover how to connect an Intel Edison to the Losant Enterprise IoT Platform.

Setup the Edison and XDK

The Edison requires some setting up before it’s ready to use. Follow our setup guide to flash and connect the Edison to your WiFi network.

Next, follow Intel’s instructions for installing, configuring, and connect the Intel XDK to the Edison board.

Install XDK

Be sure to enable the Intel XDK IoT Edition in the options. At the time of this writing, the installer also installs v1.6.5 of the Arduino IDE, which is not the latest. The Arduino IDE is not needed to program the Edison, but if you’d like it anyway, we recommend installing the latest directly from Arduino.

Programming the Edison

Create a new project using the Intel XDK. Losant provides an open source JavaScript MQTT Client that can be used to easily connect the Edison to the Losant Platform.

Add the losant-mqtt module to the package.json dependencies.

  "name": "MyEdisonProject",
  "description": "",
  "version": "0.0.0",
  "main": "main.js",
  "engines": {
    "node": ">=0.10.0"
  "dependencies": {
    "losant-mqtt" : "^1.0.0"

Connecting to Losant

To connect your device to Losant, simply create an instance of the Device object, pass it your access keys, and call connect.

var Device = require('losant-mqtt').Device;

// Construct a device instance.
var device = new Device({
  id: 'my-device-id',
  key: 'my-access-key',
  secret: 'my-access-secret'

// Connect device to Losant.

The device ID is obtained by first adding your device to your Losant application. Access keys allow you to grant access on a per-device or per-application basis.

Sending State

Once the device is connected you can begin reporting state. For this example, the Edison will report the value of a TMP36 temperature sensor every one second.

// Reading temperature from analog input.
var temp = new mraa.Aio(0);

// Once a second, read the temp and report to Losant.
setInterval(function() {

  // Read temp voltage and convert.
  var tempRaw =;
  var degreesC = (((tempRaw / 1024) * 5) - 0.52) * 100;
  var degreesF = degreesC * 1.8 + 32;


  // Report state to Losant.
  device.sendState({ temp: degreesF });

}, 1000);

Handling Commands

Commands allow you to instruct your device to take some kind of action. Commands include a name and an optional payload. Subscribing to commands is done by attaching the command event listener.

// Attach event listener for commands.
device.on('command', function(command) {

The full source for this examples can be found on the Losant JavaScript MQTT Client GitHub repository.