Arduino + DS3231 RTC with alarms, temperature monitor & remote control

As a simple addition to the Arduino real time clock with alarms and temperature monitor project, I’m going to add an IR remote control function to the circuit. The remote control used in this project is a TV one (LG TV) which uses RC-5 protocol, this remote control will be used to set the real time clock time, calendar and alarms.

To see how to build an Arduino based real time clock with alarms and temperature monitor read the post below (with setup buttons):
Arduino real time clock with alarm and temperature monitor using DS3231

and to see how to decode IR remote controls with RC5 protocol with Arduino read the following topic:
Arduino RC5 IR remote control decoder

So this project is just a combination of the previous two projects.
We need to decode our remote control in order to know the code of each button because we’ve to add it in the Arduino software (code).

Hardware Required:

  • Arduino board
  • DS3231 RTC board  — DS3231 datasheet
  • 2004 LCD screen
  • RC5 protocol IR remote control
  • IR receiver
  • LED
  • 47µF capacitor
  • 10K ohm variable resistor (or potentiometer)
  • 2 x 330 ohm resistor
  • 3V coin cell battery
  • Breadboard
  • Jumper wires

The circuit:
Project circuit schematic diagram is shown below.

Arduino with DS3231 real time clock - calendar with alarms, temperature monitor and remote control

The DS3231 board is supplied with 5V as the 2004 LCD and the IR receiver, this 5V comes from the Arduino board, there are 3 data lined connected between this board and the Arduino, SCL line is connected to analog pin 5, SDA is connected to analog pin 4 and INT line is connected to digital pin 2 which is the external interrupt pin of the Arduino (INT0). The DS3231 interrupts the microcontroller when there is an alarm (alarm1 or alarm2).

The IR receiver has 3 pins: GND, VCC and OUT where the OUT pin is connected to Arduino pin 3 which is external interrupt pin (INT1).

The LED which is connected to Arduino pin 10 is used as an alarm indicator (alarm1 or alarm2), so if there is an alarm the DS3231 pulls down the INT pin which interrupts the microcontroller (ATmega328P) and the microcontroller turns the LED ON, here a button on the remote control turns both the LED and the occurred alarm OFF.

Arduino Code:
The Arduino code below doesn’t use any library for the DS3231.
By reading the datasheet of the DS3231 RTC the code will be more easier!

The remote control used in this project is a TV IR remote control with RC5 protocol, it’s the one shown below (used buttons are numbered):

LG TV RC-5 remote control

Button numberFunctionCode (hex format)
2Set time and calendar0x10
4Set alarms0x11
5Reset alarms0x25

Button #1 is used to increment the selected parameter (hours, minutes, day, date, month, year, alarm hours, alarm minutes and alarm status (ON and OFF)) and button #3 is used to decrement that parameter. Time and calendar parameters are selected with button #2 and alarms (alarm 1 and alarm 2) parameters are selected with button #4.

When alarm ( alarm 1 or alarm 2) the Arduino turns the LED ON, here button #5 turns the LED and the occurred alarm OFF.

Full Arduino code is below.

The video below shows how a prototype circuit of the project:

19 thoughts on “Arduino + DS3231 RTC with alarms, temperature monitor & remote control”

  1. Hi, I did your project but I have one problem. I cannot exit the alarm setup menu. It does not stop flashing. Where am I wrong?

  2. Hi, the project is great. But I need a slightly different logic to work with. Have on and off time on alarm 1 and also on alarm 2 and control different outputs. Can you give me a hand?

  3. Yes, it is with NEC protocol; I tried to modify, as I wrote above but, it did not work.

    What do I have to modify, basically?

  4. Or, otherwise, how could I use your sketch with the NEC Protocol and the IRremote library? (if not much more work)

    1. I think your remote control uses NEC protocol, you’ve to modify the code in order to work with your remote control.
      This project (you’ve seen it before) may help you: “Arduino NEC IR remote control decoder”

  5. I used two sketch to decode: IR remote_decoder and Find_Protocol; both sketches decoded the two controls exactly.

    (NEC Remote Control)
    1 > FF6897
    2 > FF9867
    3 > FFB04F
    4 > FF30CF
    5 > FF18E7

    (SAMSUNG Remote Control) – This is LG Control detected as SAMSUNG.
    1 > 808827D
    2 > 80842BD
    3 > 808C23D
    4 > 80822DD
    5 > 808A25D

    I also looked at your site for the article about “Arduino NEC IR remote control decoder”;

    I tried to adapt in my sketch, for example, where was “rc5”, I put “nec” and, for example, where was “attachInterrupt (1, RC5_read, CHANGE);” I put “attachInterrupt (1, remote_read, CHANGE);” but it did not work.

    Like I said, the clock is working fine and the IR is decoded.

    Is there a way for me to send you my sketch or, could you adapt your sketch to the NEC Protocol?

    Once again, thank you very much

  6. I experimented with an LG Control of a Mini System; I decoded the 5 keys (1 – 5) and replaced it in the sketch but it didn’t work!
    I would love to wear this watch!

  7. That last question, I managed to solve, but the first not. I replaced all 5 codes of my control here: 0x10, 0x11, 0x20, 0x21 and 0x25. When I press the button on my controller, it turns on the red IR light, indicating that it is receiving Signal but does not execute the commands. My control is those little ones from china, branded KEYES. Any help, thank you

    1. Actually I don’t know exactly which red LED are you talking about, the one shown in the circuit diagram is for alarm indicating and it’s not for IR signal receiving.
      I think you’re using a remote control with NEC protocol (not RC5 protocol), so make sure you’re using the right remote control!

      1. Yes, I am actually using a 17-button NEC Protocol Control, so what should I change in code to use this Control? Thanks

  8. I didn’t have an answer to one question, I’m already asking another: what should be changed in the sketch to use a 20×4 I2C Display?

    In place of: LiquidCrystal lcd (4, 5, 6, 7, 8, 9); I put: LiquidCrystal_I2C lcd (0x39,20,4); but nothing appears on the display (only backlight on).

  9. Firstly, thanks for the excellent project.
    To use another type of IR remote control (like those small ones from china), just decode the necessary buttons and replace in the code where it appears 0x10, 0x11, 0x20, 0x21 and 0x25?

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top