Projects   /   Sensors & Temperature   /   PIC16F887

Real time clock and temperature monitor using PIC16F887 and DS3231

The last interfacing of the PIC16F887 microcontroller and DS3231 RTC is the building of a simple real time clock and calendar with two buttons for setting...

Published
Updated

At a glance

CategorySensors & Temperature
PIC modelPIC16F887
IncludesCircuit diagram · Download files
Reading time~4 min

Summary of Real time clock and temperature monitor using PIC16F887 and DS3231

This article details a project interfacing a PIC16F887 microcontroller with a DS3231 RTC module to create a real-time clock and calendar. The system features two alarms, a temperature monitor, and time/date setting capabilities controlled by three push buttons. It utilizes an LCD for display and an LED to indicate alarm status triggered via external interrupts.

Parts used in the Real Time Clock and Calendar Project:

  • PIC16F887 microcontroller
  • DS3231 RTC board
  • 20x4 LCD screen
  • 10K ohm variable resistor
  • 330 ohm resistor
  • LED
  • 3 x push button
  • 5V supply source
  • Breadboard
  • Jumper wires
  • 3 x 4.7K ohm resistors (on DS3231 board)
  • 0.1uF ceramic capacitor (on DS3231 board)
  • 3V coin cell battery (on DS3231 board)

The last interfacing of the PIC16F887 microcontroller and DS3231 RTC is the building of a simple real time clock and calendar with two buttons for setting time and date. Project link is the one below:
Interfacing DS3231 with PIC16F887 microcontroller
In this topic I'm going to add 2 alarms and temperature monitor to the previous project since the DS3231 has 2 alarm functions and temperature sensor with an accuracy of ±3°C (for more information read the DS3231 datasheet).

Real time clock and temperature monitor using PIC16F887 and DS3231
Hardware Required:

  • PIC16F887 microcontroller
  • 20x4 LCD screen
  • 10K ohm variable resistor
  • 330 ohm resistor
  • LED
  • 3 x push button
  • 5V supply source
  • Breadboard
  • Jumper wires

DS3231 board contains the following components:

  • DS3231 RTC - datasheet
  • 3 x 4.7K ohm resistors
  • 0.1uF ceramic capacitor
  • 3V coin cell battery

The circuit:
Circuit schematic diagram is shown below.

In this project I used the DS3231 board, this board basically contains the main chip which is the DS3231, pull-up resistors (4.7K) of SCL, SDA and INT/SQW lines and coin cell battery holder. There is also 24C32 EEPROM and some other resistors (not used in this project).
The DS3231 board is supplied with 5V as the microcontroller and the 2004 LCD, there are 3 data lined connected between this board and the PIC16F887 MCU, SCL line is connected to pin RC3, SDA is connected to pin RC4 and INT line is connected to pin RB0 which is the external interrupt pin of the PIC16F887 MCU. The DS3231 interrupts the microcontroller when there is an alarm.

Real time clock and temperature monitor using PIC16F887 and DS3231 schematics
In the circuit there are 3 push buttons: B1, B2 and B3. These buttons are used to set time, calendar and alarms. Time and calendar can be adjusted with B1 and B2, button B1 selects time or date parameter (time parameters: hours and minutes; calendar parameters: day, date, month and year) and B2 increments the selected parameter. The button B3 and B2 adjust alarm1 and alarm2 parameters (hours, minutes and ON/OFF), button B3 selects the parameter and B2 increments the selected parameter.
There is an LED connected to pin RB4, this LED 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 and the microcontroller turns the LED ON, here button B2 turns both the LED and the occurred alarm OFF.
In this project the PIC16F887 MCU uses its internal oscillator and MCLR pin function is disabled.

Read more: Real time clock and temperature monitor using PIC16F887 and DS3231

  • What components are included on the DS3231 board?
    The board contains the DS3231 chip, three 4.7K ohm pull-up resistors, a 0.1uF ceramic capacitor, a 3V coin cell battery holder, and a 24C32 EEPROM.
  • How does the DS3231 communicate with the PIC16F887?
    The DS3231 connects via three data lines: SCL to pin RC3, SDA to pin RC4, and INT to pin RB0 which is the external interrupt pin.
  • Which button is used to select time or date parameters?
    Button B1 selects the time or date parameter, toggling between hours/minutes and day/date/month/year.
  • How can the selected parameter be incremented?
    Button B2 increments the currently selected parameter for both time/calendar settings and alarm adjustments.
  • How does the system indicate that an alarm has occurred?
    When an alarm triggers, the DS3231 pulls down the INT pin, causing the microcontroller to turn on an LED connected to pin RB4.
  • How do you turn off an active alarm and its indicator light?
    Pressing button B2 turns both the LED and the occurred alarm OFF.
  • What power source is used for the DS3231 board and the microcontroller?
    Both the DS3231 board and the microcontroller are supplied with a 5V power source.
  • What oscillator configuration is used by the PIC16F887 in this project?
    The PIC16F887 uses its internal oscillator and the MCLR pin function is disabled.
Development Boards & Kits · PIC16F887

Hands-On Microcontroller Projects: BK300 Development Board Featuring PIC16F887 Chip Lab

1. INTRODUCTION The study of microcontroller systems is experiencing a global surge across various fields within science, engineering, and technology departments of...

Communication & Interfacing · PIC16F887

Chapter 1: PIC16F887 Microcontroller – Device Overview

The PIC16F887 is one of the latest products from Microchip. It features all the components which modern microcontrollers normally have. For its...

LED Projects · PIC16F887

LED Character Moving English Font Display Project (8×16)

LED Character moving play Project is Very popullar and very valuable project in microcontroller field.In here we play English Language font on...

Sensors & Temperature

Spectrum Analyzer using TMS320F28023DA with Proteus Simulation

Introduction This project demonstrates a real-time audio spectrum analyzer using the TMS320F28023DA Piccolo microcontroller, simulated in Proteus VSM. The system captures an...

Sensors & Temperature

DHT22 Low Cost Humidity Sensor using PIC18F25K20 with Proteus Simulation

IntroductionThis microcontroller project demonstrates how to interface a DHT22 (RHT03) digital temperature and humidity sensor with a PIC18F25K20 using Proteus simulation.The project...

Sensors & Temperature

Crafting a Microcontroller-Based Temperature Monitoring System

Abstract As technological advancements progress, processes become increasingly intricate, demanding a corresponding expansion in the parameters necessary for efficient analysis. Data acquisition,...

Ibrar Ayyub

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough...