Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
dc9f08e82c | |||
4d8146e64b | |||
39a13599c3 | |||
bcda1c9ea5 |
@ -4,7 +4,7 @@ ESP-NOW based light/led strip controller for ESP8266. Alternate firmware for Tuy
|
||||
|
||||
## Features
|
||||
|
||||
1. After turn on (or after rebooting) creates an access point named "ESP-NOW Light XXXXXXXXXXXX" with password "12345678" (IP 192.168.4.1). Access point will be shown during 5 minutes. The rest of the time access point is a hidden.
|
||||
1. After turn on (or after rebooting) creates an access point named "ESP-NOW light XXXXXXXXXXXX" with password "12345678" (IP 192.168.4.1). Access point will be shown during 5 minutes. The rest of the time access point is a hidden.
|
||||
2. Periodically transmission of system information (every 60 seconds), availability status (every 10 seconds) and state status (every 300 seconds) to the gateway.
|
||||
3. Saves the last state when the power is turned off. Goes to the last state when the power is turned on.
|
||||
4. Automatically adds light/led strip configuration to Home Assistan via MQTT discovery as a light.
|
||||
@ -25,5 +25,6 @@ See [here](https://github.com/aZholtikov/ESP-NOW-Light-Led-Strip/tree/main/hardw
|
||||
|
||||
1. A gateway is required. For details see [ESP-NOW Gateway](https://github.com/aZholtikov/ESP-NOW-Gateway).
|
||||
2. ESP-NOW network name must be set same of all another ESP-NOW devices in network.
|
||||
3. Upload the "data" folder (with web interface) into the filesystem before flashing.
|
||||
4. For using this firmware on Tuya/SmartLife WiFi light/led strip controllers, the WiFi module must be replaced with an ESP8266 compatible module (if necessary).
|
||||
3. If encryption is used, the key must be set same of all another ESP-NOW devices in network.
|
||||
4. Upload the "data" folder (with web interface) into the filesystem before flashing.
|
||||
5. For using this firmware on Tuya/SmartLife WiFi light/led strip controllers, the WiFi module must be replaced with an ESP8266 compatible module (if necessary).
|
||||
|
@ -2,20 +2,24 @@
|
||||
platform = espressif8266
|
||||
board = esp12e
|
||||
framework = arduino
|
||||
board_build.filesystem = littlefs
|
||||
board_build.ldscript = eagle.flash.4m2m.ld
|
||||
lib_deps =
|
||||
https://github.com/aZholtikov/ZHNetwork
|
||||
https://github.com/aZholtikov/ZHConfig
|
||||
bblanchon/ArduinoJson@^6.19.4
|
||||
me-no-dev/ESP Async WebServer@^1.2.3
|
||||
https://github.com/aZholtikov/Async-Web-Server
|
||||
https://github.com/bblanchon/ArduinoJson
|
||||
|
||||
[env:ESP-12E-OTA]
|
||||
platform = espressif8266
|
||||
board = esp12e
|
||||
framework = arduino
|
||||
board_build.filesystem = littlefs
|
||||
board_build.ldscript = eagle.flash.4m2m.ld
|
||||
upload_port = 192.168.4.1
|
||||
upload_protocol = espota
|
||||
lib_deps =
|
||||
https://github.com/aZholtikov/ZHNetwork
|
||||
https://github.com/aZholtikov/ZHConfig
|
||||
bblanchon/ArduinoJson@^6.19.4
|
||||
me-no-dev/ESP Async WebServer@^1.2.3
|
||||
https://github.com/aZholtikov/Async-Web-Server
|
||||
https://github.com/bblanchon/ArduinoJson
|
22
src/main.cpp
22
src/main.cpp
@ -1,6 +1,7 @@
|
||||
#include "ArduinoJson.h"
|
||||
#include "ArduinoOTA.h"
|
||||
#include "ESPAsyncWebServer.h"
|
||||
#include "ESPAsyncWebServer.h" // https://github.com/aZholtikov/Async-Web-Server
|
||||
#include "LittleFS.h"
|
||||
#include "Ticker.h"
|
||||
#include "ZHNetwork.h"
|
||||
#include "ZHConfig.h"
|
||||
@ -30,7 +31,7 @@ typedef struct
|
||||
|
||||
std::vector<espnow_message_t> espnowMessage;
|
||||
|
||||
const String firmware{"1.12"};
|
||||
const String firmware{"1.14"};
|
||||
|
||||
String espnowNetName{"DEFAULT"};
|
||||
|
||||
@ -83,7 +84,7 @@ void setup()
|
||||
{
|
||||
analogWriteRange(255);
|
||||
|
||||
SPIFFS.begin();
|
||||
LittleFS.begin();
|
||||
|
||||
loadConfig();
|
||||
|
||||
@ -102,6 +103,7 @@ void setup()
|
||||
|
||||
WiFi.setSleepMode(WIFI_NONE_SLEEP);
|
||||
myNet.begin(espnowNetName.c_str());
|
||||
// myNet.setCryptKey("VERY_LONG_CRYPT_KEY"); // If encryption is used, the key must be set same of all another ESP-NOW devices in network.
|
||||
|
||||
myNet.setOnBroadcastReceivingCallback(onBroadcastReceiving);
|
||||
myNet.setOnUnicastReceivingCallback(onUnicastReceiving);
|
||||
@ -197,6 +199,7 @@ void onConfirmReceiving(const uint8_t *target, const uint16_t id, const bool sta
|
||||
{
|
||||
espnow_message_t message = espnowMessage[i];
|
||||
if (message.id == id)
|
||||
{
|
||||
if (status)
|
||||
espnowMessage.erase(espnowMessage.begin() + i);
|
||||
else
|
||||
@ -204,14 +207,15 @@ void onConfirmReceiving(const uint8_t *target, const uint16_t id, const bool sta
|
||||
message.id = myNet.sendUnicastMessage(message.message, gatewayMAC, true);
|
||||
espnowMessage.at(i) = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loadConfig()
|
||||
{
|
||||
if (!SPIFFS.exists("/config.json"))
|
||||
if (!LittleFS.exists("/config.json"))
|
||||
saveConfig();
|
||||
File file = SPIFFS.open("/config.json", "r");
|
||||
File file = LittleFS.open("/config.json", "r");
|
||||
String jsonFile = file.readString();
|
||||
StaticJsonDocument<512> json;
|
||||
deserializeJson(json, jsonFile);
|
||||
@ -251,7 +255,7 @@ void saveConfig()
|
||||
json["green"] = green;
|
||||
json["blue"] = blue;
|
||||
json["system"] = "empty";
|
||||
File file = SPIFFS.open("/config.json", "w");
|
||||
File file = LittleFS.open("/config.json", "w");
|
||||
serializeJsonPretty(json, file);
|
||||
file.close();
|
||||
}
|
||||
@ -259,7 +263,7 @@ void saveConfig()
|
||||
void setupWebServer()
|
||||
{
|
||||
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||
{ request->send(SPIFFS, "/index.htm"); });
|
||||
{ request->send(LittleFS, "/index.htm"); });
|
||||
|
||||
webServer.on("/setting", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||
{
|
||||
@ -281,8 +285,8 @@ void setupWebServer()
|
||||
|
||||
webServer.onNotFound([](AsyncWebServerRequest *request)
|
||||
{
|
||||
if (SPIFFS.exists(request->url()))
|
||||
request->send(SPIFFS, request->url());
|
||||
if (LittleFS.exists(request->url()))
|
||||
request->send(LittleFS, request->url());
|
||||
else
|
||||
{
|
||||
request->send(404, "text/plain", "File Not Found");
|
||||
|
Reference in New Issue
Block a user