. Today we build a real time clock., As you can see in the display. We have here date time and the temperature.. All this is accomplished with the use of only one chip.. This little chip is the DS3231 chip.. This one here.. Let see how it is built. The DS3231 chip. This little chip here is a very low power chip which keeps time with great accuracy. In this building block we bought for Arduino. It comes with a battery a rechargable battery, and so it can keep time for many years.. It is very to use as it uses the I2C interface.. It has an embedded ROM which can store some data and it has a temperature sensor which is quite accurate and is very easy to use.. Let’S connect this little block to Arduino and see how easy it is to operate this little device.. First, we take the Arduino. In this video. We are going to use an Arduino Mega.. You can use any Arduino device, you like., Then we can use an Arduino display like this. In order to In order to display the data in the screen., We plug the display in the Arduino and we are ready to connect the DS3231chip.. Ok. In order to be easier to connect, we can use a small breadboard.. We plug the chip, and now we are ready to connect them. First let’s connect. Of course, the power.. The second pin of the chip is, the Vcc. is going to 5V in Arduino.
The next pin the first pin is the Ground, So we connect it with the Arduino Ground. The third pin is named SDA. and goes to the SDA pin of the Arduino Mega. and lastly, we connect the SCL pin the fourth pin with the SCL pin in the Arduino Mega.. Ok now we are ready to power the device on and see if it is working.. Ok, it works great. As you can see, it keeps the time the date and temperature.. If I unplug Unpower and power on again the device, the time is correct.. It keeps time internally, with the embedded battery. Let’s, see how to program this device and how to set the time. We are in the computer. Now. First of all, we have to download the appropriate library in order to use the DS3231 real time clock with Arduino.. We go to this page. You can find the link in the description of the video below and download the library, the Rodan 3231 library.. There are many libraries out there, but this one is easy to use.. We unzip the library in the desktop, for example, rename it, for example, Real Time Clock and cut it and paste it in the Arduino Libraries folder. Ok here it is quotReal Time Clockquot. Now we open Arduino and we can see the example of the library.. Ok, RTC. Ds3231 – This is an example that gets time from the Arduino.. I now have loaded the final code of the project.
. You can find the full code in the link in the description of the video.. It is a modified version of the code that is provided with library.. The example that we loaded in the beginning. I have modified that code and now it can set time and get time and display it to the display.. First of all, let’s set the time.. When we buy this Real Time Clock. The time is not set.. So we have to manually set it in the first time we use it. In order to do that. The library that we use has a command that it is named parsecmd In this command. We can send commands in the Real Time Clock module, So let’s send the command to set time. In order to set the time we have to make a String like that.. This is a capital quotTquot for time and the time in a String format and the number 16, because this command is 16 bytes long.. So first of all we have to set Year Year is here. 2014.. Then we have to set the month. 10 because we are now in October.. Next we have day., It is 4th of October.. Next we have day of the week.. Today is Saturday, so we can set it as the 6th day of the week.. Then we have Hour, it is 11 in the morning. So we set here 11, then is minutes 29 and we can set the seconds as well.
. Ok, let’s put here 30.. Now we have to compile and run the code only once., The first time that the code is run. The time is set and then we don’t have to care anymore about it. Let’s upload the code.. Now we have to open the Serial, Monitor and see. Ok setting time, OK, Temperature is 24 OK.. Setting of time is done.. Now We comment those lines because we want to set time only once.. Now time is kept internally in the clock for many years as long as the battery of the module has power. Now let’s have a quick look at the code and how it works.. First of all, in the setup we begin the Serial Communication with the computer and the I2C communication. We initialize the LCD screen and clear it.. Then, in the loop function we show time once in a while, once in a second., There is a variable named interval which can be set at any value. We like, I have set it to 1000, ms, in order to show time once every second.. So once a second, we get time we get temperature, we convert it to a String. We clear the LCD screen every second, we set the cursor at the beginning, we print the day of the month and then we print the month itself.. This is a custom function. Let see where it is …. Ok, it is very simple: It has an input of an integer and then it prints in the screen, the appropriate month.
. If the month is the first month of the year, it prints in the screen January very simple.. It is a simple switch case: command. Then we print year. OK.. Then we set the cursor to the second line of the LCD screen. We print hour, and then we print minutes and seconds. That’s, it., Very easy., And then lastly, we print Temperature. That’s it and, of course we check if there is new data in the Serial Communication.. As you can see, this module is a very easy to use module and it can provide time to your Arduino project fow many years because it uses very low power and so it’s embedded battery can last for many years.. It is a very cheap module and you can buy it for around 2 or 3 from the link in the description.. It can also provide temperature because it has an embedded temperature sensor, which is more accurate, that the DHT11 sensor that we used in the previous video.. Thank you very much for watching this video Please subscribe to our channel in order, see our next projects and press like if you liked the video..
arduino clock Video
arduino clock news
Posted on Wednesday September 25, 2019100 Year Old Atomic Clock Hackaday … Continue Reading »
Posted on Sunday September 22, 2019An Arduino Enhances This 7400 CPU Hackaday … Continue Reading »
Posted on Tuesday January 08, 2019Arduino Ternary clock figures out the time Electronics Weekly … Continue Reading »
arduino clock Social
🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr