Project tutorial
Temperature Logger With Arduino And Artik Cloud

Temperature Logger With Arduino And Artik Cloud © GPL3+

Sending temperature from Arduino MKR1000 to Artik Cloud.

  • 1,952 views
  • 1 comment
  • 7 respects

Components and supplies

Apps and online services

About this project

Hi,

In this project find temperature using LM35 ic and post data into artik cloud.

The LM35 series are precision integrated-circuit temperature devices with an output voltage linearly-proportional to the Centigrade temperature read more

Artik cloud:

Samsung ARTIK gives you tools to reduce your IoT product development timelines, getting your product to market faster. Our end-to-end ecosystem strategy means you don’t have to develop your own modules, network stack, or cloud on-boarding. for more.

You can find many tutorial about Artik in hackster.io.

Step 1:

First create a free Artik Cloud account .CLICK HERE

  • After that Open Developers portal
  • then Click on Device type from the Dashboard menu
  • click Create Device type and Create a new device .

After creating a device we need some information to connect with Artik cloud.

For that click on the small gear (Settings) icon on the near the device name and a pop-up will come. Click ongenerate device token and you will get a token. Copy the Device ID and the Device Token for later use.

Code:

Next we are doing code to Take temperature and post temperature details in ARTIK cloud.

Code to take temperature using LM35:

int val; 
int tempPin = 9; // temperature pin  
void setup() 
{ 
Serial.begin(9600); 
} 
void loop() 
{ 
val = analogRead(tempPin); //read analog data  
float mv = ( val/1024.0)*;  //FInd temperature  
float cel = mv/10;          //convert in to celsius  
float farh = (cel*9)/5 + 32; //convert in to fahrenheat (optional)  
Serial.print("TEMPRATURE = "); 
Serial.print(cel); 
Serial.print("*C"); 
Serial.println(); 
delay(1000); 
} 

After that we post this data into ARTIK cloud in a fixed interval. For that following have a code please checkout that. After uploading Go to ARTIK cloud and check all is fine.

You can find your data by simply go to here.

At last check this working video:

Thank you :) for watching my tutorial!

Code

TEMP_ARTIK.inoArduino
Used to detect temperature in LM35 and send in to ARTIKcloud ,
#include <WiFi101.h>
#include <ArduinoJson.h>
int temp = 9; //temperature pin
int val;

// Web REST API params
char server[] = "api.artik.cloud";  
int port = 443; //(port 443 is default for HTTPS)

String AuthorizationData = "Authorization: Bearer  <YOUR DEVICE TOKEN>";


char buf[200];
int LED = 6;
int ledState = 0;

WiFiSSLClient client;
char ssid[] = "YOUR SSID";      //  your network SSID (name)
char pass[] = "YOUR PASSWORD";
int status = WL_IDLE_STATUS;

void setup() {

  pinMode(LED,OUTPUT);
  pinMode(temp, INPUT); // LM35 pin

  Serial.begin(9600);
  while (status != WL_CONNECTED){
    Serial.println("Attempting to connect to WiFi");
    status = WiFi.begin(ssid,pass);
  }
  Serial.println("connected to WiFi ");
  
}
  
void loop() {
  Serial.println("loop");
  ledToggle();
  client.connect(server, port);
  delay(1000);
  if (!client.connected()) { 
    Serial.println(" error ");
  } else {
      //int t = dht.readTemperature();
      //int h = dht.readHumidity();
      val = analogRead(temp);
float mv = ( val/1024.0)*5000; //FInd temperature
float cel = mv/100;            //convert in to celsius 
float farh = (cel*9)/5 + 32;   //convert in to fahrenheat (optional) 
      Serial.println("Sending data"+String(cel)); // sending data 
      client.println("POST /v1.1/messages HTTP/1.1");
      client.println("Host: api.artik.cloud");
      client.println("Accept: */*");
      client.println("Content-Type: application/json");
      client.println("Connection: close");
      client.println(AuthorizationData);

       // Automated POST data section
       client.print("Content-Length: ");
       client.println(loadBuffer(cel,farh)); // loads buf, returns length
       client.println();
       client.println(buf);
       Serial.println("Data posted");
       client.stop();       
  }
 
  delay(3*60*1000); // setting delay foe 3 minutes 

}

int loadBuffer(int insTemp, int insHumid ) {  
   StaticJsonBuffer<200> jsonBuffer; // reserve spot in memory

   JsonObject& root = jsonBuffer.createObject(); // create root objects
     root["sdid"] = "<YOUR DEVICE ID>"; // FIX 
     root["type"] = "message";

   JsonObject& dataPair = root.createNestedObject("data"); // create nested objects
     dataPair["temp"] = insTemp;  
     dataPair["humid"] = insHumid;

   root.printTo(buf, sizeof(buf)); // JSON-print to buffer

   return (root.measureLength()); // also return length
 }

 void ledToggle(){
  if (ledState == 0){
    digitalWrite(LED,LOW);
    ledState = 1;
  } else {
    digitalWrite(LED,HIGH);
    ledState = 0;
  }
 }

Schematics

ARDUINO_PIN_CONNECTION
Arduinomkr1000v2 bb

Comments

Similar projects you might like

Monitor Fire and Temperature Using ARTIK Cloud

Project tutorial by Samsung IoT

  • 2,585 views
  • 0 comments
  • 21 respects

Temperature Monitoring with Arduino MKR1000 and ARTIK Cloud

Project tutorial by Team FoxLab

  • 7,514 views
  • 2 comments
  • 31 respects

Water Quality Monitoring Using MKR1000 and ARTIK Cloud

Project tutorial by Team Animo!

  • 7,077 views
  • 12 comments
  • 30 respects

Send Tweets Using Arduino with Artik Cloud

Project tutorial by Jasper

  • 1,579 views
  • 0 comments
  • 9 respects

AirLock with Artik Cloud

Project tutorial by Akash Ravichandran and Prabhakaran Senthilnathan

  • 2,830 views
  • 0 comments
  • 9 respects
Add projectSign up / Login