我正在使用 NodeMCU 12E esp8266,我连接到 Wifi,在 GPIO 2 上测量温度,将它发送到数据库,然后我用这个命令 ESP.deepSleep(1200e6) 进入睡眠状态。功耗始终在 77mA 左右,数据表显示功耗应在 20 毫安培左右。请帮忙。
威廉希尔官方网站
板进入深度睡眠 20 分钟并唤醒,没问题,但深度睡眠中的功耗是个问题。这是代码:
代码:
全选#include
#include
#include "ESP8266WiFi.h"
#include
#include
const char* ssid = "njka Local";
const char* password = "!3bNwjSf9";
const char* serverName = "http://controltemp.online/emmezeta/connect_dako.php";
String sensid = "dse1p2";
const int oneWireBus = 2;
OneWire oneWire(oneWireBus);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print("*");
}
sensors.begin();
sensors.requestTemperatures();
float temperatureC = sensors.getTem
PCByIndex(0);
if(WiFi.status()== WL_CONNECTED){
HTTPClient http;
http.begin(serverName);
http.addHeader("Content-Type", "applica
tion/x-www-form-urlencoded");
String httpRequestData = "&sensid=" + sensid + "&temp1=" +
String(temperatureC) + "";
Serial.print("httpRequestData: ");
Serial.println(httpRequestData);
int httpResponseCode = http.POST(httpRequestData);
if (httpResponseCode>0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
// Free resources
http.end();
}
else {
Serial.println("WiFi Disconnected");
}
//Send an HTTP POST request every 20 minutes
ESP.deepSleep(1200e6, WAKE_RF_DEFAULT);
}
void loop() {
}