ESP8266/NodeMCU Deep Sleep

dsleep() function accepts microseconds as its parameter (1,000,000 microseconds = 1 second), and the multiplication performed inline here is just to make it clearer that we’re sleeping for 15 minutes total. With the current 1.5.1 SDK, the maximum value accepted is 4,294,967,295, which is about 71 minutes. Earlier SDK versions had a lower limit, closer to 35 minutes. One common way to extend this is to maintain a counter in NVM (i.e., Flash or RTC Memory), and increment the counter each time that the device wakes up. If it reaches a certain threshold, then do the work, otherwise go back to sleep.

node.dsleep(15 * 60 * 1000000)

In this case, you don’t need to connect GPIO16 to the RESET pin, and you don’t need to specify an alarm value when calling dsleep(). Or, rather, use a value of zero to specify that the ESP should sleep forever (until reset, that is):

node.dsleep(0)
1
node.dsleep(0)
This permits very long idle periods (hours, days, or weeks possible) so long as you have a reliable method of waking the device up by triggering the RESET pin.

ที่มาhttps://blog.falafel.com/esp8266nodemcu-deep-sleep/

Deep Sleep for the ESP8266 ESP-01

Because the ESP-01 does not have the necessary pin exposed for Deep Sleep (GPIO 16) we will need to do some surgical soldering on it.
We need to solder a very thin piece of wire from the reset pin to one of those very small pads on the esp chip.

Don’t worry, it’s a lot easier than it looks.

Get the piece of wire, solder it on the reset pin, tin the other end and bend it into position
What I did next is applying head somewhere near the end of the wire, this melted the solder on the wire and on the pad and I got a connection. Easy peasy.

You will also need to remove at least the red LED to lower consumption.

I have also added some hot glue on top of the wire, it’s quite easy to pull it away together with the esp’s pad otherwise.

ในขั้นตอน จะมีฟังก์ชั่นการทำงานดังนี้

– try to connect to wifi, if fail start in config mode
– read dht22 data
– post dht22 data to cloud

– go to sleep
– awake and repeat

 

ที่มาhttps://tzapu.com/minimalist-battery-powered-esp8266-wifi-temperature-logger/

 

วัดอุณหภูมิ ความชื้น ขึ้น LINE NOTIFY

void Line_Notify(String message);

#include <ESP8266WiFi.h>
#include <DHT.h>

#define DHTPIN D2

// Existing WiFi network
const char* ssid = “xxxxx”; // your wifi name
const char* password = “xxxxx”; // your wifi password

#define LINE_TOKEN “xxxxxxxxxxxxxxx” // LINE Notify token

#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
Serial.println(“Weather station by kittipongint!”);

dht.begin();

// Connect to your WiFi network
WiFi.begin(ssid, password);
Serial.print(“Connecting”);

// Wait for successful connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.print(“Connected to: “);
Serial.println(ssid);
Serial.print(“IP address: “);
Serial.println(WiFi.localIP());
Serial.println(“”);
}
void read_sensor() {
delay(600000);

// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds ‘old’ (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(“Failed to read from DHT sensor!”);
return;
}

// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);

Serial.print(“Humidity: “);
Serial.print(h);
Serial.print(” %\t”);
Serial.print(“Temperature: “);
Serial.print(t);
Serial.print(” *C “);
Serial.print(f);
Serial.print(” *F\t”);
Serial.print(“Heat index: “);
Serial.print(hic);
Serial.print(” *C “);
Serial.print(hif);
Serial.println(” *F”);

String message = “%E0%B8%AD%E0%B8%B8%E0%B8%93%E0%B8%AB%E0%B8%A0%E0%B8%B9%E0%B8%A1%E0%B8%B4%20”;
// Send notificatin with LINE Notify
Line_Notify(message + t + “%C2%B0C”);
}

void loop() {
read_sensor();
}
void Line_Notify(String message) {
WiFiClientSecure client;

if (!client.connect(“notify-api.line.me”, 443)) {
Serial.println(“connection failed”);
return;
}

String req = “”;
req += “POST /api/notify HTTP/1.1\r\n”;
req += “Host: notify-api.line.me\r\n”;
req += “Authorization: Bearer ” + String(LINE_TOKEN) + “\r\n”;
req += “Cache-Control: no-cache\r\n”;
req += “User-Agent: ESP8266\r\n”;
req += “Content-Type: application/x-www-form-urlencoded\r\n”;
req += “Content-Length: ” + String(String(“message=” + message).length()) + “\r\n”;
req += “\r\n”;
req += “message=” + message;

client.print(req);

delay(30);

// Serial.println(“—–“);
while(client.connected()) {
String line = client.readStringUntil(‘\n’);
if (line == “\r”) {
break;
}
//Serial.println(line);
}
// Serial.println(“—–“);
}

 

ที่มา:https://kittipongint.com/weather-station-wemos-d1-mini/

MMC Error CSLID: FX:{18ea3f92-d6aa-41d9-a205-2023400c8fbb}

เป็นใน windows 2008 ขึ้นว่า MMC could not create the snap-in CSLID: FX:{18ea3f92-d6aa-41d9-a205-2023400c8fbb}

สาเหตุเกิดจาก

This problem occurs if the .Net Framework 3.0 feature is not enabled and an update for .net framework 3.5SP1 is installed (which could be through the windows update or through a deployment tool).

The command removes the entries added in the machine.config during Framework updates.

การแก้ไข

To fix the problem, run the following command:

c:\Windows\Microsoft.NET\Framework\v3.5\WFServicesReg.exe /r /b

After running the command enable the feature .net framework 3.0 under Add features in Server Manager.

Open Server Manager
Select Features
Click on Add features
Select the check box for .Net Framework 3.0
Click Next and follow the steps to complete the Add Features Wizard

If these steps do not alleviate the issue, carry out the following steps to replace the Machine.config file with a known good version:

1. Navigate to C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG

2. Rename Machine.config to Machine.config.old

3. Copy Machine.config from a known good server.