乐鑫技术交流
直播中

梅利号

9年用户 1563经验值
擅长:可编程逻辑
私信 关注
[问答]

ESP8266异常28负载禁止连接要怎么处理?

我一直在开发一个传感器单元来获取环境读数并将它们发布到 Google 表格中。
它一直在工作,然后我遇到了 Arduino IDE 的问题并重新安装了它和库。
现在,Google 表格连接部分抛出异常 (28) 并且电路板重置。
(附带说明,让电路板以这种方式反复重置有什么坏处吗?它会破坏某些东西并使电路板无用吗?)电路板:NodeMCU 1.0(ESP-12 模块)SSL:所有/基本密码频率:
80
/
160MHz
感谢您的指导。
代码(简化以隔离错误):
代码:全选#define DEBUG

//wifi
#include
#include "HTTPSRedirect.h"

const char* ssid = "#####";
const char* password = "#####";
const char *ssidAP = "####";
const char *passwordAP = "####";

//gscript
const char* target = "script.google.com";
const char* GScriptid = "####################";
const int httpsPort = 443;

String url = String("/macros/s/") + GScriptId + "/exec?value=Temperature";  
String url2 = String("/macros/s/") + GScriptId + "/exec";

String payload_base =  "{\"command\": \"appendRow\", \"sheet_name\": \"DataSheet\", \"values\": ";
String payload = "";

HTTPSRedirect* client = nullptr;
bool error = false;

void setup() {
  Serial.begin(115200);
  while(!Serial);
  delay(3000);
  Serial.flush();
  Serial.println(F("------------    Google Sheet Upload Test    --------------"));
  
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  delay(1000);

}

void loop() {
  for (int n=1; n<11; n++) {
    delay(1000);
    Serial.printf("%d seconds \n", n);
  }
  storeValues();
}

float temperature = 0;
float humidity = 0;
float pressure = 0;
float battery = 0;

void storeValues() {
    Serial.println(F("Sending..."));
    delete client;
    client = new HTTPSRedirect(httpsPort);
    client->setInsecure();
    client->setPrintResponseBody(true);
    client->setContentTypeHeader("application/json");
    Serial.print(F("Connecting to "));
    Serial.println(target + url2);
    bool flag = false;
    int errorcount = 0;
    if (!flag) {
      for (int i = 0; i < 5; i++) {
        int retval = client->connect(target, httpsPort);
        if (retval == 1) {
            flag = true;
            break;
        } else {
            Serial.print(F("..."));
        }
      }
    }
    if (flag) {
        payload = payload_base + "\"," + temperature + "," + humidity + "," + pressure + "," + battery + "\"}";
        Serial.println(payload);
        if (client->POST(url2, target, payload, false)) {
            errorcount = 0;
            Serial.println(F("Sent!"));
        } else {
            errorcount++;
            if (errorcount > 3) {
                //Serial.println(F("Could not connect to host. Halting storage of values."));
                Serial.print(F("Stopping"));
                error = true;
                delete client;
                client = nullptr;
            } else {
                //Serial.print(F("Attempt "));
                //Serial.print(errorcount);
                //Serial.println(F(". Error connecting to host....Retrying"));  
                Serial.print(F("Fail"));
            }
        }
    }
}

串行输出(带有 DEBUG):
代码:全选DK:2.2.2-dev(38a443e)/Core:2.7.2-7-g5d3af165=20702007/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-30-g92add50/BearSSL:5c771be
wifi evt: 2
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 5
cnt

connected with VM9347349_EXT, channel 11
dhcp client start...
wifi evt: 0
ip:192.168.0.103,mask:255.255.255.0,gw:192.168.0.1
wifi evt: 3
------------    Google Sheet Upload Test    --------------
....scandone
.Sending...
Connecting to script.google.com/macros/s/AKfycbyz8lBtcwLavg7U7RsSO5UuBGGsz6RVSGMTVlFEFbYQVH-pF2M/exec
[hostByName] request IP for: script.google.com
[hostByName] Host: script.google.com IP: 172.217.20.142
:ref 1
BSSL:_connectSSL: start connection
Fatal exception 28(LoadProhibitedCause):
epc1=0x40209bf0, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00300030, depc=0x00000000

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

Exception (28):
epc1=0x40209bf0 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00300030 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffc40 end: 3fffffc0 offset: 0190
3ffffdd0:  3ffffef0 3ffee88c 3fff01c4 4020452d  
3ffffde0:  3ffe0000 00000000 0000000a 40100c21  
3ffffdf0:  00000000 00000000 3ffeee68 4021b88c  
3ffffe00:  00000c30 3ffee99c 3fff1de8 40100bd2  
3ffffe10:  00000014 3fff1cac 000000ff 00000000  
3ffffe20:  00000006 3ffeedf0 00000020 40100f40  
3ffffe30:  40100b0c 00000008 00302064 3fff1cac  
3ffffe40:  3ffefb04 3ffeee68 00000000 4021b8d4  
3ffffe50:  3ffeee68 00000000 00000000 4010037a  
3ffffe60:  00000000 402138dc 0000422f 4021b8fa  
3ffffe70:  3ffeee68 00000000 00000000 4021c48f  
3ffffe80:  004b65af 0000005a 00000008 402179de  
3ffffe90:  3ffeee68 00000000 00000001 402137e1  
3ffffea0:  401054d1 004f864e d916872b 00000000  
3ffffeb0:  00f42400 6bc97d31 004f8600 00000000  
3ffffec0:  40105755 004f864e 3ffee974 00000000  
3ffffed0:  3ffee220 3ffee974 00000001 3ffee86c  
3ffffee0:  00000019 3ffee974 00000001 40207840  
3ffffef0:  00000000 00000001 3ffee86c 40208086  
3fffff00:  00000000 3fff01c4 3ffefb7c 40202b74  
3fffff10:  3ffee86c 00000000 00000d50 000001bb  
3fffff20:  3fff01c4 3ffe86f3 3ffee88c 000001bb  
3fffff30:  3fff01c4 3ffe86f3 00000001 40204763  
3fffff40:  4020a290 8e14d9ac 4020a290 8e14d9ac  
3fffff50:  3ffefdac 3ffee83c 3ffee88c 3ffe84e0  
3fffff60:  00000005 3ffee820 3ffee88c 40201183  
3fffff70:  3ffefa00 0057005f 80002710 40207840  
3fffff80:  40208091 00002710 3ffee918 3ffee918  
3fffff90:  3fffdad0 00000000 3ffee8d8 4020124b  
3fffffa0:  feefeffe 00000000 3ffee8d8 40207958  
3fffffb0:  feefeffe feefeffe 3ffe8504 40101231  
<<

回帖(1)

王涛

2024-5-22 17:52:32
异常28表示负载禁止连接,这可能是因为您的网络设置或连接信息已更改。您可能需要重新设置您的WiFi连接信息或检查您的网络设置是否正确。

关于电路板反复重置的问题,它可能会对电路板的寿命产生影响,但具体取决于板子的质量和使用情况。建议您尝试避免频繁重置电路板,以确保其长期稳定性。

以下是一些可能会帮助您解决问题的建议:

1. 确保您的WiFi连接信息是正确的,并在代码中正确设置。

2. 尝试将电路板连接到另一个WiFi网络,并查看是否仍出现异常28。

3. 检查您的Google表格API密钥是否正确,以确保与表格的连接正确。

4. 尝试将WiFi常量设置为WIFI_STA,以避免电路板在AP模式下运行。

5. 检查您的代码中所有的库是否正确引用和使用,并确保您使用的库版本是最新的。

6. 最后,尝试使用其他工具来测试您的电路板,例如串口调试工具,以查找其他可能的问题。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分