Programmable System for Controlling Devices by using Real Time Clock

Director from my school told me to come at his office. I was so scared because I didn’t know what is going on. Relaxing situation was when he asked me to make automated school bell. I had in my head idea how to make it, but I just got 3 days to make everything work like charm because competition of all electronic schools will be in 3 days! But if circuit control school bell for a specific time, it can control light for the school garden and electric heater! This is an absolutely multifunctional project, and you can control any device with voltage and current that your relay can handle! You set start and end time, and when the current time reaches set time relay will be on until it reaches end time that you set previously.

To realize this project I used these components

1.  Arduino 101 with Intel Curie

2.  Self-made Real Time Clock (more info on page 3)

3.  LCD display (16×2)

4.  Relays

5.  Jumper wires

6.  Regulated power supply for 12v

The project was started at 20.03.2018 and finished 22.03.2018!

Real Time Clock

Real Time Clock is a module that is saving date and time in self-memory. The script for the setup you can find on next page!

To make this module you will need:

1.  DS1307 RTC chip

2.   32,768 kHz crystal

3.  8 pin IC socket

4.  Capacitor 100nF

5.  3 metal film resistors of 10kΩ

6.  Socket forCR2032 battery

7.  CR2032 battery to count time when Arduino is out of power

Schematics you can find in this photo:

Schematics of connecting relays and RTC you can find here 

Writing of code

Writing this code wasn’t hard and wasn’t easy part

At the start of the code, I defined some libraries for RTC and I2C connection

I also defined global variables that are used for:

  • Saving current date and time to Arduino
  •  Variables when relay will turn on

In Setup part, I defined serial of 115200 baud rate, initialization of Wire library and setup of pins for relays. In loop part I defined when a current hour and current minute is like time in the variable, turn on relay1. Also, I did the same job for relay2 and relay3 but I saved their state in EEPROM to prevent loss of state when power is off. Also, I added LCD display but it is not required.

Source Code to Setup RTC Module 


#include<Wire.h>

#include "RTClib.h"

RTC_DS1307 RTC;

void setup ()

{

Serial.begin(9600);

Wire.begin();

RTC.begin(); // load the time from your computer.

if (! RTC.isrunning())

{

Serial.println("RTC is NOT running!");// This will reflect the time that your sketch was compiled

RTC.adjust(DateTime(__DATE__, __TIME__));

}

}

void loop ()

{

DateTime now = RTC.now();

Serial.print(now.month(), DEC);

Serial.print('/');

Serial.print(now.day(), DEC);

Serial.print('/');

Serial.print(now.year(), DEC);

Serial.print(' ');

Serial.print(now.hour(), DEC);

Serial.print(':');

Serial.print(now.minute(), DEC);

Serial.print(':');

Serial.print(now.second(), DEC);

Serial.println();

delay(1000);

}

//This script you just run once just to setup your RTC. You need to put battery!
All libraries you can find in Library manager at Arduino IDE.

Remove this part to just view time:

if (! RTC.isrunning())

{

Serial.println("RTC is NOT running!");// This will reflect the time that your sketch was compiled

RTC.adjust(DateTime(__DATE__, __TIME__));

}


Winning Project At Republic Competition (Mr. Filip Won Gold Medal)

Author of this Article is Mr. Filip | Click Here if you want to connect or read his Biography.

My real name is Filip a.k.a. Lukac1337. I’m coming from one “small” city in Serbia. I’m 17 years old, almost 18. I started working with computers and electronics since I was at age 7. The first laptop my father bought for me was Compaq Armada M700. It has Windows 95 and I was exploring how to install Windows XP on that machine. It is long story what I did. First solder iron I got when I was 11. My father wasn’t bought it before because he was thinking that I will torch the house with it…

Then my friends bought it for me at 27.02.2011 for my 11th birthday. Girls just gave money and said “That is not good present, he won’t be happy”, but when I unpacked it, I was the most happier human at the universe. I have 2 more solder irons but I’m just using this one. I have a lot projects that I made myself and with my best friend. First was power supply AC 230v to DC 12v. Power about 20w but enough to run LED light at my room.

I’m now a student of the most successful IT school in the region. There are a lot of great and talented students. I’m also Cisco Certified, I got that certificate about 6 months ago.I started to make a lot of projects such as EEPROM programmer, some modifications and VoltMods for desktop GPU and motherboards, overclocking computer with dry ice, modifications for routers, mobile phones, a lot of microcontroller based projects etc.

Also, I started programming 3 years ago. I know C++, JavaScript, C, C#. I bought Arduino 101 about 1 year ago and I made a lot of projects with it. I made some simple and great projects for Windows. You can view them at my GitHub account  ( www.github.com/nef0s ) .

My personal life is going great, I’m not just some geek, I have great social life, and also making a party for the mass of people. I’m also doing DJ job at my free time. At one time I decided last summer to make small workshop where I will work. I made good isolation for winter and I’m now working in it. From equipment, I have, soldering iron, bench power supply, Saleae Logic Analyzer, hot air gun, a lot of adapters and wires. I hope that I will get some great digital oscilloscope soon.

Related posts

Arduino Opta PLC Pros & Cons

Breakthrough of Ardino-Pro Opta: Micro-PLC with industrial IoT proficiency

Top Arduino sensors – the ultimate list 2021