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 number Function Code (hex format)
1 Increment 0x20
2 Set time and calendar 0x10
3 Decrement 0x21
4 Set alarms 0x11
5 Reset alarms 0x25

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:

Leave a Reply

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