Wemos D1 Mini 上的软 WDT 重置

问题描述 投票:0回答:1

尝试在我的 WeMos D1 Mini(克隆)上运行示例代码时出现此错误 这是代码:

我不确定为什么会发生这种情况,我已检查接线是否正确,并且该脚本确实可以与 Arduino 配合使用。

我不确定错误判断是否来自于它是 esp8266,因为我是个新手,只是在玩这个东西

#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>
/*
   This sample sketch demonstrates the normal use of a TinyGPSPlus (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
 */
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 4800;

// The TinyGPSPlus object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup() {
    Serial.begin(115200);
    ss.begin(GPSBaud);
}

void loop() {
    // This sketch displays information every time a new sentence is correctly encoded.
    while (ss.available() > 0) {
        if (gps.encode(ss.read())) {
            displayInfo();
        }
    }

    if (millis() > 5000 && gps.charsProcessed() < 10) {
        Serial.println(F("No GPS detected: check wiring."));
        while(true);
    }
}

void displayInfo() {
    Serial.print(F("Location: ")); 
    if (gps.location.isValid()) {
        Serial.print(gps.location.lat(), 6);
        Serial.print(F(","));
        Serial.print(gps.location.lng(), 6);
    } else {
        Serial.print(F("INVALID"));
    }

    Serial.print(F("  Date/Time: "));
    if (gps.date.isValid()) {
        Serial.print(gps.date.month());
        Serial.print(F("/"));
        Serial.print(gps.date.day());
        Serial.print(F("/"));
        Serial.print(gps.date.year());
    } else {
        Serial.print(F("INVALID"));
    }

    Serial.print(F(" "));
    if (gps.time.isValid()) {
        if (gps.time.hour() < 10) Serial.print(F("0"));
        Serial.print(gps.time.hour());
        Serial.print(F(":"));
        if (gps.time.minute() < 10) Serial.print(F("0"));
        Serial.print(gps.time.minute());
        Serial.print(F(":"));
        if (gps.time.second() < 10) Serial.print(F("0"));
        Serial.print(gps.time.second());
        Serial.print(F("."));
        if (gps.time.centisecond() < 10) Serial.print(F("0"));
        Serial.print(gps.time.centisecond());
    } else {
        Serial.print(F("INVALID"));
    }

    Serial.println();
}

这是错误:

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Soft WDT reset

Exception (4):
epc1=0x402013a0 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffe50 end: 3fffffd0 offset: 0160
3fffffb0:  00000000 00000000 3ffee6dc 40203378  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 

我之前读过一些帖子,这让我相信程序在某个地方崩溃了

arduino
1个回答
0
投票
    while(true);

您的代码可能由于某种原因无法检测到 GPS,因此它会进入无限的

while(true)
循环。对于ESP8266来说,后台运行的看门狗定时器需要定期“喂食”,这样的死循环会把“狗”掐死,把这条线改成follow就可以让看门狗“呼吸”了。

while(true) { delay(1); }

这将解决重启问题,您仍然需要处理 GPS 不工作的原因,因此请检查连接并在室外空旷视野清晰的情况下进行测试。

© www.soinside.com 2019 - 2024. All rights reserved.