{"id":1131,"date":"2016-12-24T16:07:31","date_gmt":"2016-12-24T08:07:31","guid":{"rendered":"https:\/\/yanjingang.com\/blog\/?p=1131"},"modified":"2018-12-17T20:22:33","modified_gmt":"2018-12-17T12:22:33","slug":"%e5%b0%8f%e7%8c%aa%e5%ad%a6arduino-ds3231%e9%ab%98%e7%b2%be%e5%ba%a6%e6%97%b6%e9%92%9f%e6%a8%a1%e5%9d%97%e7%9a%84%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/yanjingang.com\/blog\/?p=1131","title":{"rendered":"\u5c0f\u732a\u5b66arduino\u2014DS3231\u9ad8\u7cbe\u5ea6\u65f6\u949f\u6a21\u5757\u7684\u4f7f\u7528"},"content":{"rendered":"<p>arduino\u662f\u4e2a\u529f\u80fd\u5f88\u5f31\u7684\u5355\u7247\u673a\uff0c\u81ea\u8eab\u6ca1\u6709\u83b7\u5f97\u5f53\u524d\u65f6\u95f4\u7684\u529f\u80fd\u3002\u4ec5\u6709\u7684mills()\u8bb0\u5f55\u7cfb\u7edf\u8fd0\u884c\u65f6\u957f\u51fd\u6570\u572849\u5929\u5de6\u53f3\u540e\u4e5f\u4f1a\u6ea2\u51fa\u800c\u91cd\u7f6e\uff0c\u65e0\u6cd5\u7528\u4e8e\u65f6\u949f\uff0c\u6545\u53ea\u80fd\u5916\u52a0\u4e00\u4e2a\u65f6\u949f\u82af\u7247\u3002<\/p>\n<p>\u7f51\u4e0a\u641c\u5230\u7684\u5e38\u7528\u82af\u7247\u4e00\u822c\u662fds1307\uff0c\u6bd4\u5c0f\u6307\u7532\u76d6\u8fd8\u5c0f\uff0c\u6210\u672c\u53ea\u6709\u51e0\u6bdb\u94b1\uff0c\u5f88\u5212\u7b97\u3002\u56e0\u4e3a\u540e\u7eed\u6211\u8fd8\u6709\u5b58\u50a8\u4fe1\u606f\u7684\u9700\u6c42\uff0c\u6240\u4ee5\u6700\u7ec8\u9009\u62e9\u4e86\u96c6\u6210<strong>DS3231 AT24C32 \u9ad8\u7cbe\u5ea6\u65f6\u949f\u6a21\u5757 IIC\u6a21\u5757 \u5b58\u50a8\u6a21\u5757<\/strong>\u529f\u80fd\u7684\u82af\u7247\uff0c\u5927\u69822\/3\u5927\u62c7\u6307\u90a3\u4e48\u5927\uff0c\u67d0\u5b9d\u4e0a\u4e00\u5806\u3002<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1132\" rel=\"attachment wp-att-1132\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1132\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/ds3231.jpg\" alt=\"ds3231\" width=\"430\" height=\"430\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/ds3231.jpg 430w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/ds3231-150x150.jpg 150w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/ds3231-300x300.jpg 300w\" sizes=\"(max-width: 430px) 100vw, 430px\" \/><\/a><\/p>\n<p>ds3231\u65f6\u949f\u6a21\u5757\u53c2\u6570\u5982\u4e0b\uff1a<\/p>\n<p>DS3231\u662f\u4f4e\u6210\u672c\u3001\u9ad8\u7cbe\u5ea6I2C\u5b9e\u65f6\u65f6\u949f(RTC)\uff0c\u5177\u6709\u96c6\u6210\u7684\u6e29\u8865\u6676\u632f(TCXO)\u548c\u6676\u4f53\u3002<span style=\"color: #ff0000;\">\u5305\u542b\u626d\u6263\u7535\u6c60\uff0c\u65ad\u5f00\u4e3b\u7535\u6e90\u65f6\u4ecd\u53ef\u4fdd\u6301\u7cbe\u786e\u7684\u8ba1\u65f6<\/span>\u3002<\/p>\n<p>RTC\u4fdd\u5b58\u79d2\u3001\u5206\u3001\u65f6\u3001\u661f\u671f\u3001\u65e5\u671f\u3001\u6708\u548c\u5e74\u4fe1\u606f\u3002\u5c11\u4e8e31\u5929\u7684\u6708\u4efd\uff0c\u5c06\u81ea\u52a8\u8c03\u6574\u6708\u672b\u7684\u65e5\u671f\uff0c\u5305\u62ec\u95f0\u5e74\u7684\u4fee\u6b63\u3002\u65f6\u949f\u7684\u5de5\u4f5c\u683c\u5f0f\u53ef\u4ee5\u662f24\u5c0f\u65f6\u6216\u5e26\/AM\/PM\u6307\u793a\u768412\u5c0f\u65f6\u683c\u5f0f\u3002<span style=\"color: #ff0000;\">\u63d0\u4f9b\u4e24\u4e2a\u53ef\u8bbe\u7f6e\u7684\u65e5\u5386\u95f9\u949f\u548c\u4e00\u4e2a\u53ef\u8bbe\u7f6e\u7684\u65b9\u6ce2\u8f93\u51fa<\/span>\u3002\u5730\u5740\u4e0e\u6570\u636e\u901a\u8fc7I2C\u53cc\u5411\u603b\u7ebf\u4e32\u884c\u4f20\u8f93\u3002<br \/>\n\u7cbe\u5bc6\u7684\u3001\u7ecf\u8fc7\u6e29\u5ea6\u8865\u507f\u7684\u7535\u538b\u57fa\u51c6\u548c\u6bd4\u8f83\u5668\u7535\u8def\u7528\u6765\u76d1\u89c6VCC\u72b6\u6001\uff0c\u68c0\u6d4b\u7535\u6e90\u6545\u969c\uff0c\u63d0\u4f9b\u590d\u4f4d\u8f93\u51fa\uff0c\u5e76\u5728\u5fc5\u8981\u65f6\u81ea\u52a8\u5207\u6362\u5230\u5907\u4efd\u7535\u6e90\u3002\u53e6\u5916\uff0c\/RST\u76d1\u89c6\u5f15\u811a\u53ef\u4ee5\u4f5c\u4e3a\u4ea7\u751f\u03bcP\u590d\u4f4d\u7684\u624b\u52a8\u8f93\u5165\u3002<br \/>\n\u9664\u8ba1\u65f6\u7cbe\u5ea6\u9ad8\u4e4b\u5916\uff0cDS3231\u8fd8\u5177\u6709\u4e00\u4e9b\u5176\u5b83\u529f\u80fd,\u8fd9\u4e9b\u529f\u80fd\u6269\u5c55\u4e86\u7cfb\u7edf\u4e3b\u673a\u7684\u9644\u52a0\u529f\u80fd\u548c\u9009\u62e9\u8303\u56f4\u3002\u8be5\u5668\u4ef6\u5185\u90e8\u96c6\u6210\u4e86\u4e00\u4e2a\u975e\u5e38\u7cbe\u786e\u7684\u6570\u5b57\u6e29\u5ea6\u4f20\u611f\u5668\uff0c\u53ef\u901a\u8fc7I2C*\u63a5\u53e3\u5bf9\u5176\u8fdb\u884c\u8bbf\u95ee(\u5982\u540c\u65f6\u95f4\u4e00\u6837)\u3002\u8fd9\u4e2a\u6e29\u5ea6\u4f20\u611f\u5668\u7684\u7cbe\u5ea6\u4e3a\u00b13\u00b0C\u3002\u7247\u4e0a\u63a7\u5236\u7535\u8def\u53ef\u5b9e\u73b0\u81ea\u52a8\u7535\u6e90\u68c0\u6d4b\uff0c\u5e76\u7ba1\u7406\u4e3b\u7535\u6e90\u548c\u5907\u7528\u7535\u6e90(\u5373\u4f4e\u538b\u7535\u6c60) \u4e4b\u95f4\u7684\u7535\u6e90\u5207\u6362\u3002\u5982\u679c\u4e3b\u7535\u6e90\u6389\u7535\uff0c\u8be5\u5668\u4ef6\u4ecd\u53ef\u7ee7\u7eed\u63d0\u4f9b\u7cbe\u786e\u7684\u8ba1\u65f6\u548c\u6e29\u5ea6\uff0c\u6027\u80fd\u4e0d\u53d7\u5f71\u54cd\u3002\u5f53\u4e3b\u7535\u6e90\u91cd\u65b0\u52a0\u7535\u6216\u7535\u538b\u503c\u8fd4\u56de\u5230\u5bb9\u8bb8\u8303\u56f4\u5185\u65f6\uff0c\u7247\u4e0a\u590d\u4f4d\u529f\u80fd\u53ef\u7528\u6765\u91cd\u65b0\u542f\u52a8\u7cfb\u7edf\u5fae\u5904\u7406\u5668\u3002<\/p>\n<p>\u6a21\u5757\u53c2\u6570\uff1a<br \/>\n1.\u5c3a\u5bf8:38mm(\u957f)*22mm(\u5bbd)*14mm(\u9ad8)<br \/>\n2.\u91cd\u91cf:8g<br \/>\n3.\u5de5\u4f5c\u7535\u538b:3.3&#8211;5.5V<br \/>\n4.\u65f6\u949f\u82af\u7247:\u9ad8\u7cbe\u5ea6\u65f6\u949f\u82af\u7247DS3231<br \/>\n5.\u65f6\u949f\u7cbe\u5ea6:0-40\u2103\u8303\u56f4\u5185,\u7cbe\u5ea62ppm,\u5e74\u8bef\u5dee\u7ea61\u5206\u949f<br \/>\n6.\u5e262\u4e2a\u65e5\u5386\u95f9\u949f<br \/>\n7.\u53ef\u7f16\u7a0b\u65b9\u6ce2\u8f93\u51fa<br \/>\n8.\u5b9e\u65f6\u65f6\u949f\u4ea7\u751f\u79d2\u3001\u5206\u3001\u65f6\u3001\u661f\u671f\u3001\u65e5\u671f\u3001\u6708\u548c\u5e74\u8ba1\u65f6\uff0c\u5e76\u63d0\u4f9b\u6709\u6548\u671f\u52302100\u5e74\u7684\u95f0\u5e74\u8865\u507f<br \/>\n<span style=\"color: #ff0000;\"><span style=\"color: #000000;\">9.<\/span>\u82af\u7247\u5185\u90e8\u81ea\u5e26\u6e29\u5ea6\u4f20\u611f\u5668,\u7cbe\u5ea6\u4e3a\u00b13\u2103<\/span><br \/>\n10.<span style=\"color: #ff0000;\">\u5b58\u50a8\u82af\u7247:AT24C32(\u5b58\u50a8\u5bb9\u91cf32K)<\/span><br \/>\n11.IIC\u603b\u7ebf\u63a5\u53e3,\u6700\u9ad8\u4f20\u8f93\u901f\u5ea6400KHz(\u5de5\u4f5c\u7535\u538b\u4e3a5V\u65f6)<br \/>\n12.\u53ef\u7ea7\u8054\u5176\u5b83IIC\u8bbe\u5907,24C32\u5730\u5740\u53ef\u901a\u8fc7\u77ed\u8defA0\/A1\/A2\u4fee\u6539,\u9ed8\u8ba4\u5730\u5740\u4e3a0x57<br \/>\n13.\u5e26\u7535\u6c60CR2032,\u4fdd\u8bc1\u7cfb\u7edf\u65ad\u7535\u540e,\u65f6\u949f\u4efb\u7136\u6b63\u5e38\u8d70\u52a8<br \/>\n14.\u5305\u88c5\u65b9\u5f0f:\u5355\u4e2a\u9632\u9759\u7535\u5305\u88c5<br \/>\n<strong>\u4e00\u3001\u63a5\u7ebf\u8bf4\u660e<\/strong>(\u4ee5Arduino uno r3\u4e3a\u4f8b):<br \/>\nSCL\u2192A5<br \/>\nSDA\u2192A4<br \/>\nVCC\u21925V<br \/>\nGND\u2192GND<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1136\" rel=\"attachment wp-att-1136\"><img loading=\"lazy\" class=\"alignnone size-large wp-image-1136\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/WechatIMG2-1024x768.jpeg\" alt=\"wechatimg2\" width=\"660\" height=\"495\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/WechatIMG2-1024x768.jpeg 1024w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/WechatIMG2-300x225.jpeg 300w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/WechatIMG2-768x576.jpeg 768w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/WechatIMG2.jpeg 1280w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/a><\/p>\n<p><strong>\u4e8c\u3001\u5b89\u88c5uRTCLib\u5e93<\/strong>\uff08\u627e\u6765\u627e\u53bb\uff0c\u8fd8\u662f\u8fd9\u4e2a\u5e93\u597d\u7528\uff0c\u4f3c\u4e4e\u662f\u9488\u5bf9\u8fd9\u5feb\u96c6\u6210\u82af\u7247\u5c01\u88c5\u7684\uff09<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1133\" rel=\"attachment wp-att-1133\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1133\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/\u5c4f\u5e55\u5feb\u7167-2016-12-24-15.55.00.png\" alt=\"%e5%b1%8f%e5%b9%95%e5%bf%ab%e7%85%a7-2016-12-24-15-55-00\" width=\"802\" height=\"172\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/\u5c4f\u5e55\u5feb\u7167-2016-12-24-15.55.00.png 802w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/\u5c4f\u5e55\u5feb\u7167-2016-12-24-15.55.00-300x64.png 300w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/\u5c4f\u5e55\u5feb\u7167-2016-12-24-15.55.00-768x165.png 768w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><\/a><\/p>\n<p><strong>\u4e09\u3001\u4f7f\u7528uRTCLib\u5e93\u6d4b\u8bd5\u521d\u59cb\u5316\u548c\u8bfb\u53d6ds3231\u7684\u65f6\u95f4<\/strong><\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">#include &lt;uRTCLib.h&gt;\n\n#include \"Arduino.h\"\n#include \"Wire.h\"\n#include \"uRTCLib.h\"\n\nuRTCLib rtc;\nunsigned int pos;\n\nvoid setup() {\n\tdelay (2000);\n\tSerial.begin(9600);\n\tSerial.println(\"Serial OK\");\n\t\/\/ Max position: 32767\n\tfor (pos = 0; pos &lt; 1000; pos++) {\n\t\trtc.eeprom_write(pos, (unsigned char) pos % 256);\n\t}\n\n\t\/\/\u82af\u7247\u521d\u6b21\u4f7f\u7528\u65f6\u521d\u59cb\u5316\u4e00\u6b21\u5f53\u524d\u65f6\u95f4\uff0c\u6210\u529f\u540e\u6ce8\u6389\u8fd9\u884c\n\t\/\/rtc.set(0, 36, 15, 6, 24, 12, 16); \/\/\u521d\u59cb\u5316\u65f6\u95f4rtc.set(second, minute, hour, dayOfWeek, dayOfMonth, month, year)\n\n\tpos = 0;\n\n\t#if def _VARIANT_ARDUINO_STM32_\n\t#Serial.println(\"Board: Maple\");\n\t#else\n\t#Serial.println(\"Board: Other\");\n\t#endif\n\n}\n\nvoid loop() {\n\trtc.refresh();\n\tSerial.print(\"RTC DateTime: \");\n\tSerial.print(rtc.year());\n\tSerial.print('\/');\n\tSerial.print(rtc.month());\n\tSerial.print('\/');\n\tSerial.print(rtc.day());\n\tSerial.print(' ');\n\tSerial.print(rtc.hour());\n\tSerial.print(':');\n\tSerial.print(rtc.minute());\n\tSerial.print(':');\n\tSerial.print(rtc.second());\n\tSerial.print(\" DOW: \");\n\tSerial.print(rtc.dayOfWeek());\n\tSerial.print(\" ---- \");\n\tSerial.print(pos);\n\tSerial.print(\": \");\n\tSerial.print(rtc.eeprom_read(pos));\n\n\tSerial.println();\n\tpos++;\n\tpos %= 1000;\n\tdelay(1000);\n}<\/code><\/pre>\n<p><strong>\u8fd0\u884c\u6548\u679c\uff1a<\/strong><\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1134\" rel=\"attachment wp-att-1134\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1134\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/\u5c4f\u5e55\u5feb\u7167-2016-12-24-15.58.37.png\" alt=\"%e5%b1%8f%e5%b9%95%e5%bf%ab%e7%85%a7-2016-12-24-15-58-37\" width=\"713\" height=\"412\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/\u5c4f\u5e55\u5feb\u7167-2016-12-24-15.58.37.png 713w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/\u5c4f\u5e55\u5feb\u7167-2016-12-24-15.58.37-300x173.png 300w\" sizes=\"(max-width: 713px) 100vw, 713px\" \/><\/a><\/p>\n<p>\u628a\u65f6\u95f4\u6253\u5370\u5230led\u7684\u6548\u679c\uff1a<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1141\" rel=\"attachment wp-att-1141\"><img loading=\"lazy\" class=\"alignnone size-large wp-image-1141\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/WechatIMG3-768x1024.jpeg\" alt=\"wechatimg3\" width=\"660\" height=\"880\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/WechatIMG3-768x1024.jpeg 768w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/WechatIMG3-225x300.jpeg 225w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2016\/12\/WechatIMG3.jpeg 960w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/a><\/p>\n<p>yan 2016.12.24 15:59<\/p>\n<p>\u53c2\u8003\uff1a<\/p>\n<p>https:\/\/detail.tmall.com\/item.htm?id=41231526179<\/p>\n<p>https:\/\/github.com\/Naguissa\/uRTCLib<\/p>\n","protected":false},"excerpt":{"rendered":"<p>arduino\u662f\u4e2a\u529f\u80fd\u5f88\u5f31\u7684\u5355\u7247\u673a\uff0c\u81ea\u8eab\u6ca1\u6709\u83b7\u5f97\u5f53\u524d\u65f6\u95f4\u7684\u529f\u80fd\u3002\u4ec5\u6709\u7684mills()\u8bb0\u5f55\u7cfb\u7edf\u8fd0\u884c\u65f6\u957f\u51fd\u6570\u572849\u5929\u5de6\u53f3\u540e\u4e5f\u4f1a\u6ea2\u51fa\u800c\u91cd\u7f6e\uff0c\u65e0\u6cd5\u7528\u4e8e\u65f6\u949f\uff0c\u6545\u53ea\u80fd\u5916\u52a0\u4e00\u4e2a\u65f6\u949f\u82af\u7247\u3002<\/p>\n<p>\u7f51\u4e0a\u641c\u5230\u7684\u5e38\u7528\u82af\u7247\u4e00\u822c\u662fds1307\uff0c\u6bd4\u5c0f\u6307\u7532\u76d6\u8fd8\u5c0f\uff0c\u6210\u672c\u53ea\u6709\u51e0\u6bdb\u94b1\uff0c\u5f88\u5212\u7b97\u3002\u56e0\u4e3a\u540e\u7eed\u6211\u8fd8\u6709\u5b58\u50a8\u4fe1\u606f\u7684\u9700\u6c42\uff0c\u6240\u4ee5\u6700\u7ec8\u9009\u62e9\u4e86\u96c6\u6210DS3231 AT24C32 \u9ad8\u7cbe\u5ea6\u65f6\u949f\u6a21\u5757 IIC\u6a21\u5757 \u5b58\u50a8\u6a21\u5757\u529f\u80fd\u7684\u82af\u7247\uff0c\u5927\u69822\/3\u5927\u62c7\u6307\u90a3\u4e48\u5927\uff0c\u67d0\u5b9d\u4e0a\u4e00\u5806\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[353],"tags":[354,457,459,458],"_links":{"self":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1131"}],"collection":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1131"}],"version-history":[{"count":0,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1131\/revisions"}],"wp:attachment":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}