본문 바로가기
Development/WIZnet

The temperture monitering using Exosite Cloud

by 루카오리 2014. 11. 24.


ExositeTemperatureMonitor.ino

요새들어 IoT를 위해  클라우드 플랫폼이 많아졌다.

아직까지는 시험중인 것인지 무료로 배포하는 클라우드 플랫폼이 다 많은 것 같다.

내가 사용해본 것은 xively(링크) 와 exosite(링크) 이다. 더 많은 서비스가 존재하나, 이 두개로도 충분한 비교가 가능하여 두가지만 사용한다.


xively는 이전의 포스터(링크)에 사용방법이 있다.

현 포스터에는 exosite 사용방법을 설명하고자한다.


사용제품 및 프로그램


(사용된 온도센서와 Fritzing에서 사용된 온도센서는 다른것입니다.)

Arduino Sketch 수정

     
    #include <EEPROM.h>
    #include <SPI.h>
    #include <Ethernet.h>
    #include <Exosite.h>
    #include <dht11.h>
    dht11 DHT; 
    // Pin use
    //#define ONEWIRE 6 //pin to use for One Wire interface
    #define tempPin 6
    // Set up which Arduino pin will be used for the 1-wire interface to the sensor
     
    /*==============================================================================
    * Configuration Variables
    *
    * Change these variables to your own settings.
    *=============================================================================*/
    String cikData = "877f39f3b116289741ee112005df39c8dfe6ed0e";  // <-- FILL IN YOUR CIK HERE! (https://portals.exosite.com -> Add Device)
    byte macData[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};        // <-- FILL IN YOUR Ethernet shield's MAC address here.
    IPAddress ip(192, 168, 13, 5);
    
    // User defined variables for Exosite reporting period and averaging samples
    #define REPORT_TIMEOUT 300 //milliseconds period for reporting to Exosite.com
    #define SENSOR_READ_TIMEOUT 500 //milliseconds period for reading sensors in loop
    
    
    /*==============================================================================
    * End of Configuration Variables
    *=============================================================================*/
    
    class EthernetClient client;
    Exosite exosite(cikData, &client);
    
    //
    // The 'setup()' function is the first function that runs on the Arduino.
    // It runs completely and when complete jumps to 'loop()' 
    //
    void setup() {
      Serial.begin(9600);
      Serial.println("Boot");
      // Start up the OneWire Sensors library
      delay(1000);
      Serial.println("Starting Exosite Temp Monitor");
     Ethernet.begin(macData,ip);
       // wait 3 seconds for connection
      delay(3000); 
     
    }
     
    //
    // The 'loop()' function is the 'main' function for Arduino 
    // and is essentially a constant while loop. 
    //
    void loop() {
      static unsigned long sendPrevTime = 0;
      static unsigned long sensorPrevTime = 0; 
      //static float tempF;
      char buffer[7];
      String readParam = "";
      String writeParam = "";
      String returnString = "";  
      int tempC =0;
      Serial.print("."); // print to show running
     
     // Read sensor every defined timeout period
      if (millis() - sensorPrevTime > SENSOR_READ_TIMEOUT) {
        Serial.println();
        Serial.println("Requesting temperature...");
        int sensor_val = DHT.read(tempPin);
        tempC=  DHT.temperature;
        Serial.print("Temp:    ");
        Serial.print(tempC);
        Serial.println(" C ..........DONE");
    
        sensorPrevTime = millis();
      }
     
      // Send to Exosite every defined timeout period
      if (millis() - sendPrevTime > REPORT_TIMEOUT) {
        Serial.println(); //start fresh debug line
        Serial.println("Sending data to Exosite...");
        
        readParam = "";        //nothing to read back at this time e.g. 'control&status' if you wanted to read those data sources
        writeParam = "temp="; //parameters to write e.g. 'temp=65.54' or 'temp=65.54&status=on'
        writeParam += tempC;
           
        if ( exosite.writeRead(writeParam, readParam, returnString)) {
          Serial.println("Exosite OK");
          if (returnString != "") {
            Serial.println("Response:");
            Serial.println(returnString);
          }
        }
        else {
          Serial.println("Exosite Error");
        }
     
        sendPrevTime = millis(); //reset report period timer
        Serial.println("done sending.");
      }
      delay(1000); //slow down loop
    }  

exosite device 사용

 1. http://portals.exosite.com/ 에 접속한다

 2. 로그인은 한 후 오른쪽에 Add widget 을 클릭한다.

3. Widget Type을 고르고 Block Title(ex.Ultra) 을 적은후 빠져나온다.

 4. 왼쪽바에 Data  를 클릭해서 VBlock Title로 적었던 이름을 클릭한다.

5. CIK의 값을 아두이노 스케치에 작성해야한다. 

 6. clkDate에 CIK를 그대로 복사해서 넣는다.

 

결과

temperture resulttemperture result