How to connect a DS3231 RTC module?

How to Connect a DS3231 RTC Module?

The DS3231 real-time clock (RTC) module is a popular choice for keeping accurate time in electronic projects. It is widely used in applications such as data loggers, weather stations, and clocks. In this guide, we will show you how to connect a DS3231 RTC module to your Arduino or Raspberry Pi.

Materials Needed:

  • DS3231 RTC module
  • Jumper wires
  • Arduino or Raspberry Pi
  • Breadboard (optional)

Step 1: Wiring Diagram

First, let’s take a look at the wiring diagram to connect the DS3231 RTC module to your Arduino or Raspberry Pi:

For Arduino:

VCC – 5V

GND – GND

SCL – A5

SDA – A4

For Raspberry Pi:

VCC – 3.3V

GND – GND

SCL – SCL1 (GPIO3)

SDA – SDA1 (GPIO2)

Step 2: Connecting the DS3231 RTC Module

Now that you have the wiring diagram, let’s connect the DS3231 RTC module to your Arduino or Raspberry Pi:

1. Connect the VCC pin on the DS3231 RTC module to the 5V pin on your Arduino or 3.3V pin on your Raspberry Pi.

2. Connect the GND pin on the DS3231 RTC module to the GND pin on your Arduino or Raspberry Pi.

3. Connect the SCL pin on the DS3231 RTC module to the A5 pin on your Arduino or SCL1 pin on your Raspberry Pi.

4. Connect the SDA pin on the DS3231 RTC module to the A4 pin on your Arduino or SDA1 pin on your Raspberry Pi.

5. You can optionally use a breadboard for easier connections.

Step 3: Programming the DS3231 RTC Module

After connecting the DS3231 RTC module, you can start programming it to keep accurate time. Here is a sample code for setting the time on the DS3231:

#include <Wire.h>

#include <RTClib.h>

RTC_DS3231 rtc;

void setup() {

Serial.begin(9600);

if (! rtc.begin()) {

Serial.println("Couldn't find RTC");

while (1);

}

if (! rtc.isrunning()) {

Serial.println("RTC is NOT running!");

}

DateTime now = rtc.now();

}

By following these steps and programming the DS3231 RTC module, you can easily keep accurate time in your projects. Whether you are building a digital clock, data logger, or any other time-sensitive application, the DS3231 RTC module is a reliable choice.

Happy making!

Was this helpful?

0 / 0

Leave a Reply 0

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