我一直在开发一个传感器单元来获取环境读数并将它们发布到 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* GScrip
tid = "####################";
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
<<