Skip to content

Latest commit

 

History

History
130 lines (100 loc) · 5.41 KB

README_EN.md

File metadata and controls

130 lines (100 loc) · 5.41 KB

This is an automatic translation, may be incorrect in some places. See sources and examples!

Espsleep

The library allows ESP8266 to go into a dream for any period (up to ~ 585 billion years)

  • turns off WiFi for the duration of sleep and turns on according to the documentation before waking up if the WiFi mode is not rf_disabled
  • Offline RTC calibration (sleep time) every awakening.On the tests carried out, the ESPSHA slept for 3 days with awakening every 6 hours, the time of awakening did not shift for any minute

compatibility

ESP8266

Dependencies

Content

  • [use] (#usage)
  • [versions] (#varsions)
  • [installation] (# Install)
  • [bugs and feedback] (#fedback)

Usage

H initialization

`CPP Espsleep (uint8_t rtc_offset = 124, bool Instant = 0, Wakemode mode = rf_default); `

description of the class

`` `CPP // to sleep (milliseconds, seconds, minutes, hours, days) VOID Sleep (Uint64_t MS, Uint32_T Sec = 0, Uint32_t Min = 0, Uint16_T Hour = 0, Uint16_T Day = 0);

// Sleep, microseconds VOID Sleep_us (Uint64_T US);

// ticker of sleep blocks.Call at the beginning of the program. // will return false if this is the first launch of MK and the dream is not launched (true, if sleep in the process) Bool Tick ();

// True - the first launch after the diet.Call after Tick ()! Bool firststart ();

// cancel the next dream in Tick VOID Stop ();

// === The defines of settings (declared before connecting the library) ==== // Sleep block, by default 2 hours.Not recommended for more than 3 hours! #define max_sleep_block 2ull * 60 * 60 * 1000 * 1000

// Calibration time, ISS.Set 0 to turn off #define rtc_cali_block 100000 `` `

How it works

To wake up the GPIO16 timer, it must be connected to RST!

The rest of the information on sleep [in the documentation] (https://arduino-esp8266.Riredocs.io/en/latest/libraries.html#esp-specific-pis)

ESP8266 cannot sleep with hardware than ESP.deepsleepmax () microsecond (~ 3.2 hours).Therefore, the dream is crushed for periods equal to the maximum time of sleep, and the remaining time of sleep is recorded in RTC memory (RAM not cleansed during rebooting).To sleep in this mode with this library, you need to use the design of the type:

`` `CPP #include <espsleep.h> Espsleep Sleep;

VOID setup () { // We wake up here // you can cancel the remaining dream through Sleep.Stop ()

// ...

// fall asleep if there is time to sleep // at the first supply of power on MK, nothing happens Sleep.tick ();

// We get here when the time of sleep came out completely! // and also when feeding on MK Serial.begiCranberries N (115200); Serial.println (); Serial.println ("Awake!");

// fall asleep for example here Sleep.sleep (5000); }

VOID loop () { // you can go to sleep anywhere // ifo (foo) Sleep.sleep (5000); } `` `

versions

  • V1.0

Installation

Update

  • I recommend always updating the library: errors and bugs are corrected in the new versions, as well as optimization and new features are added
  • through the IDE library manager: find the library how to install and click "update"
  • Manually: ** remove the folder with the old version **, and then put a new one in its place.“Replacement” cannot be done: sometimes in new versions, files that remain when replacing are deleted and can lead to errors!

bugs and feedback

Create ** Issue ** when you find the bugs, and better immediately write to the mail [alex@alexgyver.ru] (mailto: alex@alexgyver.ru) The library is open for refinement and your ** pull Request ** 'ow!

When reporting about bugs or incorrect work of the library, it is necessary to indicate:

  • The version of the library
  • What is MK used
  • SDK version (for ESP)
  • version of Arduino ide
  • whether the built -in examples work correctly, in which the functions and designs are used, leading to a bug in your code
  • what code has been loaded, what work was expected from it and how it works in reality
  • Ideally, attach the minimum code in which the bug is observed.Not a canvas of a thousand lines, but a minimum code