Using STONE Display Make Clock and Home Automation

Contents

  1. Description
  1. GUI design

3 .Circuit Diagram

  1. Code
  2. Video

 

Description

In this project we are going to design a clock and a automation system with this help we can switch ON or OFF the home light and there is also clock which will show the time and date .

For this we are using TFT display (STONE-HMI), this display has a software that is a GUI software with this help we are going to design interface which will contain both section clock and automation.Download the GUI software click here

Clock part designing :-

Let’s first design the clock part ,first we have to add all the images which are given in the folder click here .

As  you can see in the left side all images have added in the section of picture file.Now click on image ‘14’ you will get this interface as you seeing in the image.Now select ‘RTC’ from touch configuration for setting the time and date and do all the configuration for this first add ‘in the page’ image as image number 6 which will be use at the time of setting.Now go to image number 6 and add all the buttons and their keys values.these value will be in this format.

For ‘1’ —  0031

For ‘2’ —  0031

For ‘3’ —  0031

For ‘4’ —  0031

For ‘5’ —  0031

For ‘6’ —  0031

For ‘7’ —  0031

For ‘8’ —  0031

For ‘9’ —  0031

For ‘0’ —  0030

For ‘OK’– 00F1

After that add button effect as image nimber-7 for all the buttons so by this part will be done to settings up the clock.let’s move further to create a hands of clock.

Similarly add Dial clock from top and add all the ,hour,minute and second hand for this first we have to make icon for these hands so for this go to the icon generator and select these images you will find the a new folder in the section of ‘icon file’ from here you have to select all icon according to the hand requirements.After that select all the icon according to clock hands requirements,and don’t forget to select the center of each hands for the clock,with this procedure this will be done now we have to go for automation part and for this we have added a automation symbol as you can see in the above image,for this select button and put that button in the area of this automaton icon and then select the ‘page switch’ as image-1 because this is the image for automation after that select image-1 for further designing.

Automation part designing :-

Let’s design automation part for this we required Arduino to send particular key value over a address,here we are using ‘0001’ for all the key value.For Fan(ON) button we are sending ‘0001’ key value and for Fan(OFF) we are sending ‘0002’ key value similarly we are sending for all the particular value for all the appliances.Here we also added a button to switch to clock GUI which will help to move from this interface to clock interface.

For the page switch we are using ‘button’ which is placed on left top and for automation button we are using ‘return press key value’ function which has two parameter first is address value and another is key value as we have mentioned above we are using different different key value for each automation button.

Circuit Diagram

 

As you  can see in the connection there are three LEDs light-1,light-2 and for Fan here we are using only LEDs but you can connect actual appliances to this.Light-1 connect to the pin -D6 of Arduino ,light-2 connect to the pin-D7 of Arduino,similar Fan connect with D5 with Arduino.And do the connection for Rx and Tx as per the circuit diagram.Here we have connected Tx with pin-2 and Rx with pin-3 of Arduino as per the Arduino code.Let’s move further  how it’s working with the code.

There are different types of Serial Communications. When you use an Arduino board on a project you can choose the standard Serial pins as Arduino software serial Rx Tx, from the UART inside the Arduino board, so it is called Serial TTL. In that case, we are using the Hardware serial.h Library, but some additional pins can work as an Rx or Tx. For example, the SPI communication pins can work as a MISO, MOSI and Select (SC), but they are also pins that can work as a digital input or digital output, or if you need you could use those pins as Rx, Tx using the softwareserial.h Library. 

Let’s move further to know how code is working. 

 

Code :- 

 

#include <SoftwareSerial.h>              //software serial library

SoftwareSerial max232(2,3);

char data; 

String mystring;

int f = 5;                                 // Pin for Fan

int l1 = 6;         // Pin for light-1

int l2 = 7;                          // Pin for light-2

void setup()

{

Serial.begin(115200);                //Here Baudrate is 115200

max232.begin(115200);

pinMode(f, OUTPUT);     

digitalWrite(f, LOW); 

pinMode(l1, OUTPUT);    

digitalWrite(l1, LOW);

pinMode(l2, OUTPUT);    

digitalWrite(l2, LOW);

}

void loop()

{

if (max232.available()>0)

 {

   data = max232.read();

   mystring = mystring + byte(data) ; 

   delay(10);

 }

else if (mystring.endsWith(“101”)) //condition for Fan ON

  {

    mystring = “”; 

   digitalWrite(f,HIGH);

  

  }

else if  (mystring.endsWith(“102”)) //condition for Fan OFF

  {

   mystring = “”; 

   digitalWrite(f,LOW);

  }

else if  (mystring.endsWith(“103”)) //condition for Light-1 ON

  {

  mystring = “”; 

  digitalWrite(l1,HIGH);

  }

else if  (mystring.endsWith(“104”)) //condition for Light-1 OFF

  {

   mystring = “”; 

   digitalWrite(l1,LOW);

  }

else if  (mystring.endsWith(“105”)) //condition for Light-2 ON

  {

  mystring = “”; 

  digitalWrite(l2,HIGH);

  }

else if  (mystring.endsWith(“106”)) //condition for Light-2 OFF

  {

   mystring = “”; 

   digitalWrite(l2,LOW);

  }

else if  (mystring.endsWith(“107”)) //condition for All appliances ON

  {

   mystring = “”; 

   digitalWrite(l1,HIGH);

   digitalWrite(l2,HIGH);

   digitalWrite(f,HIGH);

  }

else if  (mystring.endsWith(“108”)) //condition for All appliances OFF

  {

   mystring = “”; 

   digitalWrite(l1,LOW);

   digitalWrite(l2,LOW);

   digitalWrite(f,LOW);

  }

}

Working :-

As we have discussed we are using software-serial library to transfer the key value over a address,for this we have added  <SoftwareSerial.h>    in this code this giving the interface to connect Arduino and STON-HMI display.After that we have declare all the output pin whatever we are using for the LEDs and Fan,for these devices we have declare these Pins as OUTPUT then set the Baud rate for the software-serial library.these all done in the void setup part now let’s move to make the condition for the devices we are using ,this part is added in the void loop because this is going to repeat many times as we will press the button on the display.

In the void loop section there are four condition for the devices.First condition is for Fan on and off here we are sending ‘0001’ key value for the ON condition and ‘0002’ for off condition over the address ‘0001’ this address is same for all the devices.For second device that is for light-1 we are sending ‘0003’ for ON condition and ‘0004’ for off condition,similarly for light-2 ‘0005’ for ON and ‘0006 ‘ for off condition so in this way these conditions are working for individual device.

There are one more condition for to switch OFF or switch ON all devices at once for this we are using ‘0007’ for ON & ‘0008’ for the OFF.

 

Output Video :-

This is the output video of this project in this video first showing the setup of clock and there is working of automation as you ca see in the video.

This is the output video you can download by click on that video.we have added all the data related to this if you have any doubt about GUI designing you can download the project file and open it directly in this case you don’t have to design any GUI you will get that design which we have built. But if you want to design different GUI then you have to follow all the steps.

 

Code

//For more information about this project visit:- wwww.electrocircuit.net //

#include <SoftwareSerial.h>

SoftwareSerial max232(2,3);

char data; 

String mystring;

int f = 5; 

int l1 = 6; 

int l2 = 7;  

void setup()

{

Serial.begin(115200); 

max232.begin(115200);

 

pinMode(f, OUTPUT);      /////////RED////////

digitalWrite(f, LOW); 

 

pinMode(l1, OUTPUT);      ////////GREEN///////

digitalWrite(l1, LOW);

 

pinMode(l2, OUTPUT);     ///////BLUE/////////

digitalWrite(l2, LOW);

}

void loop()

{

if (max232.available()>0)

 {

   data = max232.read();

   mystring = mystring + byte(data) ; 

   delay(10);

 }

 

else if (mystring.endsWith(“101”))

  {

    mystring = “”; 

   digitalWrite(f,HIGH);

  

  }

else if  (mystring.endsWith(“102”))

  {

   mystring = “”; 

   digitalWrite(f,LOW);

  }

else if  (mystring.endsWith(“103”))

  {

  mystring = “”; 

  digitalWrite(l1,HIGH);

  }

else if  (mystring.endsWith(“104”))

  {

   mystring = “”; 

   digitalWrite(l1,LOW);

  }

else if  (mystring.endsWith(“105”))

  {

  mystring = “”; 

  digitalWrite(l2,HIGH);

  }

else if  (mystring.endsWith(“106”))

  {

   mystring = “”; 

   digitalWrite(l2,LOW);

  }

else if  (mystring.endsWith(“107”))

  {

   mystring = “”; 

   digitalWrite(l1,HIGH);

   digitalWrite(l2,HIGH);

   digitalWrite(f,HIGH);

  }

else if  (mystring.endsWith(“108”))

  {

   mystring = “”; 

   digitalWrite(l1,LOW);

   digitalWrite(l2,LOW);

   digitalWrite(f,LOW);

  }

}

 

Leave a Comment