Swapnil Kalhapure
Published © MIT

Ivy Suite - A Home Automation Kit for Artik Cloud

An open Source hardware suite for Artik Cloud, that aims at extending the support of Artik Cloud to devices that aren't compatible.

AdvancedWork in progress18 hours1,153
Ivy Suite - A Home Automation Kit for Artik Cloud

Things used in this project

Hardware components

ESP8266 ESP-01
Espressif ESP8266 ESP-01
×3
NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
SparkFun USB to Serial Breakout - FT232RL
SparkFun USB to Serial Breakout - FT232RL
×1
Solid State Relay
Solid State Relay
×1

Software apps and online services

Arduino IDE
Arduino IDE
ARTIK Cloud for IoT
Samsung ARTIK Cloud for IoT

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Smart Button

Fritzing project for smart button

Smart Bulb

Fritzing project for smart Bulb

Smart Reader

Fritzing project for smart reader

Smart Switch

fritzing project for smart switch

Github repository

Code

Smart Button

Arduino
Smart Button
#include <MQTTClient.h>

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>

const char* _SSID     = "----------------"; //Wi-Fi SSID 
const char* _PASSWORD = "----------------"; // Wi-Fi Password 


// MQTT - Artik Cloud Server params
char Artik_Cloud_Server[]     = "api.artik.cloud"; // Server 
int  Artik_Cloud_Port         = 8883; // MQTT Port
char Client_Name[] = "----------------"; // Any Name 
char Device_ID[]   = "----------------"; // DEVICE ID
char Device_TOKEN[]   = "----------------"; //  DEVICE TOKEN
char MQTT_Publish[]      = "/v1.1/messages/DEVICE_ID_GOES_HERE"; // (/v1.1/messages/"DEVICE ID")
char MQTT_Sub[]      = "/v1.1/actions/DEVICE_ID_GOES_HERE"; // (/v1.1/actions/<DEVICE ID>)

char buf[200]; // Json Data to Artik Cloud 

WiFiClientSecure SSL_ESP; // ESP SSL Connection to Artik cloud 

MQTTClient MQTT_Artik_Client; // MQTT Protocol



/*********************************************************************************************************


Sample msg fields

	{
	"button1":true
	}


Sample action fields

	{
	"actions":	[{	
					"name":"Vibration",
		    		"parameters":{
		    						"vibe":true
		    			 		 }
				}]
	}

**********************************************************************************************************/



void setup() {
  pinMode(2,INPUT);
  pinMode(0,OUTPUT);
  delay(1000);
  Serial.begin(115200);  
  // Wifi Setting
  WiFi.begin(_SSID, _PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  
  MQTT_Artik_Client.begin(Artik_Cloud_Server, Artik_Cloud_Port, SSL_ESP); // Connect to Artik Server
  
  while (!MQTT_Artik_Client.connect(Client_Name, Device_ID, Device_TOKEN)) { // Connect to Artik IOT Device 
    Serial.print("*");
    delay(1000);
  }
}

void loadBuffer(int buttonState) {
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& dataPair = jsonBuffer.createObject();
  dataPair["button1"] = buttonState ;
  dataPair.printTo(buf, sizeof(buf));
  Serial.println(buf);
}


void loop() {
  int buttonState = digitalRead(2);// gpio2 has the button

  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // went from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes:  ");
      Serial.println(buttonPushCounter);
    } else {
      // went from on to off:
    loadBuffer(buttonState);  // Publishing data list 
    delay(1000);  
    }
    delay(50);
  }
  lastButtonState = buttonState;

  
  
  MQTT_Artik_Client.publish(MQTT_Publish, buf);// Publishing data to the Artik Cloud 
  delay(3000);
  Serial.println("Publishing..");     
  for (int i =0; i<100;i++){ // delay 10 Mnts ( as per Artik Free package specifications) 
    delay(6000);
  }  

  MQTT_Artik_Client.subscribe(MQTT_Sub);
  // MQTT_Artik_Client.unsubscribe(MQTT_Sub);


  void messageReceived(String topic, String payload, char * bytes, unsigned int length) {
  Serial.print("incoming: ");
  Serial.print(topic);
  Serial.print(" - ");
  Serial.print(payload);
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& root = jsonBuffer.parseObject(payload);
  boolean state = root["actions"]["parameters"]["vibe"];
  if(state)
  {
   digitalWrite(0,HIGH);//turn on vibrator
   delay(1000);
   digitalWrite(0,LOW);//turn off vibrator
  }
  Serial.println();
}


  MQTT_Artik_Client.loop();
  delay(10); 
}

Smart Bulb

Arduino
Smart Bulb
#include <MQTTClient.h>

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>

const char* _SSID     = "----------------"; //Wi-Fi SSID 
const char* _PASSWORD = "----------------"; // Wi-Fi Password 


// MQTT - Artik Cloud Server params
char Artik_Cloud_Server[]     = "api.artik.cloud"; // Server 
int  Artik_Cloud_Port         = 8883; // MQTT Port
char Client_Name[] = "----------------"; // Any Name 
char Device_ID[]   = "----------------"; // DEVICE ID
char Device_TOKEN[]   = "----------------"; //  DEVICE TOKEN
char MQTT_Publish[]      = "/v1.1/messages/DEVICE_ID_GOES_HERE"; // (/v1.1/messages/"DEVICE ID")
char MQTT_Sub[]      = "/v1.1/actions/DEVICE_ID_GOES_HERE"; // (/v1.1/actions/<DEVICE ID>)

char buf[200]; // Json Data to Artik Cloud 

WiFiClientSecure SSL_ESP; // ESP SSL Connection to Artik cloud 

MQTTClient MQTT_Artik_Client; // MQTT Protocol



/*********************************************************************************************************


Sample msg fields

{
  "state":true
}

Sample action fields

{
  "actions":[{
              "name":"toggle",
              "parameters":{
                            "toggle":true
                            }
            }]
}

**********************************************************************************************************/



void setup() {
  pinMode(2,OUTPUT);
  delay(1000);
  Serial.begin(115200);  
  // Wifi Setting
  WiFi.begin(_SSID, _PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  
  MQTT_Artik_Client.begin(Artik_Cloud_Server, Artik_Cloud_Port, SSL_ESP); // Connect to Artik Server
  
  while (!MQTT_Artik_Client.connect(Client_Name, Device_ID, Device_TOKEN)) { // Connect to Artik IOT Device 
    Serial.print("*");
    delay(1000);
  }
}

void loadBuffer(String state) {
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& dataPair = jsonBuffer.createObject();
  dataPair["state"] = state ;
  dataPair.printTo(buf, sizeof(buf));
  Serial.println(buf);
}


void loop() {
  MQTT_Artik_Client.subscribe(MQTT_Sub);
  // MQTT_Artik_Client.unsubscribe(MQTT_Sub);

  void messageReceived(String topic, String payload, char * bytes, unsigned int length) {
  Serial.print("incoming: ");
  Serial.print(topic);
  Serial.print(" - ");
  Serial.print(payload);
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& root = jsonBuffer.parseObject(payload);
  boolean state = root["actions"]["parameters"]["toggle"];
  if(state)
  {
  digitalWrite(2,HIGH);
  loadBuffer(state);  // Publishing data list   
  MQTT_Artik_Client.publish(MQTT_Publish, buf);// Publishing data to the Artik Cloud 
  delay(3000);
  Serial.println("Publishing..");     
  for (int i =0; i<100;i++){ // delay 10 Mnts ( as per Artik Free package specifications) 
    delay(6000);
  }
  else 
  {
  digitalWrite(2,LOW);
  loadBuffer(state);  // Publishing data list   
  MQTT_Artik_Client.publish(MQTT_Publish, buf);// Publishing data to the Artik Cloud 
  delay(3000);
  Serial.println("Publishing..");     
  for (int i =0; i<100;i++){ // delay 10 Mnts ( as per Artik Free package specifications) 
  delay(6000);
  }  
   
  }
  
}

  MQTT_Artik_Client.loop();
  delay(10); 
}

Smart Reader

Arduino
Smart Reader
#include <MQTTClient.h>

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <Wire.h>
#include "rgb_lcd.h"


const char* _SSID     = "----------------"; //Wi-Fi SSID 
const char* _PASSWORD = "----------------"; // Wi-Fi Password 


// MQTT - Artik Cloud Server params
char Artik_Cloud_Server[]     = "api.artik.cloud"; // Server 
int  Artik_Cloud_Port         = 8883; // MQTT Port
char Client_Name[] = "----------------"; // Any Name 
char Device_ID[]   = "----------------"; // DEVICE ID
char Device_TOKEN[]   = "----------------"; //  DEVICE TOKEN
char MQTT_Publish[]      = "/v1.1/messages/DEVICE_ID_GOES_HERE"; // (/v1.1/messages/"DEVICE ID")
char MQTT_Sub[]      = "/v1.1/actions/DEVICE_ID_GOES_HERE"; // (/v1.1/actions/<DEVICE ID>)

char buf[200]; // Json Data to Artik Cloud 

WiFiClientSecure SSL_ESP; // ESP SSL Connection to Artik cloud 

MQTTClient MQTT_Artik_Client; // MQTT Protocol


rgb_lcd lcd;



/*********************************************************************************************************


Sample msg fields

{	
	"state":"Present string on the display"
}


Sample actions fields

{
	"actions":[{
				"name":"setValue",
				"parameters":{
								"string":"String to be displayed"
							  }
				}]
}

**********************************************************************************************************/



void setup() {
  delay(1000);
  lcd.begin(16, 2);
  Serial.begin(115200);  
  // Wifi Setting
  WiFi.begin(_SSID, _PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  
  MQTT_Artik_Client.begin(Artik_Cloud_Server, Artik_Cloud_Port, SSL_ESP); // Connect to Artik Server
  
  while (!MQTT_Artik_Client.connect(Client_Name, Device_ID, Device_TOKEN)) { // Connect to Artik IOT Device 
    Serial.print("*");
    delay(1000);
  }
}

void loadBuffer(string state) {
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& dataPair = jsonBuffer.createObject();
  dataPair["state"] = buttonState ;
  dataPair.printTo(buf, sizeof(buf));
  lcd.setCursor(0, 1);
  lcd.print(state);
  Serial.println(buf);
}


void loop() {
  loadBuffer("Hello there");  // Publishing data list 
  delay(1000);  
  
  MQTT_Artik_Client.publish(MQTT_Publish, buf);// Publishing data to the Artik Cloud 
  delay(3000);
  Serial.println("Publishing..");     
  for (int i =0; i<100;i++){ // delay 10 Mnts ( as per Artik Free package specifications) 
    delay(6000);
  }  

  MQTT_Artik_Client.subscribe(MQTT_Sub);
  // MQTT_Artik_Client.unsubscribe(MQTT_Sub);


  void messageReceived(String topic, String payload, char * bytes, unsigned int length) {
  Serial.print("incoming: ");
  Serial.print(topic);
  Serial.print(" - ");
  Serial.print(payload);
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& root = jsonBuffer.parseObject(payload);
  String state = root["actions"]["parameters"]["string"];
  loadBuffer(state);  // Publishing data list 
  delay(1000);  
  MQTT_Artik_Client.publish(MQTT_Publish, buf);// Publishing data to the Artik Cloud 
  delay(3000);
  Serial.println("Publishing..");     
  for (int i =0; i<100;i++){ // delay 10 Mnts ( as per Artik Free package specifications) 
    delay(6000);
  }  
}

  MQTT_Artik_Client.loop();
  delay(10); 
}

Smart socket

Arduino
Smart socket
#include <MQTTClient.h>

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>

const char* _SSID     = "----------------"; //Wi-Fi SSID 
const char* _PASSWORD = "----------------"; // Wi-Fi Password 


// MQTT - Artik Cloud Server params
char Artik_Cloud_Server[]     = "api.artik.cloud"; // Server 
int  Artik_Cloud_Port         = 8883; // MQTT Port
char Client_Name[] = "----------------"; // Any Name 
char Device_ID[]   = "----------------"; // DEVICE ID
char Device_TOKEN[]   = "----------------"; //  DEVICE TOKEN
char MQTT_Publish[]      = "/v1.1/messages/DEVICE_ID_GOES_HERE"; // (/v1.1/messages/"DEVICE ID")
char MQTT_Sub[]      = "/v1.1/actions/DEVICE_ID_GOES_HERE"; // (/v1.1/actions/<DEVICE ID>)

char buf[200]; // Json Data to Artik Cloud 

WiFiClientSecure SSL_ESP; // ESP SSL Connection to Artik cloud 

MQTTClient MQTT_Artik_Client; // MQTT Protocol



/*********************************************************************************************************


Sample msg fields

{
  "state":true
}

Sample action fields

{
  "actions":[{
              "name":"toggle",
              "parameters":{
                            "toggle":true
                            }
            }]
}


**********************************************************************************************************/



void setup() {
  pinMode(0,OUTPUT);
  delay(1000);
  Serial.begin(115200);  
  // Wifi Setting
  WiFi.begin(_SSID, _PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  
  MQTT_Artik_Client.begin(Artik_Cloud_Server, Artik_Cloud_Port, SSL_ESP); // Connect to Artik Server
  
  while (!MQTT_Artik_Client.connect(Client_Name, Device_ID, Device_TOKEN)) { // Connect to Artik IOT Device 
    Serial.print("*");
    delay(1000);
  }
}

void loadBuffer(String state) {
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& dataPair = jsonBuffer.createObject();
  dataPair["state"] = state ;
  dataPair.printTo(buf, sizeof(buf));
  Serial.println(buf);
}


void loop() {
  MQTT_Artik_Client.subscribe(MQTT_Sub);
  // MQTT_Artik_Client.unsubscribe(MQTT_Sub);

  void messageReceived(String topic, String payload, char * bytes, unsigned int length) {
  Serial.print("incoming: ");
  Serial.print(topic);
  Serial.print(" - ");
  Serial.print(payload);
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& root = jsonBuffer.parseObject(payload);
  boolean state = root["actions"]["parameters"]["toggle"];
  if(state)
  {
  digitalWrite(0,HIGH);
  loadBuffer(state);  // Publishing data list   
  MQTT_Artik_Client.publish(MQTT_Publish, buf);// Publishing data to the Artik Cloud 
  delay(3000);
  Serial.println("Publishing..");     
  for (int i =0; i<100;i++){ // delay 10 Mnts ( as per Artik Free package specifications) 
    delay(6000);
  }  
   else
   {
    digitalWrite(0,LOW);
    loadBuffer(state);  // Publishing data list   
    MQTT_Artik_Client.publish(MQTT_Publish, buf);// Publishing data to the Artik Cloud 
    delay(3000);
    Serial.println("Publishing..");     
    for (int i =0; i<100;i++){ // delay 10 Mnts ( as per Artik Free package specifications) 
    delay(6000);
    }
  }
  
}

  MQTT_Artik_Client.loop();
  delay(10); 
}

Credits

Swapnil Kalhapure

Swapnil Kalhapure

4 projects • 10 followers
A hobby roboticist and a tech. enthusiast constantly learning and enjoying open source hardware. Love to reverse engineer and put different technologies to test

Comments