Salt Warehouses Monitoring with Arduino & Artik Cloud

Salt Warehouses Monitoring with Arduino & Artik Cloud © Apache-2.0

In this Article i will demonstrate how to connect Arduino MKR1000 with Artik Cloud & monitor salt/Dairy warehouses Temperature & Humidity.

  • 1,501 views
  • 0 comments
  • 5 respects

Components and supplies

Apps and online services

About this project

Background

Humidity & Temperature Monitoring is very important factor in Salt/Dairy warehouses. Instead of taking manual readings from Digital meters I plan to make a device which will automatically stream real time statistics of warehouses to Artik cloud. By this way we can get real time result any where any time and take decisions on time to save products from damage.

Prerequisites

You must have basic knowledge about programming Arduino MKR1000. Also you need Artik Cloud (Samsung) account. For Arduino IDE, libraries WiFi101 and ArduinoJSON are required.

Basics of Artik Cloud

1-Create a account at https://artik.cloud/

2- Login to https://developer.artik.cloud/ and click on Dashboard

3- Now click on New button for Device Types to Create new device type

Enter Device Name & Unique Name and click on Create Device Type button

4-Click on Create Manifest button to Create Manifest for Device in this we need to create 2 fields Temperature & Humidity.

Click on Save and create new field for humidity again.

5- After creating fields for devices click on "Next" button to create Device Actions and then "Next" and then click on "Activate Manifest" button to save all the settings. Now we need to connect Device with Device Type. to connect device go to https://artik.cloud/my/devices URL and click on "Connect Another Device"

6- Search your Device in case of this Article our Device Name is "Warehouse Device"

7- Select the Device and click on "Connect Device" button

8- Now you can see all of your connected Devices and also "Warehouse Device".

9- Click on "Warehouse Device" Setting Icon to get the Device ID & Device Token. For Device Token first time you need to click on Generate Device Token.

10- Now Device setup has been completed you can use Device ID & Device Token in your Arduino Code and start streaming your data to Artik Cloud but from where we can view the streamed data hmmm. for you need to click on "Warehouse Device" and you can see the live result & old result by changing the date & time.

This picture will show the Arduino MKR1000 & DHT22 device connection. if you already not familiar with DHT22 & Arduino please read the Temperature Monitoring With DHT22 & Arduino Article

Below video will also demonstrate the complete Artik Cloud setup and device connection.

Code

Artik_Cloud.inoC/C++
Connecting Arduino MKR1000 to Artik Cloud and send DHT22 reading to Cloud.
#include <WiFi101.h>
#include <DHT.h>
#include <ArduinoJson.h>

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

String AuthorizationData = "Authorization: Bearer ---------------Replace with Deivce Token-----------------"; //device token

//float insTemp;
char buf[200];
#define LED 7
int ledState = 0;

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

#define DHTPIN 6    // what pin we're connected to, pin1 is 5th pin from end
#define DHTTYPE DHT22  // DHT 22
DHT dht(DHTPIN,DHTTYPE);

void setup() {

  pinMode(LED,OUTPUT);

  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 {
      float t = dht.readTemperature();
      float h = dht.readHumidity();
      Serial.println("Sending data"+String(t));
      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(t,h)); // loads buf, returns length
       client.println();
       client.println(buf);
       Serial.println(buf);
       Serial.println("Data posted");
       client.stop();       
  }
 
  delay(1*60*1000); // delay 2 min

}

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

   JsonObject& root = jsonBuffer.createObject(); // create root objects
     root["sdid"] = "------------------Replace with Deivice ID-------"; // FIX Device ID
     root["type"] = "message";

   JsonObject& dataPair = root.createNestedObject("data"); // create nested objects
     dataPair["temp"] = insTemp;  
     dataPair["Humidity"] = 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

Design
MKR1000%20with%20DHT22.fzz

Comments

Similar projects you might like

Temperature Monitoring with Arduino MKR1000 and ARTIK Cloud

Project tutorial by Team FoxLab

  • 7,511 views
  • 2 comments
  • 31 respects

Water Quality Monitoring Using MKR1000 and ARTIK Cloud

Project tutorial by Team Animo!

  • 7,075 views
  • 12 comments
  • 30 respects

Send Tweets Using Arduino with Artik Cloud

Project tutorial by Jasper

  • 1,696 views
  • 0 comments
  • 9 respects

Arduino MKR1000 - DHT - Artik cloud

by Team MAKERS-NS

  • 4,298 views
  • 2 comments
  • 20 respects

Temperature Logger With Arduino And Artik Cloud

Project tutorial by RAFI RASHEED T C

  • 1,949 views
  • 1 comment
  • 7 respects

AirLock with Artik Cloud

Project tutorial by Akash Ravichandran and Prabhakaran Senthilnathan

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