Library of reusable functions for rapid development of ESP8266 sketches. Helps avoiding copy-pasting supporting code from one sketch to another and focus straight away on sketch business.
- Application identification
- Application log with log browser and automatic log rotation
- Syslog on hardware serial line
- Builtin LED (supported by JLed)
- Builtin button (where available) (supported by AceButton)
- Information on reset reason
- RTC memory
- System time, including support for time zone and sync via NTP
- Record of boot time; uptime counter (supported by Uptime-Library)
- File system (LittleFS or SPIFFS)
- Wi-Fi network
- Wi-Fi manager (configuration of Wi-Fi at runtime) (supported by WiFiManager)
- mDNS
- Web server with pages template, system info page and favicon support
- Rich set of timers: absolute, solar, countdown, including run-time reconfiguration (supported by Dusk2Dawn)
- ... add your own ...
The strong part of the library is that capabilities know about each other and often have synergy. E.g., if you activate both 'time' and 'network', time will be automatically sync from NTP; and if you add a 'led' on top, Wi-Fi connection process will be signalled with LED.
Most features rely on ESP8266 Arduino Core or several other excellent libraries from GitHub, and make just a thin interface on top. Library objects are deliberately declared public
, so you have full access to the native interface, should you need it. Few things I haven't found a good support for and implemented myself:
-
Download the latest release locally (installation via Arduino Library Manager is not supported - see why);
-
Copy files
System.h
,System.cpp
andMySystem.h
fromsrc/
into your sketch folder. Reopen sketch in Arduino if you had it opened. -
Uncomment the desired features in
MySystem.h
; -
Add the following lines in your sketch (.ino):
#include "MySystem.h" using namespace ds; ... void setup() { System::begin(); // Could be omitted for some capabilities ... } void loop() { ... System::update(); // Could be omitted for some capabilities }
#define DS_CAP_SYS_NETWORK // Enable network
#define DS_CAP_SYS_TIME // Enable system time
#define DS_CAP_SYS_LOG_HW // Enable syslog on hardware serial line
#define DS_TIMEZONE TZ_Europe_Paris // Timezone. Pick yours from TZ.h coming with ESP Core
#include "System.h" // System global definitions
#include "MySystem.h"
using namespace ds;
// Set network parameters
const char *System::wifi_ssid = "mySSID"; // Network SSID
const char *System::wifi_pass = "myPassword"; // Network password
void setup() {
System::begin();
delay(2000); // Allow time to synchronize
System::log->print("Current time: ");
System::log->println(System::getTimeStr());
}
void loop() {
System::update();
}
0000000066: Started
0000000067: Connecting to network 'mySSID'... connected. IP address: 192.168.1.2
0000005969: Starting NTP client service... OK
0000005970: DS System v10100 initialization completed. Configured capabilities: SYS_LOG_HW SYS_TIME SYS_NETWORK
0000007974: System clock set: 2020/10/08 23:30:50
Current time: 2020/10/08 23:30:50
For detailed information and examples see Wiki pages.