Sunday, July 17, 2022

RTC and Arduino Based Adjustable Motor Timer

RTC and Arduino Based Adjustable Motor Timer
Hi after a long time I am here with a timer for you which's very useful for home appliances as you can see in title.

In daily life we analyze that some appliances are helping in human life to overcome the human efforts and struggles like water pump, washing machines refrigerator's etc. but we also concern with utilization of power as well. So we want to manage these things in a good and desire manners.

So here is a Arduino and real time clock RTC based adjustable timer for your appliance. You Just set you desire minutes to ON the appliance in each hour then save that. Than you will be feel easy.

This Circuit is especially design for water pump to suck the water from the ground after each hour.

Function buttons:

set: Press to enter in setting mode for timer ON and OFF minutes, Real time setting, Day setting then saving that values

++ : is use to increase values

-- : is use to decrease values

AOM : is empty right now for one more advancement I want to do (I will share in next version)

Components used:

  •     Arduino Uno
  •     RTC (DS1307)
  •     LCD 16x2
  •     Push button
  •     7805 Regulators
  •     SPDT Relay 12v operated
  •     TIP147
  •     Optocoupler 817
  •     Resistors 10k, 220
  •     Pot-meter 5k for Contrast control with LCD
  •     12v adopter 2A
  •     Li cell for RTC
You can get all the components online from Electronics world by just clicking here

Circuit diagram: Proteus file

RTC and Arduino Based Adjustable Motor Timer

Arduino program:

001// RTC and Arduino based Motor timer //
002//  FHQ Design, 30 July,2022         //
003//www.elektronicsgarage1.blogspot.com//
004  
005// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
006#include <wire .h="">
007#include <liquidcrystal .h="">
008#include "RTClib.h"
009 
010RTC_DS1307 rtc;
011const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
012LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
013//RTC_DS1307 RTC;
014 
015//************Button*****************//
016int Bset  =8; // Button SET MENU'
017int Binc  =9; // Button +
018int Bdec  =10; // Button -
019int Baom  =11; // Auto or Manual
020int motor =12; // motor control pin
021int LED   =13;   // led
022 
023 
024 
025 //void now_time();
026int manu=0,hr=0,mint=0,mintcheck=0,On_time=3,daycheck=0;
027int ONt,OFFt;
028int yearm, monthm, daym=daym+2, hourm=12, minutem=12, secm=12;
029char daysOfTheWeek[7][12] = {"Sun   ", "Mon   ", "Tue    ", "Wed      ", "Thu     ", "Fri   ", "Sat     "};
030//#define label;
031void setup ()
032{
033  lcd.begin(16,2);
034  lcd.clear();
035  Serial.begin(9600);
036  while (!Serial) {
037    ; // wait for serial port to connect. Needed for native USB port only
038  }
039  Serial.println("Goodnight moon!");
040   
041  pinMode(Bset,INPUT);
042  pinMode(Binc,INPUT);
043  pinMode(Bdec,INPUT);
044  pinMode(Baom,INPUT);
045  pinMode(LED,OUTPUT);
046  pinMode(LED, OUTPUT); // Set buzzer as an output
047  pinMode(motor, OUTPUT);
048  digitalWrite(motor, HIGH); 
049  Wire.begin();
050//  RTC.begin();
051  //Serial.begin(9600);
052    
053  if (! rtc.begin())
054  {
055    lcd.print("Couldn't find RTC");
056    while (1);
057  }
058 
059  if (! rtc.isrunning())
060  {
061    lcd.print("RTC is NOT running!");
062  }
063   
064   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time
065  // rtc.adjust(DateTime(yearm, monthm, daym, hourm, minutem, secm));// to set the time manualy
066  //setTime(varHr, varMin, varSec, vardd, varmm, varyy);
067}
068 
069void loop ()
070{
071  // Function Modes changing //
072  //delay(10);
073  //int sw = digitalRead(Bset);delay(100);
074  if (digitalRead(Bset) == LOW){
075  //for (int x=0;x<=1000;x++){}
076  delay(500);manu++;
077  //lcd.print("Function #");
078  //lcd.print(manu);
079   if (manu>6){
080    manu=0;}
081  }
082 
083  // Functions //
084   
085    if (manu==0){
086    now_time();
087    setmotor();
088   delay(10);
089   }
090//label:  
091    if (manu==1){
092      motor_ONtime();}
093 
094    if (manu==2){
095      motor_OFFtime();}
096       
097    if(manu==3){
098      sethr_T();}
099     
100    if(manu==4){
101      setmin_T();}
102 
103     if(manu==5){
104      setday_w();}
105       
106    if(manu==6){
107    Save_Prog();}
108}
109    void now_time()
110    {
111    DateTime now = rtc.now();
112     
113    lcd.setCursor(0, 0); // 12:45:78 * * mon
114     
115    /* Serial.print(now.hour());
116     Serial.print(":");
117     Serial.print(now.minute());
118     Serial.print(":");
119      Serial.print(now.second());
120     Serial.println();*/
121     
122    lcd.print(now.hour());
123    hr=now.hour();
124    lcd.print(':');
125    lcd.print(now.minute());
126    mint = now.minute();
127    mintcheck=now.minute();
128    lcd.print(':');
129    lcd.print(now.second());
130    lcd.print(" *_* ");
131    lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
132    daym=now.dayOfTheWeek();
133   // daym=daym-2;
134    //lcd.setCursor(0, 1);
135   // lcd.print("                ");
136    delay(10);
137    }
138    /*
139    lcd.setCursor(0, 1);
140    lcd.print(now.day());
141    lcd.print('/');
142    lcd.print(now.month());
143    lcd.print('/');
144    lcd.print(now.year());
145   */
146    
147   void setmotor(){ // 0
148     lcd.setCursor(0, 1);
149   lcd.print("Motor.T =   ->  ");
150   lcd.setCursor(10, 1);
151   lcd.print(ONt, DEC);
152   lcd.setCursor(14, 1);
153   lcd.print(OFFt, DEC);   
154    
155   if ((ONt<= mintcheck)&&(mintcheck<offt 0="" 1="" 2="" dec="" delay="" digitalread="" digitalwrite="" if="" inc="" lcd.print="" lcd.setcursor="" low="" motor="" motor_offtime="" n_time="ONt;" on="); delay(500);
156  }
157   else digitalWrite(motor, HIGH);
158   delay(10);
159   }
160    
161   void motor_ONtime(){ // 1
162              
163             if (digitalRead(Binc)== LOW)
164                {delay(500);ONt++;
165                if (ONt>60){lcd.setCursor(10, 1);lcd.print(" otor="" set="" t--="" t="" time="" void="">60){lcd.setCursor(11, 1);lcd.print("(^_^)");delay(1000);OFFt=0;}}
166           if (digitalRead(Bdec)== LOW)
167                {delay(500);OFFt--;
168                if (OFFt<0 0="" 1="" 3="" delay="" digitalread="" hours="" hr="" if="" inc="" lcd.print="" lcd.setcursor="" low="" motor="" n_time="OFFt;" set="" sethr_t="" t="60;}}//" time="" void="">24){lcd.setCursor(10, 1);lcd.print("(^_^)");delay(1000);hr=1;}}
169           if (digitalRead(Bdec)== LOW)
170                {delay(500);hr--;
171                if (hr<0 1="" delay="" digitalread="" hr="24;}}" if="" inc="" lcd.print="" lcd.setcursor="" low="" mint="" minute="" ours=");
172   lcd.setCursor(10, 1);
173   lcd.print(hr);
174   //now.hour()=hr;
175   delay(10); }
176   
177   void setmin_T(){ // 4
178      lcd.setCursor(0, 0);
179   lcd.print(" set="" time="">60){lcd.setCursor(11, 1);lcd.print("(^_^)");delay(1000);mint=1;}}
180           if (digitalRead(Bdec)== LOW)
181                {delay(500);mint--;
182                if (mint<0 1="" day="" daycheck="" daym="" delay="" digitalread="" if="" inc="" inute=");
183   lcd.setCursor(11, 1);
184   lcd.print(mint);
185   delay(10); }
186 
187  void setday_w(){ // 5
188   //int mint;
189   lcd.setCursor(0, 0);
190   lcd.print(" lcd.print="" lcd.setcursor="" low="" mint="24;}}" set="" week="">6){lcd.setCursor(10, 1);lcd.print("(^_^)");delay(1000);daym=0;}}
191           if (digitalRead(Bdec)== LOW)
192                {delay(500);daym--;
193                if (daym<0 0="" 1="" atetime="" ay=");
194   lcd.setCursor(10, 1);
195  lcd.print(daysOfTheWeek[daym]);       // sun mon tue wed thu fri sat
196   delay(10); }                         //  0   1   2   3   4   5   6
197                                        //  2   3   4   5   6   0   1
198   void Save_Prog(){ // 6
199   lcd.setCursor(0, 0);
200   lcd.print(" data="" daym="" delay="" hourm="" if="" lcd.print="" lcd.setcursor="" manu="0;" manualy="" minutem="" monthm="" otor.t="-" rtc.adjust="" saving="" secm="" set="" t="" the="" time="" to="" wait="" yearm="">  ");
201                lcd.setCursor(10, 0);
202                lcd.print(ONt, DEC);
203                lcd.setCursor(14, 0);
204                lcd.print(OFFt, DEC);  
205                lcd.setCursor(0, 1);
206                lcd.print("Error::OFFt>ONt");
207                delay(1000);
208                manu=1;
209                }
210                 
211  // On_time = ONt;
212  delay(1000);  }
213  <!--0--><!--0--><!--0--><!--0--></offt></liquidcrystal></wire>
If you like my project ! Plz share it and comment me 
Thanks

1 comment:
Write comments

I am very thankful for your precious time

Important Artical

Popular Articals

Total Page views in This Month

1294
© 2019-20 Electronics Garage. Designed by Bloggertheme9 & Distributed by elektronicsgarage1.blogspot.com