<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=MCookie-RTC</id>
		<title>MCookie-RTC - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=MCookie-RTC"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=MCookie-RTC&amp;action=history"/>
		<updated>2026-04-30T09:28:02Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=MCookie-RTC&amp;diff=10571&amp;oldid=prev</id>
		<title>1304410487@qq.com：Created page with &quot;{{Language|mCookie-RTC}} {| style=&quot;width: 800px;&quot; |- | mCookie-RTC mCookie-RTC is a clock module adopting IIC interface communi...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=MCookie-RTC&amp;diff=10571&amp;oldid=prev"/>
				<updated>2015-10-14T04:41:04Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language|mCookie-RTC}} {| style=&amp;quot;width: 800px;&amp;quot; |- | &lt;a href=&quot;/index.php/%E6%96%87%E4%BB%B6:MCookie-rtc-rect.jpg&quot; title=&quot;文件:MCookie-rtc-rect.jpg&quot;&gt;400px|thumb|right|mCookie-RTC&lt;/a&gt; mCookie-RTC is a clock module adopting IIC interface communi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Language|mCookie-RTC}}&lt;br /&gt;
{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
[[file:mCookie-rtc-rect.jpg|400px|thumb|right|mCookie-RTC]]&lt;br /&gt;
mCookie-RTC is a clock module adopting IIC interface communication, which can acquire time. With an onboard capacitor, RTC module can keep timing for several times after power disconnected.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Features==&lt;br /&gt;
*With century mark, second, minute, hour, day, week, month and year; &lt;br /&gt;
*Adopt I2C interface to communication with the core modules;&lt;br /&gt;
*Use EEPROM memory chip with I2C interface; &lt;br /&gt;
*Low-power clock chip with typical 0.25μA current value and a super capacitor, capable of keeping running after power-fail; &lt;br /&gt;
&lt;br /&gt;
==Specification==&lt;br /&gt;
*Clock chip: PCF8563&lt;br /&gt;
**Low-power CMOS real-time clock/calendar chip; &lt;br /&gt;
**Offer a programmable clock output, an interruption output and a power-fail detector. All addresses and data can have a serial transmission through I2C bus interface; &lt;br /&gt;
**The maximum bus speed is 400Kbits/s. The embedded word address register will generate increment after reading and writing data every time. &lt;br /&gt;
&lt;br /&gt;
*EEPROM chip：AT24C32&lt;br /&gt;
**Provide 32,768 EPROM serial power, which can be organized with a length of 4096 words × 8-bit;&lt;br /&gt;
**Cascade feature allows AT24C32 to articulate eight devices on the same I2C bus, to have the replication cycle of millions times and save the data to 100 years with a write-protect function.&lt;br /&gt;
*Super capacitor：XH414&lt;br /&gt;
**Provide a power-down timing function in a time slot. &lt;br /&gt;
&lt;br /&gt;
[[File:mCookie-RTC-Pinout-1Big1.jpg|800px|thumb|center|mCookie-RTC-Pinout1]]&lt;br /&gt;
&lt;br /&gt;
==Document==&lt;br /&gt;
&lt;br /&gt;
==Development==&lt;br /&gt;
&lt;br /&gt;
==Application==&lt;br /&gt;
===Detect Power-down Time Duration===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;Wire.h&amp;gt;&lt;br /&gt;
#include &amp;lt;Rtc_Pcf8563.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//init the real time clock&lt;br /&gt;
Rtc_Pcf8563 rtc;&lt;br /&gt;
&lt;br /&gt;
void setup()&lt;br /&gt;
{&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  settime(15, 8, 10, 4, 15, 57, 36);//Year, month, day, week, hour, minute and second &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
  //both format functions call the internal getTime() so that the&lt;br /&gt;
  //formatted strings are at the current time/date.&lt;br /&gt;
  Serial.println(&amp;quot;CODE_1:&amp;quot;);&lt;br /&gt;
  Serial.print(rtc.formatDate());//Acquire data &lt;br /&gt;
  Serial.print(&amp;quot;    &amp;quot;);&lt;br /&gt;
  Serial.println(rtc.formatTime());//Acquire time &lt;br /&gt;
&lt;br /&gt;
  Serial.println(&amp;quot;CODE_2:&amp;quot;);&lt;br /&gt;
  Serial.print(&amp;quot;20&amp;quot;);&lt;br /&gt;
  Serial.print(rtc.getYear());//Acquire year&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(rtc.getMonth());//Acquire month&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(rtc.getDay());//Acquire day &lt;br /&gt;
  Serial.print(&amp;quot;     &amp;quot;);&lt;br /&gt;
  Serial.print(rtc.getHour());//Acquire hour&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(rtc.getMinute());//Acquire minute &lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.println(rtc.getSecond());//Acquire second &lt;br /&gt;
&lt;br /&gt;
  delay(1000);&lt;br /&gt;
  Serial.print(&amp;quot;\r\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
void settime(int _year, int _month, int _day, int _week, int _hour, int _min, int _sec)&lt;br /&gt;
{&lt;br /&gt;
  //clear out the registers&lt;br /&gt;
  rtc.initClock();&lt;br /&gt;
  //set a time to start with.&lt;br /&gt;
  //day, weekday, month, century(1=1900, 0=2000), year(0-99)&lt;br /&gt;
  rtc.setDate(_day, _week, _month, 0, _year);&lt;br /&gt;
  //hr, min, sec&lt;br /&gt;
  rtc.setTime(_hour, _min, _sec);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Download program &lt;br /&gt;
**Stack mCookie-BT and mCookie-CoreUSB, plug USB cable into mCookie-CoreUSB, then connect to PC with the other end; &lt;br /&gt;
**Start Arduino IDE, copy the program above to IDE and set time in &amp;quot; settime(15, 8, 10, 4, 15, 57, 36);&amp;quot;;  &lt;br /&gt;
**Select Microduino-CoreUSB in (Tools) -&amp;gt; (Board) and the corresponding serial number in (Tools) -&amp;gt;(Serial); &lt;br /&gt;
**Click the icon（√）on top left of IDE and compile the program. After that, please click Download (-&amp;gt;) and burn the program to the RTC board; &lt;br /&gt;
*Result &lt;br /&gt;
**Open serial monitor after download and you can see the time. &lt;br /&gt;
[[File:mCookie-RTC-res.jpg|800px|thumb|center]]&lt;br /&gt;
**Add &amp;quot;//&amp;quot;before &amp;quot; settime(15, 8, 10, 4, 15, 57, 36);&amp;quot; to comment out the function and download program again. Open serial monitor and you'll see the time. &lt;br /&gt;
**Cut off  the power and connect to PC after several minutes, open serial monitor and you'll the running time after blackout rather than initialized time. &lt;br /&gt;
**'''(Note: RTC is programmable clock output, which can be set by settime() function. By setting time through settime() function, you need to comment out settime() so that you can take blackout timing next time. Otherwise, you have to reset the value after power-on and restart. ) '''&lt;br /&gt;
&lt;br /&gt;
===Test EEPROM Read/Write===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;EEPROM.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
long randNumber, data; //Define random number using the name of data &lt;br /&gt;
&lt;br /&gt;
//EEPROM configuration&lt;br /&gt;
#define EEPROM_write(address, p) {int i = 0; byte *pp = (byte*)&amp;amp;(p);for(; i &amp;lt; sizeof(p); i++) EEPROM.write(address+i, pp[i]);}&lt;br /&gt;
#define EEPROM_read(address, p)  {int i = 0; byte *pp = (byte*)&amp;amp;(p);for(; i &amp;lt; sizeof(p); i++) pp[i]=EEPROM.read(address+i);}&lt;br /&gt;
&lt;br /&gt;
//Define EEPROMdata&lt;br /&gt;
struct config_type&lt;br /&gt;
{&lt;br /&gt;
  int EEPROMdata;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void setup()&lt;br /&gt;
{&lt;br /&gt;
  Serial.begin(115200);&lt;br /&gt;
  /*EEPROM read evaluation*/&lt;br /&gt;
  config_type config_readback;&lt;br /&gt;
  EEPROM_read(0, config_readback);&lt;br /&gt;
  data = config_readback.EEPROMdata;&lt;br /&gt;
}&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
  randNumber = random(10, 100);//Random function: The values of randNumber change from 10 to 99.&lt;br /&gt;
  delay(1000);//Rrefresh one time every second &lt;br /&gt;
  if (randNumber != data) //Judge if EEPROM data is changed, if yes, then write in. &lt;br /&gt;
    eeprom_write();//EEPROM write function &lt;br /&gt;
  Serial.print(&amp;quot;EEPROM Write:&amp;quot;);&lt;br /&gt;
  Serial.println(randNumber);&lt;br /&gt;
  Serial.print(&amp;quot;EEPROM Read:&amp;quot;);&lt;br /&gt;
  Serial.println(data);&lt;br /&gt;
  delay(1000);&lt;br /&gt;
  Serial.println(&amp;quot;&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//=======================EEPROM Write Function===========================//&lt;br /&gt;
void eeprom_write()&lt;br /&gt;
{&lt;br /&gt;
  config_type config;                  // Define config and its content &lt;br /&gt;
  config.EEPROMdata = randNumber;&lt;br /&gt;
  EEPROM_write(0, config);         //Save &amp;quot;config&amp;quot; to EEPROM and write address 0 &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Copy the program above to IDE, download program, open serial monitor and you'll see EEPROM writing and reading data.&lt;br /&gt;
[[File:mCookie-RTC-eeprom.jpg|800px|thumb|center]]&lt;br /&gt;
*By unplugging power and then plugging in during testing, you can see that &amp;quot; EEPROM Read &amp;quot; is the value of &amp;quot; EEPROM Write &amp;quot; from serial monitor.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Purchase==&lt;br /&gt;
&lt;br /&gt;
==Picture==&lt;br /&gt;
[[file:mCookie-rtc-t.jpg|thumb|600px|center|Front]]&lt;br /&gt;
[[file:mCookie-rtc-B.jpg|thumb|600px|center|Back]]&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>1304410487@qq.com</name></author>	</entry>

	</feed>