srwi / ESPEssentials

Essentials to get you started with your Arduino projects using the ESP8266 and ESP32.
GNU Lesser General Public License v2.1
26 stars 5 forks source link
arduino esp32 esp32-arduino esp32-library esp8266 esp8266-arduino esp8266-library espressif wifimanager

ESPEssentials

ESP8266 ESP32 arduino-library-badge LGPL-2.1 license

Essentials for the ESP8266 and ESP32 to get you started with your Arduino project without any of the annoying stuff.

Features

Requirements

Usage

ESPEssentials only needs three lines of additional code:

#include <ESPEssentials.h>

void setup()
{
    ESPEssentials::init("Project Name");
}

void loop()
{
    ESPEssentials::handle();
}

Notes

Serial

By default the baud rate will be 115200. You can specify it with

ESPEssentials::init("Project Name", 9600);

WiFiManager

All WiFiManager methods can be accessed through the Wifi instance. For example to reset wifi settings:

ESPEssentials::Wifi.resetSettings();

More information can be found here.

Webserver

HTTP requests can be initialized within setup(). For example to reset wifi settings by accessing http://<device-ip>/reset_wifi:

ESPEssentials::WebServer.on("/reset_wifi", HTTP_GET, [&]() {
    ESPEssentials::WebServer.send(200, "text/plain", "Wifi settings reset.");
    ESPEssentials::Wifi.resetSettings();
});

Note: The routes /edit, /handle_update, /list, /reboot and /update are already used by ESPEssentials and can not be used.

To edit files inside your browser upload /data/edit.htm.gz to the root directory. The easiest way to do this is by accessing http://<device-ip>/edit and uploading it from there. Afterwards you can access the file editor via the same URL to edit files directly on the device.

Each file created/uploaded that way can be accessed via the corresponding URL (e.g. http://<device-ip>/myPage to access /myPage.htm).

OTA firmware update

An OTA password can be set up with

ESPEssentials::init("Project Name", "hunter2");

Web firmware update

Open http://<device-ip>/update and select a .bin file to upload a new firmware to the ESP8266/ESP32 from within the web browser. If a password has been supplied to init you will be asked to authenticate. The username is admin.