Pete Hoffswell
Published © MIT

Intel Edison and ARTIK Cloud Temperature Monitor

Connect your Intel Edison to a temperature sensor, and then track data over time with ARTIK Cloud.

IntermediateFull instructions provided2 hours466
Intel Edison and ARTIK Cloud Temperature Monitor

Things used in this project

Hardware components

Intel Edison
Intel Edison
Specifically, the IOT edition with development Board
×1
Grove starter kit plus for Intel Edison
Seeed Grove starter kit plus for Intel Edison
Or simply the Grove shield, display and temperature sensor
×1

Software apps and online services

ARTIK Cloud for IoT
Samsung ARTIK Cloud for IoT

Story

Read more

Schematics

System hookup

Connecting devices with the Grove kit is very easy. Simply connect your display to an I2C port, and your temperature sensor to the A0 port
Img 20160807 152700589

Code

Edison Nodejs code

JavaScript
/* Thermometer

Connect Intel Edison with Seedstudio Grove Starter Kit Plus Temperature sensor and display to make a Thermometer.

Publish temperature to ARTIK Cloud

Hardware:
Intel Edison Kit for Arduino
Grove Starter Kit Plus, containing - 
    Base Shield
    Temperature Sensor
    LCD Display
    
Connect the LCD to and I2C Port
Connect the temperature sensor to A2 port
Set shield for 5 volts

pete@hoffswell.com
August, 2016
*/

// Configure these variables - 

var ID = '<device id>';  // Your Device Id from ARTIK Cloud
var TOKEN = '<device token>'; // Your Device Token from ARTIK Cloud

//

// configure jshint
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */

var mraa = require('mraa'); // mraa library for access to gpio
var mqtt = require('mqtt'); // mqtt messaging library for communicating with ARKTK
                            // If this errors out, be sure to "root@edison2:~# npm install mqtt"
var lcd = require('jsupm_i2clcd');

var display = new lcd.Jhd1313m1(0, 0x3E, 0x62);
var analogPin0 = new mraa.Aio(0); //setup access analog input Analog pin #0 (A0)
var analogPin1 = new mraa.Aio(1);
var B = 3975; // B value of termistor 
var delay = 3*1000; // delay between reads/display
var display_temp;

console.log('ARTIK Thermometer');
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console

display.setColor(0, 100, 100);  // R G B display background color

var PROTOCOL = 'mqtts';
var BROKER ='api.artik.cloud';
var PORT = 8883;

//Create the url string
var URL = PROTOCOL + '://' + BROKER;
URL += ':' + PORT;

var requireds = { username: ID, password: TOKEN };
var mqttConfig = { 'url': URL, 'requireds': requireds };

var client = mqtt.connect(mqttConfig.url, mqttConfig.requireds);
var TOPIC = '/v1.1/messages/'+ID;

client.on('connect', function () { // Connect MQTT to ARTIK
    console.log('ARTIK connected');
    setInterval(function () { // Every 10 seconds publish!
        console.log('Published ' + '{"Temperature":'+display_temp+'}');
        client.publish(TOPIC, '{"Temperature":'+display_temp+'}');    
    }, 10*1000);//Keeps publishing every 10000 milliseconds.    
});

read_display(); // start the loop

function read_display() {
    // read the temperature sensor, convert to celsius/fahrenheit, display on console and LCD.
    var tempSensor = analogPin0.read(); //read the value of the analog pin
    var resistance = (1023 - tempSensor) * 10000 / tempSensor; //get the resistance of the sensor;
    var celsius_temperature = 1 / (Math.log(resistance / 10000) / B + 1 / 298.15) - 273.15; //convert to temperature via datasheet ;
    var fahrenheit_temperature = (celsius_temperature * (9 / 5)) + 32;
    display_temp = fahrenheit_temperature;   // Change this to celsius_temperature if you wish
    
    
    display.setCursor(0,0);
    display.write('Temp: ' + display_temp);  
    console.log('Temp: ' + display_temp);
    setTimeout(read_display,delay);
    
}

Credits

Pete Hoffswell

Pete Hoffswell

3 projects • 58 followers
Network Engineer for All the People. Internet advocate. Microcontroller Fan. Maker.

Comments

Add projectSign up / Login