最近在调试多个传感器加屏幕,发现nodemcu动态内存使用到46%左右时就会重启,怀疑多种问题仍然调试无果。故写了一个简单程序测试(详细代码如下),在上报温湿度的代码基础上,定义了3个字符串变量(String SMS0~SMS2),每个变量1000字节左右,当加入这3个变量后,动态内存占用48%,当串口调试信息提示==== needInit ====附近后重启(见附录)。而当注释掉这3个变量,动态内存使用45%,此时程序正常连接平台。已经更换过nodemcu,单独供电测试过。请问有朋友知道原因么,谢谢。(esp8266版本是2.7.1,blinker库是最新的)
- String SMS0="121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghj";
- String SMS1="gjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjh121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjgg3gfghjggfjhgjf121343gfgfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf12134hj";
- String SMS2="ghjggfjhgjf121343gfghjggfjhgjf121343gjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjh121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfgfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjgg3gfghjggfjhgjf121343gfgfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf121343gfghjggfjhgjf12134hj";
- #define BLINKER_WIFI
- #include <Blinker.h>
- char auth[] = "***";
- char ssid[] = "***";
- char pswd[] = "***";
- BlinkerNumber HUMI("humi");
- BlinkerNumber TEMP("temp");
- #include <DHT.h>
- #define DHTPIN D7
- #define DHTTYPE DHT11 // DHT 11
- DHT dht(DHTPIN, DHTTYPE);
- uint32_t read_time = 0;
- float humi_read, temp_read;
- void dataRead(const String & data)
- {
- BLINKER_LOG("Blinker readString: ", data);
- Blinker.vibrate();
- uint32_t BlinkerTime = millis();
- Blinker.print("millis", BlinkerTime);
- }
- void heartbeat()
- {
- HUMI.print(humi_read);
- TEMP.print(temp_read);
- }
- void setup()
- {
- Serial.begin(9600);
- BLINKER_DEBUG.stream(Serial);
- BLINKER_DEBUG.debugAll();
- pinMode(LED_BUILTIN, OUTPUT);
- digitalWrite(LED_BUILTIN, LOW);
- Blinker.begin(auth, ssid, pswd);
- Blinker.attachData(dataRead);
- Blinker.attachHeartbeat(heartbeat);
- dht.begin();
- }
- void loop()
- {
- Blinker.run();
- if (read_time == 0 || (millis() - read_time) >= 2000)
- {
- read_time = millis();
- float h = dht.readHumidity();
- float t = dht.readTemperature();
- if (isnan(h) || isnan(t)) {
- BLINKER_LOG("Failed to read from DHT sensor!");
- return;
- }
- float hic = dht.computeHeatIndex(t, h, false);
- humi_read = h;
- temp_read = t;
- }
- }
复制代码 报错信息一般从以下位置开始,提示[size=1em] exception (9) ,但调整内存占用,也出现过 在串口显示MQTT连接成功后,提示exception (28)后重启。
- 23:43:43.629 -> [19021] ==== needInit ====
- 23:43:43.629 -> [19021] message: /share/device?deviceName=66438E2ACAZFQ66OSCZRQRPF&key=1c******a5
- 23:43:43.723 -> [19088] blinker server begin
- 23:43:43.770 -> [19119] Freeheap: 23880
- 23:43:58.844 -> [34334] HTTPS begin: https://iot.diandeng.tech/api/v1/user/device/share/device?deviceName=66438E2ACAZFQ66OSCZRQRPF&key=1c****a5
- 23:43:58.985 -> [34341] HTTPS payload: /share/device?deviceName=66438E2ACAZFQ66OSCZRQRPF&key=<span style="display: inline !important; float: none; background-color: rgb(247, 247, 247); color: rgb(68, 68, 68); font-family: Microsoft YaHei,SimHei,Verdana,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; overflow-wrap: break-word; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">1c****a5</span>
- 23:43:59.078 -> [34435] [HTTP] ... failed, error: connection refused
- 23:43:59.125 ->
- 23:43:59.125 -> Exception (9):
- 23:43:59.172 -> epc1=0x40240141 epc2=0x00000000 epc3=0x00000000 excvaddr=0x000010ab depc=0x00000000
- 23:43:59.219 ->
- 23:43:59.219 -> >>>stack>>>
- 23:43:59.266 ->
- 23:43:59.266 -> ctx: bearssl
- 23:43:59.266 -> sp: 3fff43b0 end: 3fff4820 offset: 0190
- 23:43:59.313 -> 3fff4540: 3fff5b64 3fff5b48 3fff5064 4023fa70
复制代码
|