SKU: OT2118-A47 Numer artykułu: NA509 EAN: 8324968584702
Moduł zegara czasu rzeczywistego z układem DS3231 (. Ten moduł sprawia, że Arduino w każdej chwili zna dokładny czas. Dzięki podłączeniu Arduino do pinu ´sqw´ możliwe jest generowanie przerwania co sekundę, dzięki czemu można odczytywać wartości z czujników lub sterować wyświetlaczem.
Komunikacja: interfejs I2C.
Dokładnie odmierza czas, nawet gdy moduł nie jest podłączony (bateria podtrzymująca)
Rok - miesiąc - dzień godzina : minuta : sekunda
Złącze dla wyzwalania z interwałem (1Hz, 4kHz, 8kHz, 32kHz)
56 Bytes pamięci nieulotnej
Większa precyzja niż DS1307
Dodatkowy układ pamięci: AT24C32 (32K bytes)
Wbudowany czujnik temperatury (odchylenie ±3 °C)
Dostarczany bez baterii
Uwaga: użyj akumulatora LIR2032
Wymiary
Lengte: 3,9cm
Breedte: 2,2cm
Hoogte: 1,2cm
Tak podłączysz DS3231 Moduł zegara czasu rzeczywistego I2C (RTC wysoka precyzja) do Arduino UNO lub ESP32, z przykładowym szkicem, który możesz od razu wgrać.
Ten projekt łączy wysokoprecyzyjny moduł RTC DS3231 z Arduino Uno przez I2C. Szkic ustawia RTC na czas kompilacji, jeśli nastąpiła utrata zasilania, a następnie co sekundę odczytuje i wyświetla w Serial Monitor sformatowaną datę, godzinę oraz odczyty wbudowanego czujnika temperatury.
/*
* ==================================================================
* 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);
}
Wymagane biblioteki: RTClib 2.1.4
Wiring diagram and example code generated by Codey.online — https://www.codey.online
Ten projekt odczytuje bieżącą datę, czas i temperaturę wewnętrzną z modułu Real Time Clock DS3231 przez I2C. Podłącz moduł do szyny 3.3V ESP32 i domyślnych pinów I2C, a następnie otwórz Serial Monitor z prędkością 115200 baud, aby wyświetlić bieżący znacznik czasu.
/*
* ==================================================================
* 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);
}
Wymagane biblioteki: RTClib 2.1.4
Wiring diagram and example code generated by Codey.online — https://www.codey.online