SKU: OT2118-A47 Numero articolo: NA509 EAN: 8324968584702
Modulo real time clock con chip DS3231 (. Questo modulo fa sì che l'Arduino conosca sempre l'ora esatta. Collegando l'Arduino al pin ´sqw´, è possibile generare un interrupt ogni secondo con cui possono essere gestiti valori dei sensori o un display.
Comunicazione: interfaccia I2C.
Mantiene l'ora con precisione, anche quando il modulo non è collegato (batteria di backup)
Anno - mese - giorno ora : minuto : secondo
Connessione per trigger esterno con intervallo (1Hz, 4kHz, 8kHz, 32kHz)
56 Bytes di memoria non volatile
Maggiore precisione rispetto al DS1307
Chip di memoria extra: AT24C32 (32K bytes)
Sensore di temperatura integrato (scostamento di ±3 °C)
Viene fornito senza batteria
Attenzione usare batteria ricaricabile LIR2032
Dimensioni
Lunghezza: 3,9cm
Larghezza: 2,2cm
Altezza: 1,2cm
Ecco come collegare il Modulo Real Time Clock DS3231 I2C (RTC alta precisione) a un Arduino UNO o ESP32, con uno sketch di esempio che puoi caricare subito.
Questo progetto collega un modulo RTC DS3231 ad alta precisione a un Arduino Uno tramite I2C. Lo sketch imposta la RTC sull'ora di compilazione se l'alimentazione è stata interrotta, poi legge e stampa nel Serial Monitor ogni secondo la data, l'ora e le letture del sensore di temperatura integrato, formattate.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : DS3231 Real-Time Clock with Arduino Uno
* Board : Arduino UNO (arduino:avr:uno)
* Parts : DS3231 Real Time Clock Module I2C
* Libraries : RTClib 2.1.4
*
* Codey Online is an AI-powered browser IDE for Arduino and ESP32.
* Describe your project and Codey writes the code, draws the wiring
* diagram and uploads it to your board, straight from the browser.
* This code is free to use, modify and share, without warranty.
* ==================================================================
*/
#include <Wire.h>
#include <RTClib.h>
RTC_DS3231 rtc;
void setup() {
Serial.begin(115200);
while (!Serial);
if (!rtc.begin()) {
Serial.println(F("Couldn't find DS3231 RTC"));
while (1) delay(10);
}
if (rtc.lostPower()) {
Serial.println(F("RTC lost power, setting time to compile time..."));
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
Serial.println(F("DS3231 RTC initialized."));
}
void loop() {
DateTime now = rtc.now();
char dateBuffer[11];
char timeBuffer[9];
snprintf(dateBuffer, sizeof(dateBuffer), "%04d-%02d-%02d", now.year(), now.month(), now.day());
snprintf(timeBuffer, sizeof(timeBuffer), "%02d:%02d:%02d", now.hour(), now.minute(), now.second());
Serial.print(F("Date: "));
Serial.print(dateBuffer);
Serial.print(F(" | Time: "));
Serial.print(timeBuffer);
Serial.print(F(" | Temp: "));
Serial.print(rtc.getTemperature());
Serial.println(F(" C"));
delay(1000);
}
Librerie necessarie: RTClib 2.1.4
Wiring diagram and example code generated by Codey.online — https://www.codey.online
Questo progetto legge la data, l'ora e la temperatura interna correnti dal modulo Real Time Clock DS3231 tramite I2C. Collega il modulo alla linea 3.3V dell'ESP32 e ai pin I2C predefiniti, quindi apri il Serial Monitor a 115200 baud per vedere il timestamp in tempo reale.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : ESP32 Real-Time Clock with DS3231
* Board : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
* Parts : DS3231 Real Time Clock Module I2C
* Libraries : RTClib 2.1.4
*
* Codey Online is an AI-powered browser IDE for Arduino and ESP32.
* Describe your project and Codey writes the code, draws the wiring
* diagram and uploads it to your board, straight from the browser.
* This code is free to use, modify and share, without warranty.
* ==================================================================
*/
#include <Wire.h>
#include "RTClib.h"
RTC_DS3231 rtc;
void setup() {
Serial.begin(115200);
while (!Serial) { delay(10); }
Wire.begin(21, 22); // SDA = GPIO 21, SCL = GPIO 22
if (!rtc.begin()) {
Serial.println("Couldn't find DS3231 RTC module!");
while (1) delay(10);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, setting time to compilation time!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop() {
DateTime now = rtc.now();
char buffer[30];
snprintf(buffer, sizeof(buffer), "%04d-%02d-%02d %02d:%02d:%02d",
now.year(), now.month(), now.day(),
now.hour(), now.minute(), now.second());
Serial.print("Current Time: ");
Serial.print(buffer);
Serial.print(" | Temp: ");
Serial.print(rtc.getTemperature());
Serial.println(" °C");
delay(1000);
}
Librerie necessarie: RTClib 2.1.4
Wiring diagram and example code generated by Codey.online — https://www.codey.online