![]() To get a the current time and date, we call the GetDateTime method on our previously defined RtcDS3231 object (which we named “rtcObject”). In this simple example, we will poll the RTC every 20 seconds. RtcObject.SetDateTime(currentTime) //configure the RTC with objectįinally, we will read the current date and time from the RTC in the main loop function. ![]() ![]() RtcDateTime currentTime = RtcDateTime(16, 05, 18, 21, 20, 0) //define date and time object Serial.begin(115200) //Starts serial connection So, we use the library shown in figure 3 which, as stated in the description, is tested on the ESP8266. Software LibraryĪs usual, the Arduino Environment provides a wide range of libraries to interface with different devices, and the DS3231 is no exception. The tests were performed using a NodeMCU board, a very cheap and easy to use ESP8266 board. ![]() If you are using a NodeMCU board, take into consideration that the board pins don’t correspond to the ESP8266 pins (check here the correct mapping). Since we are using the Arduino IDE, we have the Wire library available to handle the I2C protocol in the ESP8266, which we will later use when creating the program to interact with the RTC.Īs described in the documentation of the ESP8266 libraries for the Arduino IDE, the default pins for the I2C in the Wire library are pins 4 (SDA) and 5 (SDL). Figure 2 – Connection diagram between the ESP8266 and the DS3231.Īs can be seen in the diagram, the DS3231 uses an I2C interface to interact with microcontrollers. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |