![]() ![]() Wait 3 seconds and then replace the battery. So to start, remove the battery from the holder while the Arduino is not powered or plugged into USB. We'll also show what happens if you remove the battery and replace it since that causes the RTC to halt. The first thing we'll demonstrate is a test sketch that will read the time from the RTC once a second. ![]() You MUST have a coin cell installed for the RTC to work, if there is no coin cell, it will act strangly and possibly hang the Arduino so ALWAYS make SURE there's a battery installed, even if its a dead battery. ![]() It's low cost, easy to solder, and can run for years on a very small coin cell.Īs long as it has a coin cell to run it, the DS1307 will merrily tick along for a long time, even when the Arduino loses power, or is reprogrammed. Theres a lithium battery in there which is why its so big. This image shows a computer motherboard with a Real Time Clock called the DS1387. It can count leap-years and knows how many days are in a month, but it doesn't take care of Daylight Savings Time (because it changes from place to place) Thus, we include a seperate RTC! The RTC chip is a specialized chip that just keeps track of time. While this sort of basic timekeeping is OK for some projects, some projects such as data-loggers, clocks, etc will need to have consistant timekeeping that doesnt reset when the Arduino battery dies or is reprogrammed. Much like very cheap alarm clocks: every time they lose power they blink 12:00 But if it lost power, you'd have to reset the time. OK so what if you wanted to set the time on the Arduino? You'd have to program in the date and time and you could have it count from that point on. The Arduino doesnt know its 'Tuesday' or 'March 8th' all it can tell is 'Its been 14,000 milliseconds since I was last turned on'. So why would you want to have a seperate RTC chip? Well, the biggest reason is that millis() only keeps track of time since the Arduino was last powered - that means that when the power is turned on, the millisecond timer is set back to 0. Most microcontrollers, including the Arduino have a built-in timekeeper called millis() and theres also timers built into the chip that can keep track of longer time periods like minutes or days. A real time clock is basically just like a watch - it runs on a battery and keeps time for you even when there is a power outage! Using an RTC, you can keep track of long timelines, even if you reprogram your microcontroller or disconnect it from USB or a power plug. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |