Codey Online › Libreria di componenti Arduino ed ESP32 › DS3231 Real Time Clock Module I2C
DS3231 Real Time Clock Module I2C
Altro

DS3231 Real Time Clock Module I2C

Modulo orologio in tempo reale con chip DS3231 e I2C

Larghezza: 46.2 mm

Pinout — DS3231 Real Time Clock Module I2C

Pin Segnale Descrizione
32K clock 32.768 kHz clock output from the DS3231 RTC for external timing use.
SQW interrupt RTC square-wave or active-low alarm interrupt output from the DS3231.
SCL SCL I2C serial clock line for communication with the DS3231 RTC.
SDA SDA I2C serial data line for communication with the DS3231 RTC.
VCC power Main power input for the RTC module, typically 3.3 V to 5 V.
GND ground Ground reference for power and I2C signals.
SCL.1 SCL Duplicate I2C serial clock connection for the DS3231 RTC.
SDA.1 SDA Duplicate I2C serial data connection for the DS3231 RTC.
VCC.1 power Duplicate main power input for the RTC module, typically 3.3 V to 5 V.
GND.1 ground Duplicate ground reference for power and I2C signals.

Schema di cablaggio di esempio — DS3231 Real Time Clock Module I2C

Da A Filo
board:5V x1:VCC red
board:GND x1:GND black
board:SCL x1:SCL green
board:SDA x1:SDA blue

Codice Arduino di esempio — DS3231 Real Time Clock Module I2C

Questo esempio è stato scritto e verificato in compilazione per arduino-uno. Codey Online lo adatta a qualsiasi altra scheda supportata.

#include <Wire.h>
#include <RTClib.h>

RTC_DS3231 rtc;

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }

  Wire.begin();

  if (!rtc.begin()) {
    Serial.println("Couldn't find DS3231 RTC module");
    while (1) {
      delay(10);
    }
  }

  // If the RTC lost power, set it to the compile time.
  if (rtc.lostPower()) {
    Serial.println("RTC lost power, setting the time to compile time.");
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }

  Serial.println("DS3231 RTC example started.");
}

void loop() {
  DateTime now = rtc.now();

  Serial.print("Date: ");
  Serial.print(now.year());
  Serial.print('-');
  if (now.month() < 10) Serial.print('0');
  Serial.print(now.month());
  Serial.print('-');
  if (now.day() < 10) Serial.print('0');
  Serial.print(now.day());

  Serial.print("  Time: ");
  if (now.hour() < 10) Serial.print('0');
  Serial.print(now.hour());
  Serial.print(':');
  if (now.minute() < 10) Serial.print('0');
  Serial.print(now.minute());
  Serial.print(':');
  if (now.second() < 10) Serial.print('0');
  Serial.println(now.second());

  delay(1000);
}

Componenti correlati

TOF200C VL53L0X Distance Sensor Time-Of-Flight high precision

TOF200C VL53L0X Distance Sensor Time-Of-Flight high precision

AD9850 DDS Signal Generator Module

AD9850 DDS Signal Generator Module

TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm

TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm

TOF050C-VL6180X Distance Sensor Time-Of-Flight high precision

TOF050C-VL6180X Distance Sensor Time-Of-Flight high precision

Crea il tuo progetto Arduino o ESP32 con l'AI

Descrivi cosa vuoi realizzare. Codey Online scrive il codice, disegna lo schema di collegamento, lo compila e programma la tua scheda direttamente dal browser.

Inizia gratis