making a four port outlet timer

hello all I am hoping to learn how to use an arduino uno, seed studio relay shield, real time clock add on, and a lcd screen shield to make a four port outlet timer to use just like a light timer withing more controll over more on and off settings and expandability of course...I am wanting to control the four relays individually to switch the dc voltage on and off going to the little dc fans and such...and use the lcd screen to display what modes it is in and maybe turn a few things on and off... I have a little bit of arduino programming under my belt but may as well be starting at the bottom... I was hoping someone here could give some guidance on this... how difficult will this project be? i see how the lcd screen could be a little bit more involved and i could deferentially save it for later I would definentally like to get this thing up and running as a programmable "light timer" clock even if it means I can only change the settings with my computer and just use the lcd screen as a display for the time and what the modes are doing r cumming up.... I have the hole hardware side almost completely figured out im pretty good with setting up electrical circuits and what not...

the time clock is not here yet it will be here later this week however I figured I could start writing the programming and learn how everything works until then.....

any guidance would be more than useful and i thank you in advance.... I hope this is in the correct forum.


What RTC did you buy? Some have an alarm function, and some don't. I use an alarm to activate certain functions in my aquarium. The RTC only stores one alarm at a time. When the alarm triggers, it pulls a line high, which I use as an interrupt to the main processor. As each alarm is triggered, I store the next scheduled alarm in the RTC. That, I think, is the best way to schedule multiple events throughout a day. The RTC I use is the PCF8533.

The Arduino platform will easily handle this project.
Show us the schematic and links to your hardware in your proposed circuit.
inc/dec/select push button switches could be used to set LCD menu items.

I purchased the osepp uno r4

seed studio relay shield v2

osepp lcd

And this rtc

I bought this clock because I figured I just needed it to tell the uno what time it is so the uno could run a loop with timers and if then alarms so when the time hits an alarm it will react by switching a relay...... (sorry its been a while this may not be realistic)

I can cancel the time clock as I just ordered it a while ago however i have the other components...

As for a schematic the relay shield plugs ontop of the uno leaving the expanded pins(unique to the osepp uno r4 I will not be using) and the lcd stacks directly on top of the relay shield.... the relays are powered directly by the uno powersupply. the time clock should stack onto the lcd display however if the pinout is different I will connect with jumpers... or direct solder wires.\

hope this is the info you were requesting

The relay shield link is faulty
That RTC is a good choice.


Here is a thread that might be of interest to you.


Ok good on the rtc as for the relay board . Ill hop on that link and start reading up!!

alright i got about half way through that thread and started to get pretty confused it was ver difficult to keep up with when he was having difficulty talking in english.... perhaps I should start by asking a few questions and maybe using someone else code off of another page and modding it to my liking so i can get to learn it more...

firstly.... i didnt ever get to using librarys... from my undestanding you download the library and install it into my uno and it will use it to communicate with the rtc and lcd.. is this true? if so then do i need to tell the rtc to communicate with the lcd as well?

as for the relay shield i believe it is controlled by setting different pins to a high or a low to trigger a relay am i right?

You install a library on your PC and then you use the library when you are writing your program. It will be exactly the same as using (for example) the Servo library with #include <Servo.h>


well I have some library’s for the shields and the rtc installed and uploaded and working after a bit of tinkering I “stole” some code to try and mod to fit my hardware and Im kind of learning how to address different libraries and use their functions… where i"m at right now is i have a DS3232rtc library installed and whe I go to adress datetime now ; Im recieving a ‘DateTime’ does not name a type error code… I"m assuming that datetime is a funtion that I am calling up from inside the library am I correct? If so does this mean that this function is not included in the library? if this is true I would find this kind of odd as this would be a very useful funtion to use with a rtc… how do I go about adding this function into the library and or fix this error code?

Thanks for the assistance I know this is allot of random questions but this seems to be how I learn best!!

where i"m at right now is i have a DS3232rtc library installed and whe I go to adress datetime now ; Im recieving a 'DateTime' does not name a type error code.

It is completely pointless making comments like that when you have not posted the program that you are trying.


it exceeds the 900 chaector length I will try and just include the upper half… I apologize I am new to this

#include <DS3232RTC.h>


  • Description:
  • This is an example sketch that builds an Alarm Clock out of an Arduino Uno,
  • an LCD Keypad Shield, a DS1307 Real Time Clock, and a buzzer
  • The example lets you display the date and time, and also set the alarm.
  • There are 4 modes of operation in which the buttons on the LCD have specific functions.
  • “Display Date Time” mode: Date, Time, and an Alarm indication display on the LCD (default mode)
  • SELECT: Lets you set the alarm time
  • LEFT: Displays the current alarm time
  • RIGHT: Turns the alarm on and off
  • “Display Alarm Time”:
  • No active buttons. After 3 seconds the clock returns to the default mode
  • “Set Alarm” mode: Lets you set the alarm time (hours & minutes)
  • UP: Increases hours/minutes **
  • DOWN: Decreases hours/minutes **
  • SELECT: Accepts the hours/minutes value
  • “Buzzer Ringing” mode: When the alarm time has been met, the buzzer rings
  • SELECT or LEFT: Turns off the buzzer and the alarm
  • UP or DOWN: Snooze → Adds 10 minutes to the alarm time
  • ** After 5 seconds of inactivity, the clock returns to default mode
  • Note 1:
  • The development of the code was based on a Finite State Machine (FSM)
  • you can find on github:
  • The code is quite simple and was made possible due to the above
  • preliminary design. You are urged to study both the FSM and the code.
  • Note 2:
  • The time on the RTC can shift over time. If you notice a deviation building up,
  • just uncomment line 91 and load the example to your Arduino. That will set the
  • computer’s time on the RTC. Afterwards, make sure to reupload the code with
  • line 91 commented out. If you don’t do that, the next time your Arduino resets
  • it will write the time again on the RTC… the time of the code’s compilation.
  • Author:
  • Nick Lamprianidis { paign10.ln [at] gmail [dot] com }
  • License:
  • Copyright (c) 2014 Nick Lamprianidis
  • This code is released under the MIT license

#include <Wire.h> // Required by RTClib
#include <LiquidCrystal.h> // Required by LCDKeypad
#include <LCDKeypad.h>
#include <DS3232RTC.h>"

#define TIME_OUT 5 // One of the system’s FSM transitions
#define ALARM_TIME_MET 6 // One of the system’s FSM transitions

#define BUZZER_PIN 3 // Output PWM pin for the buzzer
#define SNOOZE 10 // Minutes to snooze

// The different states of the system
enum states
SHOW_TIME, // Displays the time and date
SHOW_TIME_ALARM_ON, // Displays the time and date, and alarm is on
SHOW_ALARM_TIME, // Displays the alarm time and goes back to time and date after 3 seconds
SET_ALARM_HOUR, // Option for setting the alarm hours. If provided, it moves on to alarm minutes.
// Otherwise, it times out after 5 seconds and returns to time and date
SET_ALARM_MINUTES, // Option for setting the alarm minutes. If provided, it finally sets the alarm time and alarm.
// Otherwise, it times out after 5 seconds and returns to time and date
BUZZER_ON // Displays the time and date, and buzzer is on (alarm time met)

// Creates an LCDKeypad instance
// It handles the LCD screen and buttons on the shield
LCDKeypad lcd;

// Creates an RTC_DS1307 instance
// It handles the DS1307 Real-Time Clock
DS3232RTC rtc;

states state; // Holds the current state of the system
int8_t button; // Holds the current button pressed
uint8_t alarmHours = 0, alarmMinutes = 0; // Holds the current alarm time
uint8_t tmpHours;
boolean alarm = false; // Holds the current state of the alarm
unsigned long timeRef;
DateTime now ; // Holds the current date and time information

Use REPLY rather than QUICK REPLY, you will find you can ATTACH the ino file to your post.

Tom.... :slight_smile:

Here is the link to where I downloaded the library.

and i found that haha thank you!! will definentally use in the future

and i found that haha thank you!! will definentally use in the future

If you need help now then use it now to attach the complete program.