ESP8266 nodeMCU 12E V1.0 deepSleep problem
Posted: Mon Jan 09, 2017 10:09 pm
Hi guys,
I'm using ESP8266 nodeMCU to send data to nodeJS server each 5s, after that, the ESP go to sleep to save power.
The code work great without deepSleep mode. I mean if I put the ESP to sleep, it only send data 1 time, then sleep. After 5s, it's awake and print out some thing wierd with the red led is on, and then ESP stunned!
This is my code:
And this is what ESP responsed to Serial Monitor:
I've try to connect GPIO 16 to RST but after that, the ESP reacted so strange. The red and blue light keep flashing and no response.
Please help me
I'm using ESP8266 nodeMCU to send data to nodeJS server each 5s, after that, the ESP go to sleep to save power.
The code work great without deepSleep mode. I mean if I put the ESP to sleep, it only send data 1 time, then sleep. After 5s, it's awake and print out some thing wierd with the red led is on, and then ESP stunned!
This is my code:
Code: Select all
/*
* This sketch sends data via HTTP GET requests to data.sparkfun.com service.
*
* You need to get streamId and privateKey at data.sparkfun.com and paste them
* below. Or just customize this script to talk to other HTTP servers.
*
*/
#include <ESP8266WiFi.h>
const char* ssid = "Phong KGHT CDIO";
const char* password = "pCDIO201609";
const char* host = "192.168.100.3";
const char* streamId = "....................";
const char* privateKey = "....................";
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
int value = 0;
void loop() {
Serial.println("Awaked!");
delay(500);
digitalWrite(LED_BUILTIN, LOW);
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 3000;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
// We now create a URI for the request
String url = "/sensor/";
url += "26";
url += "/";
url += "30";
Serial.print("Requesting URL: ");
Serial.println(url);
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("Entering deep sleep");
ESP.deepSleep(5000000, WAKE_RF_DEFAULT);
delay(500);
}
And this is what ESP responsed to Serial Monitor:
Code: Select all
Connecting to Phong KGHT CDIO
......
WiFi connected
IP address:
192.168.100.6
Awaked!
connecting to 192.168.100.3
Requesting URL: /sensor/26/30
Entering deep sleep
rl lœž| Œlà| Œ lì b|Ž‚ ì ’r’blŽbŒònnžlnnœâì b pìŽlrlrl ‚rò’nàbânbp ü
I've try to connect GPIO 16 to RST but after that, the ESP reacted so strange. The red and blue light keep flashing and no response.
Please help me