Difference between revisions of "MCookie-RTC"
From Microduino Wiki
(3 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
[[file:mCookie-rtc-rect.jpg|400px|thumb|right|mCookie-RTC]] | [[file:mCookie-rtc-rect.jpg|400px|thumb|right|mCookie-RTC]] | ||
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. | 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. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Features== | ==Features== | ||
− | * | + | *Marked with century flag, second, minute, hour, day, week, month and year; |
− | * | + | *Adopt I2C communication with the core modules; |
− | * | + | *Own EEPROM memory chip with I2C interface. |
− | *Low-power clock chip with typical 0.25μA current value and a super capacitor, capable of keeping the module running even after power | + | *Low-power clock chip with typical 0.25μA current value and a super capacitor, capable of keeping the module running even after power disconnected; |
==Specification== | ==Specification== | ||
Line 30: | Line 22: | ||
**Provide 32,768 EPROM serial power, which can be organized with a length of 4096 words × 8-bit; | **Provide 32,768 EPROM serial power, which can be organized with a length of 4096 words × 8-bit; | ||
**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. | **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. | ||
− | *Super | + | *Super capacitor: XH414 |
**Provide a power-down timing function in a time slot. | **Provide a power-down timing function in a time slot. | ||
Line 159: | Line 151: | ||
+ | ==FAQ== | ||
+ | <blockquote>Some of the example codes that use the RTC module doesn't compile or gives an error!</blockquote> | ||
+ | There is an issue with the incorrect and outdated software library included in the Microduino software package. To fix it, please follow the guide below: | ||
+ | #Download the correct library file from here: https://wiki.microduino.cc/images/9/90/Rtc_pcf8563.zip | ||
+ | #In the Microduino IDE go to Sketch->Add .ZIP library... | ||
+ | #Navigate to the downloaded file and select the "Rtc_pcf8563.zip". Then click Choose on the bottom right. | ||
+ | #Now the IDE should use the correct library version and should be able to compile the program. | ||
==Purchase== | ==Purchase== | ||
Latest revision as of 03:23, 4 August 2017
Language: | English • 中文 |
---|
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.
ContentsFeatures
Specification
DocumentDevelopmentFor the development, it need to be supported by _06_Microduino_RTC_PCF8563 library and check the library file here: (Installation Address)\Microduino-IDE\hardware\Microduino\avr\libraries ApplicationDetect Power-down Time Duration#include <Wire.h>
#include <Rtc_Pcf8563.h>
//init the real time clock
Rtc_Pcf8563 rtc;
void setup()
{
Serial.begin(9600);
settime(15, 8, 10, 4, 15, 57, 36);//Year, month, day, week, hour, minute and second
}
void loop()
{
//both format functions call the internal getTime() so that the
//formatted strings are at the current time/date.
Serial.println("CODE_1:");
Serial.print(rtc.formatDate());//Acquire data
Serial.print(" ");
Serial.println(rtc.formatTime());//Acquire time
Serial.println("CODE_2:");
Serial.print("20");
Serial.print(rtc.getYear());//Acquire year
Serial.print("/");
Serial.print(rtc.getMonth());//Acquire month
Serial.print("/");
Serial.print(rtc.getDay());//Acquire day
Serial.print(" ");
Serial.print(rtc.getHour());//Acquire hour
Serial.print(":");
Serial.print(rtc.getMinute());//Acquire minute
Serial.print(":");
Serial.println(rtc.getSecond());//Acquire second
delay(1000);
Serial.print("\r\n");
}
void settime(int _year, int _month, int _day, int _week, int _hour, int _min, int _sec)
{
//clear out the registers
rtc.initClock();
//set a time to start with.
//day, weekday, month, century(1=1900, 0=2000), year(0-99)
rtc.setDate(_day, _week, _month, 0, _year);
//hr, min, sec
rtc.setTime(_hour, _min, _sec);
}
Test EEPROM Read/Write#include <EEPROM.h>
long randNumber, data; //Define random number using the name of data
//EEPROM configuration
#define EEPROM_write(address, p) {int i = 0; byte *pp = (byte*)&(p);for(; i < sizeof(p); i++) EEPROM.write(address+i, pp[i]);}
#define EEPROM_read(address, p) {int i = 0; byte *pp = (byte*)&(p);for(; i < sizeof(p); i++) pp[i]=EEPROM.read(address+i);}
//Define EEPROMdata
struct config_type
{
int EEPROMdata;
};
void setup()
{
Serial.begin(115200);
/*EEPROM read evaluation*/
config_type config_readback;
EEPROM_read(0, config_readback);
data = config_readback.EEPROMdata;
}
void loop()
{
randNumber = random(10, 100);//Random function: The values of randNumber change from 10 to 99.
delay(1000);//Rrefresh one time every second
if (randNumber != data) //Judge if EEPROM data is changed, if yes, then write in.
eeprom_write();//EEPROM write function
Serial.print("EEPROM Write:");
Serial.println(randNumber);
Serial.print("EEPROM Read:");
Serial.println(data);
delay(1000);
Serial.println("");
}
//=======================EEPROM Write Function===========================//
void eeprom_write()
{
config_type config; // Define config and its content
config.EEPROMdata = randNumber;
EEPROM_write(0, config); //Save "config" to EEPROM and write address 0
}
FAQSome of the example codes that use the RTC module doesn't compile or gives an error! There is an issue with the incorrect and outdated software library included in the Microduino software package. To fix it, please follow the guide below:
PurchasePicture |