<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://wiki.ocrobot.com/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://wiki.ocrobot.com/feed.php">
        <title> reference:library:sleepdog</title>
        <description></description>
        <link>https://wiki.ocrobot.com/</link>
        <image rdf:resource="https://wiki.ocrobot.com/lib/tpl/20cones/images/favicon.ico" />
       <dc:date>2026-07-18T19:20:50+00:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:disable&amp;rev=1760151335&amp;do=diff"/>
                <rdf:li rdf:resource="https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:enable&amp;rev=1760151335&amp;do=diff"/>
                <rdf:li rdf:resource="https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:reset&amp;rev=1760151335&amp;do=diff"/>
                <rdf:li rdf:resource="https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:sleep&amp;rev=1760151335&amp;do=diff"/>
                <rdf:li rdf:resource="https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:tutorial01&amp;rev=1760151335&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://wiki.ocrobot.com/lib/tpl/20cones/images/favicon.ico">
        <title></title>
        <link>https://wiki.ocrobot.com/</link>
        <url>https://wiki.ocrobot.com/lib/tpl/20cones/images/favicon.ico</url>
    </image>
    <item rdf:about="https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:disable&amp;rev=1760151335&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-11T02:55:35+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>reference:library:sleepdog:disable</title>
        <link>https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:disable&amp;rev=1760151335&amp;do=diff</link>
        <description>Watchdog.disable()

结束看门狗

语法


Watchdog.disable();


参数

无

返回值

无

例子


#include &lt;Adafruit_SleepyDog.h&gt;

void setup() {

  int countdownMS = Watchdog.enable(4000);//初始化休眠定时器，每4s超时，超时将重启arduino开发板
  for(int i = 1; i &lt;= 10; ++i) {//重置定时器10次
    Watchdog.reset();
  }
  Watchdog.disable();//关闭休眠定时程序
  countdownMS = Watchdog.enable(4000); //初始化休眠定时器，定时器时间4s
  delay(countdownMS+1000); //暂缓至休眠定时器超时1s后
  //从此部分开始的代码将不再被执行，因为休眠定时器超时，触发重启arduino开发板操作，相当于reset arduino开发板。
  
}

void loop() {

}…</description>
    </item>
    <item rdf:about="https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:enable&amp;rev=1760151335&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-11T02:55:35+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>reference:library:sleepdog:enable</title>
        <link>https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:enable&amp;rev=1760151335&amp;do=diff</link>
        <description>Watchdog.enable()

启动看门狗，并设定最大周期，单位是毫秒。

语法


int Watchdog.enable(int maxPeriodMS = 0);



参数

	*  maxPeriodMS：启动看门狗后的最大喂狗周期，超过该周期后MCU会自动重启。

返回值</description>
    </item>
    <item rdf:about="https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:reset&amp;rev=1760151335&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-11T02:55:35+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>reference:library:sleepdog:reset</title>
        <link>https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:reset&amp;rev=1760151335&amp;do=diff</link>
        <description>Watchdog.reset()

清空/重置看门狗定时器的寄存器。

语法


void Watchdog.reset();



参数

无

返回值

无

例子


#include &lt;Adafruit_SleepyDog.h&gt;

void setup() {

  int countdownMS = Watchdog.enable(4000);//初始化休眠定时器，每4s超时，超时将重启arduino开发板
  for(int i = 1; i &lt;= 10; ++i) {//重置定时器10次
    Watchdog.reset();
  }
  Watchdog.disable();//关闭休眠定时程序
  countdownMS = Watchdog.enable(4000); //初始化休眠定时器，定时器时间4s
  delay(countdownMS+1000); //暂缓至休眠定时器超时1s后
  //从此部分开始的代码将不再被执行，因为休眠定时器超时，触发重启arduino开发板操作，相当于reset arduino开发板。
  
}

void loop() {…</description>
    </item>
    <item rdf:about="https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:sleep&amp;rev=1760151335&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-11T02:55:35+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>reference:library:sleepdog:sleep</title>
        <link>https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:sleep&amp;rev=1760151335&amp;do=diff</link>
        <description>Watchdog.sleep()

设定休眠时常并启动休眠，时间长度为毫秒。

设定的时常并不是无限长，以SAMD21G为例，其睡眠时常大概为16秒。设置的睡眠时间不可以超过这个时长。

比如你设置的睡眠时长为40000ms，也就是40秒，实际醒来时间也为16秒。主要原因在于该睡眠采用内部定时器中断，由于内部定时器位数有限，因此在16s后，内部定时器溢出。</description>
    </item>
    <item rdf:about="https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:tutorial01&amp;rev=1760151335&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-11T02:55:35+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>reference:library:sleepdog:tutorial01</title>
        <link>https://wiki.ocrobot.com/doku.php?id=reference:library:sleepdog:tutorial01&amp;rev=1760151335&amp;do=diff</link>
        <description>每隔十分钟从休眠中醒来

使用看门狗定时器作为休眠唤醒定时器有其局限性，那就是最大时间通常都非常短。

比如在M0核心的的SAMD21下面，最大16秒就会自动醒来。AVR核心也大同小异。

如果要做一个大部分时间都在休眠，每隔10分钟醒来执行某段一段代码的程序我们该怎样设计呢？</description>
    </item>
</rdf:RDF>
