Iot – Device API Integration with Rest Slack, Intel Edison and Node.js

ByAlexandre Brandao Lustosa in

To developers, IoT can seem a complex subject, with lots of difficulties to implement, especially when it addresses languages like C/C++, Assembler and integration with high-level systems such as REST APIs and cloud services.

In this article we will work on a Stack to troubleshoot devices integrations with high level systems in a simple, effective and productive way.

Node.js – Javascript on Devices?

Yes, that’s right! How about developing integrations with sensors, LED, serial communication systems, I2Sim, I2C, USB, Relay, Infrared, Ethernet for Embeed Devices simply and productively?

Use Node.js

This way, you can develop your Rest API, one Ortal p data visualization, backend systems and also Embeeded aplication all with one programming language, which makes it easy.You can share, reuse and port code between platforms, not to mention that in this way you do not need a giant multidisciplinary team with differnet programming languages skills.

Sounds good right?

Solution Stack and Tools

In this article we will create a temperature monitoring system where the readings obtained by the sensor, installed on Intel Edison, will be published on Slack.Slack is a messaging tool, has a rich Web interface and also desktop and mobile versions. It is a great solution for reporting and alerts.

For this proposal to become reality we need some tools, here is the proposed stack for the integration solution and implementation of this example.

Data flow

Intel Edison Board for IoT

Powerful development platform for embedded systems based on and fully compatible with Arduino. It supports not only Node.js but also C/C++, Java, Python, and others.

  • Dual-core Intel® Atom ™ processor at 500 MHz
  • 1 GB DDR3 RAM, 4 GB eMMC flash
  • 40 multiplexed GPIO interfaces
  • Bluetooth* 4.0, Wi-Fi*
  • Yocto Project*, Brillo*
  • Arduino* compatible
  • Open-source software development enviroment
  • C/C++, Python*, Node.js, HTML5, JavaScript*

Intel Edison ofical references:

Intel Edison Chip
Intel Edison Chip
Intel Edison Breakout Board
Intel Edison Breakout Board
Intel Edison Mini Breakout Board
Intel Edison Mini Breakout Board
Grove Temperature Sensor
Grove Temperature Sensor
Intel Edison with Grove Kit
Intel Edison with Grove Kit
Intel Edison Architecture Diagram
Intel Edison Architecture Diagram

Intel XDK Development IDE

Intel provides a powerful IDE for development of mobile and IoT solutions: Intel XDK, which can be downloaded from at It is also an excellent tool for those who want to develop cross-platform mobile applications.

Configuring a new Slack Rest API Integration Url

To perform Slack notifications we need to create a channel or use an existing channel. After, have in the settings an integration url that will point all received data to the desired channel. Just follow the steps below:

1. Click New channel


2. Set a name and a description for the new channel and click on “Create Channel”


3. That’s it, your new channel is created

4. Now let’s define a new integration for the channel. Click “Manager” as indicated below.


5. Add a new setting


6. Select channel and confirm the creation of the new channel


7. Take notes of the new WebHook url that was generated, we need to display it in the code to send the data via http POST to the correct channel.


8. Okay, we’ve set up everything at slack. 🙂 See the indication of success in the settings of the notification Url in the message shown on the channel.


Hardware Configurations

For the code to work properly it is necessary to instal correctly the Intel XDK, to have internet acess for the Intel Edison (via Wi-Fi preferably), the Grove Kit temperature sensor needs to be connected to the analog port A0, the LED for processing indication has to be connected to the GPIO2, the Intel Edison must be properly connected to the development station and integrated with the IDE Intel XDK. For questions on how to set up Intel Edison and Intel XDK access these links:

Successfull configuration on Intel Edison Configuration Tool
Successfull configuration on Intel Edison Configuration Tool

Download code and deploy to Intel Edison

Now, with all properly set, download the code from GitHub repository.

Open the IDE Intel XDK and then the project through the file IoTTempMonitor.xdk.

Open the file main.js and replace the url webhook on line 113 by the set url as we showed earlier and save the file.

Check the connections to the Intel Edison Breakout Board and click the Upload button as shown below:


After uploading, the application will go into processing and will present readings and messages indicating that the POST process for Slack was successfully made.

Application running on Intel Edison

We can open Slack now, whether on web, desktop or mobile version, and display the notification message in the Chanel.

Notification message with the data obtained from the temperature sensor
Notification message with the data obtained from the temperature sensor

If your application does not automatically boot you can access Intel Edison’s terminal and make the startup manually. Access Intel Edison by serial terminal and perform the following steps:


The code!

The main code is in main.js file that is fully commented to facilitate the comprehension and maintenance of the application behavior. But first of all, to assess the data flow diagram to facilitate comprehension of the responsibility of each method and how the application behaves.

Operating with infinite loop workflow and execution break in every 4 seconds
Operating with infinite loop workflow and execution break in every 4 seconds
	    Iot Intel Edison Api REST Slack Integration
	    by Alexandre Brandão Lustosa

	//Load mraa eletronic sensor library
	var mraa = require("mraa");
	//Load http request library
	var request = require('request');

	//Sensor variable
	var tempSensor = new mraa.Aio(0);
	//Led process indicator
	var ledProcess = new mraa.Gpio(2);

	//Initialize application

	//Main function
	function main(){
	    //Print message
	    //Setup configurations
	    //Set loop process each 4 seconds
	    setInterval(function () {
	        //Set led process indicator on
	        //Read Sensor
	        var data = readTempSensor();
	        //Post data on Slack
	        //Set led process indicator on
	    }, 4000);

	//Setup configuration
	function config(){
	    //Set pin direction

	//Read temperature sensor
	function readTempSensor() {          
	    //Read sensor
	    var a =;
	    //Set resistênce value
	    var resistance = (1023 - a) * 10000 / a;
	    //Convert temperature to celsius according mraa datasheet
	    var celsius_temperature = 1 / (Math.log(resistance / 10000) / 3975 + 1 / 298.15) - 273.15;
	    //Convert temperature to fahrenheit
	    var fahrenheit_temperature = (celsius_temperature * (9 / 5)) + 32;
	    //Print message
	    console.log("Fahrenheit Temperature: " + fahrenheit_temperature);
	    //Print message
	    console.log("Celcius Temperature: " + celsius_temperature);  
	    //Set response message
	    var data = formatData(fahrenheit_temperature, celsius_temperature);
	    return data;

	//Set led process indicator on
	function ledProcessOn(){
	    //Write signal to up

	//Set led process indicator off
	function ledProcessOff(){
	    //Write signal to down

	//Format message
	function formatData(fahrenheit, celsius){
	    //Set message
	    var msg = "Fahrenheit: " + fahrenheit.toFixed(2) + "°F / Celsius: " + celsius.toFixed(2) + "°C";
	    //Set data
	    var data = {
	        "text": "Actual local temperature:",
	        "attachments": [
	                "color": "#0066ff",
	                "text": msg,
	                "footer": "Slack API IoT Integration with Intel Edison",
	                "footer_icon": "",
	    return data;

	//Post data on Slack  WebHoook Integration
	function postOnSlack(data){
	    //Set options and message
	    var options = {
	        //Webhook uri, replace by your uri Slack web hook integration
	        uri: '',
	        method: 'POST', //Request type
	        json: data      //Data

	    //Do post request
	    request(options, function (error, response, body) {
	        //Verify response
	        if (!error && response.statusCode == 200) {
	            //Print message
	            //Print message

This source code and other examples of systems and libraries for IoT are available for download at GibHub:


There is nothing better than applying our knowledge in an emerging area that will increasingly impact people’s lives. Use your ideas, solve problems and reduce the complexity of their implementation, use the Intel Edison with Node.js, cause impact, be an Intel Maker and change the world around you.

Leave a comment! 0

0 comentário


Your email address will not be published. Required fields are marked *

Commenting asAnônimo

read more