czy udało się komuś zaimplementować funkcję Deep Sleep?
W moim kodzie niestety nie działa to prawidłowo, serwer ma luki w danych, tak jak by połowa gdzieś znikała
Przykład:
Code: Select all
1699485106 2023-11-09 00:11:46 22.05
1699485705 2023-11-09 00:21:45 22.09
1699498905 2023-11-09 04:01:45 22.41
1699499506 2023-11-09 04:11:46 22.43
1699500105 2023-11-09 04:21:45 22.42
1699500705 2023-11-09 04:31:45 22.41
1699501306 2023-11-09 04:41:46 22.4
1699501905 2023-11-09 04:51:45 22.39
1699502506 2023-11-09 05:01:46 22.35
1699515706 2023-11-09 08:41:46 22.62
1699516305 2023-11-09 08:51:45 22.62
1699516906 2023-11-09 09:01:46 22.64
1699517505 2023-11-09 09:11:45 22.7
1699518106 2023-11-09 09:21:46 22.69
1699518705 2023-11-09 09:31:45 22.77
1699519306 2023-11-09 09:41:46 22.81
1699532506 2023-11-09 13:21:46 24.2
1699533105 2023-11-09 13:31:45 24.13
1699533706 2023-11-09 13:41:46 24.13
1699534305 2023-11-09 13:51:45 24.16
1699534906 2023-11-09 14:01:46 24.1
1699535505 2023-11-09 14:11:45 24.16
1699536106 2023-11-09 14:21:46 24.03
1699536705 2023-11-09 14:31:45 23.95
1699549906 2023-11-09 18:11:46 23.53
1699550505 2023-11-09 18:21:45 23.59
1699551106 2023-11-09 18:31:46 23.64
1699551705 2023-11-09 18:41:45 23.63Code: Select all
#include <SuplaDevice.h>
#include <supla/sensor/DHT.h>
#define STORAGE_OFFSET 100
#include <supla/storage/eeprom.h>
Supla::Eeprom eeprom(STORAGE_OFFSET);
#include <supla/network/esp_wifi.h>
Supla::ESPWifi wifi(####);
#define DHT1PIN 2
#define DHT1TYPE DHT11
const long sleep_calc = 1000000;
const long working_calc = 1000;
//Sleep time in seconds
const long sleep_time = 600;
//Working time in seconds
const long working_time = 120;
const unsigned long eventInterval = working_time*working_calc;
unsigned long previousTime = 0;
void setup() {
Serial.begin(115200);
// Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
char GUID[SUPLA_GUID_SIZE] = {#####};
// Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {#####};
// CHANNEL0 - DHT22 Sensor
new Supla::Sensor::DHT(DHT1PIN, DHT1TYPE);
SuplaDevice.begin(###);
}
void loop() {
unsigned long currentTime = millis();
SuplaDevice.iterate();
if (currentTime - previousTime >= eventInterval) {
previousTime = currentTime;
Serial.println(" ESP8266 to Sleep mode"); // Say going to sleep
ESP.deepSleep(sleep_time*sleep_calc);
}
}
