Arduino Timer With On/Off Set Point

46,575

131

74

Posted

Introduction: Arduino Timer With On/Off Set Point

Edited 09/05/2017.New RTC library master adafruit, supports 1307 (tested)and 3231(not tested). You can enter the time manually."Set time rtc" is for rtc 1307 and works as described on the video and steps(automatic)

Hi, with this project you will be able to control the on and off of your devices between the time you want. They may be the lights at the night, water the garden, turn on a machine, etc. We will use the arduino, the LCD and the RTC 1307 to show and control the time. You can set the "ON" hour and the "OFF" hour, by 4 push buttons that let you increase or decrease the "SET POINT". Also, you will learn to make a clock with the arduino. I included fritzing schematics and a video, so you can make this project.

First, watch the video to know what is all about. Use it like a guide

Step 1: Materials

-Arduino Uno

-RTC 1307 module

-LCD 16X2

-5V relay module

-10K trimpot

-1K resistor

-10K resistors x 4

-Push buttons x 4

-Breadboard, jumpers.

Step 2: Mounting the Clock

Follow the Fritzing schematic.

Connect 5v and gnd, from the arduino to their respective rails (Red 5V and Blue GND)

LCD pins to Arduino pins

1 VSS to GND

2 VDD to 5V

3 VO to pot center

4 RS to pin 2

5 RW to GND

6 EN or E to pin 3

7 D0 NC

8 D1 NC

9 D2 NC

10 D3 NC

11 D4 to pin 4

12 D5 to pin 5

13 D6 to pin 6

14 D7 to pin 7

15 A to 5V

16 K to GND by 1K resistor

The extremes of the trimpot to 5V and GND

RTC to Arduino

SDA to pin 4

SCL to pin 5

GND and 5V

Step 3: Setting the Time

Now we have to set the clock. Run the code "Set time RTC". This sketch take the Date and Time according the computer you're using (right when you compile the code) and uses that to program the RTC. If your computer time is not set right you should fix that first. Then you must press the Upload button to compile and then immediately upload.

Warning !: If you compile and then upload later, the clock will be off by that amount of time.

Then open up the Serial monitor window to show that the time has been set

Step 4: The Clock

With the time set, open and upload the sketch "Clock with RTC LCD" . The 10K trimpot is for the lcd contrast.Turn it to adjust the contrast and see the numbers clearly.

If everything works fine, you will have the clock running. See the video.

Step 5: Mounting the Timer

Now we add the push buttons and the relay. Follow the fritzing schematic.

So, you have pins 8, 9, 10 and 11 connected to gnd by 10K resistor(LOW). When you push, it will be connected to 5V (HIGH).

The relay is connected to pin 12. With the relay you can control your devices. Be careful with the maximun load of the relay!

Step 6: The Timer

Open and upload the code "Timer with on off set point" . You will see the current time, the "ON" set point and the "OFF" set point. The default "ON" and "OFF" time is 12.

The timer runs from 0 to 23 hours, and so on. Push the buttons to change the set point up and down. The timer will start immediately if it is between the setting values.If not, will wait to the "ON" hour.

This code have interesting functions that you can use in other projects. I tried to separate every function to make it clear.

- Add buttons to change settings

-Debounce buttons

-Limit of the set point or any values

- Add a clock to your project

All codes are made by me, exept:

Set the time of RTC , Adafruit data logger shield guide

I hope this tutorial is useful for you!

Nicolás Jarpa

3 People Made This Project!

Recommendations

  • Science of Cooking

    Science of Cooking
  • Microcontroller Contest

    Microcontroller Contest
  • Spotless Contest

    Spotless Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

64 Comments

I like your project. I built and ran it in about one hour. The only question I have is that the Relay module takes a GND on the signal pin to activate the Relay? So I can just reverse all the HIGHs and LOWs in the program?

The relays are activated by 5v in my case (HIGH from arduino), You can always reverse the logic states to make other types of relays work.

Hello, this worked great in the UNO, but I can’t get it to compile when changing the board selection to the mega. Any suggestions to where I’m going wrong?

Hi ! SDA and SCL are not the same pins on MEGA!

SDA pin 20

SCL pin 21

great instructable!! i would like to implement this into automating a chamber at work. it is run on 208V. my plan is to utilize this timer as a switch to power on/off the chamber. would i wire the physical switch from the chamber into the relay?? or, what would be the best way to implement this??

Thank you!!!

Hi! you need to check the power consumption and number of phases, I recommend you to use a contactor, powered by the arduino relay, wiring the switch into the contactor or power relay. Remember that the max load of this relays is about 10 amp.

were have you code how add on time minutes and off time minutes or hour or day, all peoples need only can set day, hour,minutes on and off time, not only hour who need ,no newer anybody.

Thanks for the comment, I have been asked a lot of times about this (to add min,days, etc) Keep in mind that you have 2 challenges here: add more variables(min,days) and make an interface for that.If you take a look to the code, it is nothing more than a comparator. I recommend to upgrade the code by stages. I have uploaded an instructable for multiple screens, that is the way to make an interface to change parameters. In the future i will update this instructable with more functions. Regards!

were i found same relay controller whit Tiny RTC and minutes too,

set on time hour+min,

set off time hour+min,

set weekday if can too.

and ofcourse today all used i2c LCD not old waste lot pins lcd.