Open quorle opened 5 years ago
@quorle have a Look here for ESP01 support: https://github.com/carlymx/SPIFFS-Mod-for-ESP8266
Regards Tobias
Hello, have the Same Problem. whot is the minimum define? I neat am MQTT and minimal Web Interface for testing.
I have diasble:
//#define USE_WS2812FX_DMA 0 // 0 = Used PIN is ignored & set to RX/GPIO3; 1 = Used PIN is ignored & set to D4/GPIO2; 2 = Uses PIN is ignored & set to TX/GPIO1; Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
// Neopixel
#define PIN 2 // PIN (15 / D8) where neopixel / WS2811 strip is attached
#define NUMLEDS 42 // Number of leds in the strip
//#define LED_BUILTIN 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
#define RGBW // If defined, use RGBW Strips
const char HOSTNAME[] = "MCL_RGBW02"; // Friedly hostname
#define ENABLE_OTA 1 // If defined, enable Arduino OTA code. If set to 0 enable Arduino OTA code, if set to 1 enable ESP8266HTTPUpdateServer OTA code.
#define ENABLE_MQTT 1 // If defined use MQTT OR AMQTT, if set to 0 enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API, if set to 1, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client
#define ENABLE_MQTT_HOSTNAME_CHIPID // Uncomment/comment to add ESPChipID to end of MQTT hostname
//#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
//
//#define ENABLE_BUTTON 14 // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control, the value defines the input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
//#define ENABLE_BUTTON_GY33 12 // If defined, enable button handling code for GY-33 color sensor to scan color. The value defines the input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
//#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
#define ENABLE_STATE_SAVE 1 // If defined, save state on reboot, if set to 0 in EEPROM, if set to 1 on SPIFFS
#define ENABLE_LEGACY_ANIMATIONS // Enable Legacy Animations
//#define ENABLE_E131 // E1.31 implementation You have to uncomment #define USE_WS2812FX_DMA and set it to 0
//#define ENABLE_TV // Enable TV Animation
So you may want to disable OTA and remove E1.31 (DMX). Also check both MQTT and AMQTT (you need either-or, but they may behave differently)
Does someone have a step by step noob protocol for the ESP-01 ? I can't make it work :(
Hey, use this https://www.youtube.com/watch?v=7axaXO8cFo8. Just at 3:20 take esp 01_1m instead of nodemcu. This should be the best way
Thanks, I gave it a try but it does not work for me... came back to the Arduino IDE and now I have this error when I try to access the ESP /
File Not Found
URI: /
Method: GET
Arguments: 0
http://MYIP/list?dir=/ gives me
[{"type":"file","name":"neoconfig.json"}]
The code I use (and used to work)...
//#define USE_NEOANIMATIONFX // Uses NeoAnimationFX, PIN is ignored & set to RX/GPIO3 or UART method: D4/GPIO2, see: https://github.com/debsahu/NeoAnimationFX
#define USE_WS2812FX // Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
// Neopixel
#define PIN 0 // PIN (14 / D5) where neopixel / WS2811 strip is attached
#define NUMLEDS 60 // Number of leds in the strip
#define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
#define BUTTON 4 // Input pin (4 / D2) for switching the LED strip on / off, connect this PIN to ground to trigger button.
const char HOSTNAME[] = "McLighting01"; // Friedly hostname
#define HTTP_OTA // If defined, enable ESP8266HTTPUpdateServer OTA code.
//#define ENABLE_OTA // If defined, enable Arduino OTA code.
#define ENABLE_AMQTT // If defined, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client
//#define ENABLE_MQTT // If defined, enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API
//#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
#define ENABLE_LEGACY_ANIMATIONS
#if defined(USE_NEOANIMATIONFX) and defined(USE_WS2812FX)
#error "Cant have both NeoAnimationFX and WS2812FX enabled. Choose either one."
#endif
#if !defined(USE_NEOANIMATIONFX) and !defined(USE_WS2812FX)
#error "Need to either use NeoAnimationFX and WS2812FX mode."
#endif
#if defined(ENABLE_MQTT) and defined(ENABLE_AMQTT)
#error "Cant have both PubSubClient and AsyncMQTT enabled. Choose either one."
#endif
#if ( (defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_MQTT)) and (defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_AMQTT)) )
#error "To use HA, you have to either enable PubCubClient or AsyncMQTT"
#endif
#if ( !defined(ENABLE_HOMEASSISTANT) and defined(MQTT_HOME_ASSISTANT_SUPPORT) )
#error "To use HA support, you have to either enable Homeassistant component"
#endif
// parameters for automatically cycling favorite patterns
uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
{0xff0000, 200, 1, 5.0}, // blink red for 5 seconds
{0x00ff00, 200, 3, 10.0}, // wipe green for 10 seconds
{0x0000ff, 200, 11, 5.0}, // dual scan blue for 5 seconds
{0x0000ff, 200, 42, 15.0} // fireworks for 15 seconds
};
#if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)
#ifdef ENABLE_MQTT
#define MQTT_MAX_PACKET_SIZE 512
#define MQTT_MAX_RECONNECT_TRIES 4
int mqtt_reconnect_retries = 0;
char mqtt_intopic[strlen(HOSTNAME) + 4 + 5]; // Topic in will be: <HOSTNAME>/in
char mqtt_outtopic[strlen(HOSTNAME) + 5 + 5]; // Topic out will be: <HOSTNAME>/out
uint8_t qossub = 0; // PubSubClient can sub qos 0 or 1
#endif
#ifdef ENABLE_AMQTT
String mqtt_intopic = String(HOSTNAME) + "/in";
String mqtt_outtopic = String(HOSTNAME) + "/out";
uint8_t qossub = 0; // AMQTT can sub qos 0 or 1 or 2
uint8_t qospub = 0; // AMQTT can pub qos 0 or 1 or 2
#endif
#ifdef ENABLE_HOMEASSISTANT
String mqtt_ha = "home/" + String(HOSTNAME) + "_ha/";
String mqtt_ha_state_in = mqtt_ha + "state/in";
String mqtt_ha_state_out = mqtt_ha + "state/out";
const char* on_cmd = "ON";
const char* off_cmd = "OFF";
bool stateOn = false;
bool animation_on = false;
bool new_ha_mqtt_msg = false;
uint16_t color_temp = 327; // min is 154 and max is 500
#endif
//#define ENABLE_MQTT_HOSTNAME_CHIPID // Uncomment/comment to add ESPChipID to end of MQTT hostname
#ifdef ENABLE_MQTT_HOSTNAME_CHIPID
const char* mqtt_clientid = String(String(HOSTNAME) + "-" + String(ESP.getChipId())).c_str(); // MQTT ClientID
#else
const char* mqtt_clientid = HOSTNAME; // MQTT ClientID
#endif
char mqtt_host[64] = "";
char mqtt_port[6] = "";
char mqtt_user[32] = "";
char mqtt_pass[32] = "";
#endif
// ***************************************************************************
// Global variables / definitions
// ***************************************************************************
#define DBG_OUTPUT_PORT Serial // Set debug output port
// List of all color modes
#ifdef ENABLE_LEGACY_ANIMATIONS
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM };
MODE mode = RAINBOW; // Standard mode that is active when software starts
bool exit_func = false; // Global helper variable to get out of the color modes when mode changes
#else
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, CUSTOM };
MODE mode = SET_MODE; // Standard mode that is active when software starts
#endif
MODE prevmode = mode;
int ws2812fx_speed = 196; // Global variable for storing the delay between color changes --> smaller == faster
int brightness = 196; // Global variable for storing the brightness (255 == 100%)
int ws2812fx_mode = 0; // Helper variable to set WS2812FX modes
bool shouldSaveConfig = false; // For WiFiManger custom config
struct ledstate // Data structure to store a state of a single led
{
uint8_t red;
uint8_t green;
uint8_t blue;
};
typedef struct ledstate LEDState; // Define the datatype LEDState
LEDState ledstates[NUMLEDS]; // Get an array of led states to store the state of the whole strip
LEDState main_color = { 255, 0, 0 }; // Store the "main color" of the strip used in single color modes
#define ENABLE_STATE_SAVE_SPIFFS // If defined, saves state on SPIFFS
//#define ENABLE_STATE_SAVE_EEPROM // If defined, save state on reboot
#ifdef ENABLE_STATE_SAVE_EEPROM
char current_state[32]; // Keeps the current state representation
char last_state[32]; // Save the last state as string representation
unsigned long time_statechange = 0; // Time when the state last changed
int timeout_statechange_save = 5000; // Timeout in ms to wait before state is saved
bool state_save_requested = false; // State has to be saved after timeout
#endif
#ifdef ENABLE_STATE_SAVE_SPIFFS
bool updateStateFS = false;
#endif
// Button handling
#ifdef ENABLE_BUTTON
#define BTN_MODE_SHORT "STA| 1| 0|245|196|255|255|255" // Static white
#define BTN_MODE_MEDIUM "STA| 1| 48|245|196|255|102| 0" // Fire flicker
#define BTN_MODE_LONG "STA| 1| 46|253|196|255|102| 0" // Fireworks random
unsigned long keyPrevMillis = 0;
const unsigned long keySampleIntervalMs = 25;
byte longKeyPressCountMax = 80; // 80 * 25 = 2000 ms
byte mediumKeyPressCountMin = 20; // 20 * 25 = 500 ms
byte KeyPressCount = 0;
byte prevKeyState = HIGH; // button is active low
boolean buttonState = false;
#endif
Tried the new version but still does not work... compiling and uploading correctly but i can't connect to the ESP
Le croquis utilise 466224 octets (45%) de l'espace de stockage de programmes. Le maximum est de 1023984 octets.
Les variables globales utilisent 41372 octets (50%) de mémoire dynamique, ce qui laisse 40548 octets pour les variables locales. Le maximum est de 81920 octets.
esptool.py v2.6
2.6
esptool.py v2.6
Serial port /dev/cu.wchusbserial14320
Connecting....
Chip is ESP8266EX
Features: WiFi
MAC: dc:4f:22:19:cf:ff
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Compressed 470384 bytes to 323542...
Writing at 0x00000000... (5 %)
Writing at 0x00004000... (10 %)
Writing at 0x00008000... (15 %)
Writing at 0x0000c000... (20 %)
Writing at 0x00010000... (25 %)
Writing at 0x00014000... (30 %)
Writing at 0x00018000... (35 %)
Writing at 0x0001c000... (40 %)
Writing at 0x00020000... (45 %)
Writing at 0x00024000... (50 %)
Writing at 0x00028000... (55 %)
Writing at 0x0002c000... (60 %)
Writing at 0x00030000... (65 %)
Writing at 0x00034000... (70 %)
Writing at 0x00038000... (75 %)
Writing at 0x0003c000... (80 %)
Writing at 0x00040000... (85 %)
Writing at 0x00044000... (90 %)
Writing at 0x00048000... (95 %)
Writing at 0x0004c000... (100 %)
Wrote 470384 bytes (323542 compressed) at 0x00000000 in 34.2 seconds (effective 110.0 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
$//#define USE_WS2812FX_DMA // LED_PIN is ignored & set to RX/GPIO3 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
//#define USE_WS2812FX_UART1 // LED_PIN is ignored & set to D4/GPIO2 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
#define USE_WS2812FX_UART2 // LED_PIN is ignored & set to TX/GPIO1 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
// Neopixel
#define LED_PIN 0 // LED_PIN (14 / D5) where neopixel / WS2811 strip is attached
#define NUMLEDS 60 // Number of leds in the strip
//#define LED_TYPE_WS2811 // Uncomment if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
#define BUTTON 4 // Input pin (4 / D2) for switching the LED strip on / off, connect this PIN to ground to trigger button.
#define HOSTNAME "McLighting01" // Friedly hostname
#define HTTP_OTA // If defined, enable ESP8266HTTPUpdateServer OTA code.
//#define ENABLE_OTA // If defined, enable Arduino OTA code.
#define ENABLE_AMQTT // If defined, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client
//#define ENABLE_MQTT // If defined, enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API
#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT or ENABLE_AMQTT must be active
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
#define ENABLE_LEGACY_ANIMATIONS // Dont disbale this for now
//#define ENABLE_E131 // E1.31 implementation
//#define USE_HTML_MIN_GZ //comment for using index.htm & edit.htm from SPIFFs instead of PROGMEM
//#define CUSTOM_WS2812FX_ANIMATIONS //uncomment and put animations in "custom_ws2812fx_animations.h"
#ifdef ENABLE_E131
#define START_UNIVERSE 1 // First DMX Universe to listen for
#define END_UNIVERSE 2 // Last Universe to listen for, starting at UNIVERSE
// MUST: END_UNIVERSE >= START_UNIVERSE
#endif
//#define WIFIMGR_PORTAL_TIMEOUT 180
//#define WIFIMGR_SET_MANUAL_IP
#ifdef WIFIMGR_SET_MANUAL_IP
uint8_t _ip[4] = {192,168,0,128};
uint8_t _gw[4] = {192,168,0,1};
uint8_t _sn[4] = {255,255,255,0};
#endif
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
#define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87
#endif
#if defined(USE_WS2812FX_DMA) and defined(USE_WS2812FX_UART)
#error "Cant have both DMA and UART method."
#endif
#if defined(ENABLE_MQTT) and defined(ENABLE_AMQTT)
#error "Cant have both PubSubClient and AsyncMQTT enabled. Choose either one."
#endif
#if ( (defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_MQTT)) and (defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_AMQTT)) )
#error "To use HA, you have to either enable PubCubClient or AsyncMQTT"
#endif
#if ( !defined(ENABLE_HOMEASSISTANT) and defined(MQTT_HOME_ASSISTANT_SUPPORT) )
#error "To use HA support, you have to either enable Homeassistant component"
#endif
// parameters for automatically cycling favorite patterns
uint32_t autoParams[][4] = { // color, speed, mode, duration (milliseconds)
{0xff0000, 200, 1, 5000}, // blink red for 5 seconds
{0x00ff00, 200, 3, 10000}, // wipe green for 10 seconds
{0x0000ff, 200, 14, 5000}, // dual scan blue for 5 seconds
{0x0000ff, 200, 45, 15000} // fireworks for 15 seconds
};
#if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)
const char mqtt_will_topic[] = HOSTNAME "/status";
const char mqtt_will_payload[] = "OFFLINE";
const char mqtt_intopic[] = HOSTNAME "/in";
const char mqtt_outtopic[] = HOSTNAME "/out";
bool mqtt_lwt_boot_flag = true;
#ifdef ENABLE_MQTT
#define MQTT_MAX_PACKET_SIZE 512
#define MQTT_MAX_RECONNECT_TRIES 4
int mqtt_reconnect_retries = 0;
uint8_t qossub = 0; // PubSubClient can sub qos 0 or 1
#endif
#ifdef ENABLE_AMQTT
uint8_t qossub = 0; // AMQTT can sub qos 0 or 1 or 2
uint8_t qospub = 0; // AMQTT can pub qos 0 or 1 or 2
#endif
#ifdef ENABLE_HOMEASSISTANT
const char mqtt_ha_state_in[] = "home/" HOSTNAME "_ha/state/in";
const char mqtt_ha_state_out[] = "home/" HOSTNAME "_ha/state/out";
const char* on_cmd = "ON";
const char* off_cmd = "OFF";
bool stateOn = false;
bool animation_on = false;
bool new_ha_mqtt_msg = false;
uint16_t color_temp = 327; // min is 154 and max is 500
#endif
//#define ENABLE_MQTT_HOSTNAME_CHIPID // Uncomment/comment to add ESPChipID to end of MQTT hostname
#ifdef ENABLE_MQTT_HOSTNAME_CHIPID
char mqtt_clientid[64];
#else
const char mqtt_clientid[] = HOSTNAME;
#endif
char mqtt_host[64] = "";
char mqtt_port[6] = "";
char mqtt_user[32] = "";
char mqtt_pass[32] = "";
#endif
// ***************************************************************************
// Global variables / definitions
// ***************************************************************************
#define DBG_OUTPUT_PORT Serial // Set debug output port
// List of all color modes
#ifdef ENABLE_LEGACY_ANIMATIONS
#ifdef ENABLE_E131
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM, E131 };
#else
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM };
#endif
MODE mode = RAINBOW; // Standard mode that is active when software starts
bool exit_func = false; // Global helper variable to get out of the color modes when mode changes
#else
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, CUSTOM };
MODE mode = SET_MODE; // Standard mode that is active when software starts
#endif
MODE prevmode = mode;
int ws2812fx_speed = 196; // Global variable for storing the delay between color changes --> smaller == faster
int brightness = 196; // Global variable for storing the brightness (255 == 100%)
int ws2812fx_mode = 0; // Helper variable to set WS2812FX modes
bool shouldSaveConfig = false; // For WiFiManger custom config
struct ledstate // Data structure to store a state of a single led
{
uint8_t red;
uint8_t green;
uint8_t blue;
};
typedef struct ledstate LEDState; // Define the datatype LEDState
LEDState ledstates[NUMLEDS]; // Get an array of led states to store the state of the whole strip
LEDState main_color = { 255, 0, 0 }; // Store the "main color" of the strip used in single color modes
#define ENABLE_STATE_SAVE_SPIFFS // If defined, saves state on SPIFFS
//#define ENABLE_STATE_SAVE_EEPROM // If defined, save state on reboot
#ifdef ENABLE_STATE_SAVE_EEPROM
char current_state[32]; // Keeps the current state representation
char last_state[32]; // Save the last state as string representation
unsigned long time_statechange = 0; // Time when the state last changed
int timeout_statechange_save = 5000; // Timeout in ms to wait before state is saved
bool state_save_requested = false; // State has to be saved after timeout
#endif
#ifdef ENABLE_STATE_SAVE_SPIFFS
bool updateStateFS = false;
#endif
// Button handling
#ifdef ENABLE_BUTTON
#define BTN_MODE_SHORT "STA| 1| 0|245|196|255|255|255" // Static white
#define BTN_MODE_MEDIUM "STA| 1| 48|245|196|255|102| 0" // Fire flicker
#define BTN_MODE_LONG "STA| 1| 46|253|196|255|102| 0" // Fireworks random
unsigned long keyPrevMillis = 0;
const unsigned long keySampleIntervalMs = 25;
byte longKeyPressCountMax = 80; // 80 * 25 = 2000 ms
byte mediumKeyPressCountMin = 20; // 20 * 25 = 500 ms
byte KeyPressCount = 0;
byte prevKeyState = HIGH; // button is active low
boolean buttonState = false;
#endif
Replying to myself... after a lot of trial errors I get it working...
//#define USE_WS2812FX_DMA // LED_PIN is ignored & set to RX/GPIO3 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
#define USE_WS2812FX_UART1 // LED_PIN is ignored & set to D4/GPIO2 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
//#define USE_WS2812FX_UART2 // LED_PIN is ignored & set to TX/GPIO1 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
// Neopixel
#define LED_PIN 0 // LED_PIN (14 / D5) where neopixel / WS2811 strip is attached
#define NUMLEDS 60 // Number of leds in the strip
//#define LED_TYPE_WS2811 // Uncomment if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
#define BUTTON 4 // Input pin (4 / D2) for switching the LED strip on / off, connect this PIN to ground to trigger button.
#define HOSTNAME "McLighting01" // Friedly hostname
#define HTTP_OTA // If defined, enable ESP8266HTTPUpdateServer OTA code.
//#define ENABLE_OTA // If defined, enable Arduino OTA code.
#define ENABLE_AMQTT // If defined, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client
//#define ENABLE_MQTT // If defined, enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API
#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT or ENABLE_AMQTT must be active
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
#define ENABLE_LEGACY_ANIMATIONS // Dont disbale this for now
//#define ENABLE_E131 // E1.31 implementation
#define USE_HTML_MIN_GZ //comment for using index.htm & edit.htm from SPIFFs instead of PROGMEM
#define CUSTOM_WS2812FX_ANIMATIONS //uncomment and put animations in "custom_ws2812fx_animations.h"
#ifdef ENABLE_E131
#define START_UNIVERSE 1 // First DMX Universe to listen for
#define END_UNIVERSE 2 // Last Universe to listen for, starting at UNIVERSE
// MUST: END_UNIVERSE >= START_UNIVERSE
#endif
//#define WIFIMGR_PORTAL_TIMEOUT 180
//#define WIFIMGR_SET_MANUAL_IP
#ifdef WIFIMGR_SET_MANUAL_IP
uint8_t _ip[4] = {192,168,0,128};
uint8_t _gw[4] = {192,168,0,1};
uint8_t _sn[4] = {255,255,255,0};
#endif
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
#define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87
#endif
#if defined(USE_WS2812FX_DMA) and defined(USE_WS2812FX_UART)
#error "Cant have both DMA and UART method."
#endif
#if defined(ENABLE_MQTT) and defined(ENABLE_AMQTT)
#error "Cant have both PubSubClient and AsyncMQTT enabled. Choose either one."
#endif
#if ( (defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_MQTT)) and (defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_AMQTT)) )
#error "To use HA, you have to either enable PubCubClient or AsyncMQTT"
#endif
#if ( !defined(ENABLE_HOMEASSISTANT) and defined(MQTT_HOME_ASSISTANT_SUPPORT) )
#error "To use HA support, you have to either enable Homeassistant component"
#endif
// parameters for automatically cycling favorite patterns
uint32_t autoParams[][4] = { // color, speed, mode, duration (milliseconds)
{0xff0000, 200, 1, 5000}, // blink red for 5 seconds
{0x00ff00, 200, 3, 10000}, // wipe green for 10 seconds
{0x0000ff, 200, 14, 5000}, // dual scan blue for 5 seconds
{0x0000ff, 200, 45, 15000} // fireworks for 15 seconds
};
#if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)
const char mqtt_will_topic[] = HOSTNAME "/status";
const char mqtt_will_payload[] = "OFFLINE";
const char mqtt_intopic[] = HOSTNAME "/in";
const char mqtt_outtopic[] = HOSTNAME "/out";
bool mqtt_lwt_boot_flag = true;
#ifdef ENABLE_MQTT
#define MQTT_MAX_PACKET_SIZE 512
#define MQTT_MAX_RECONNECT_TRIES 4
int mqtt_reconnect_retries = 0;
uint8_t qossub = 0; // PubSubClient can sub qos 0 or 1
#endif
#ifdef ENABLE_AMQTT
uint8_t qossub = 0; // AMQTT can sub qos 0 or 1 or 2
uint8_t qospub = 0; // AMQTT can pub qos 0 or 1 or 2
#endif
#ifdef ENABLE_HOMEASSISTANT
const char mqtt_ha_state_in[] = "home/" HOSTNAME "_ha/state/in";
const char mqtt_ha_state_out[] = "home/" HOSTNAME "_ha/state/out";
const char* on_cmd = "ON";
const char* off_cmd = "OFF";
bool stateOn = false;
bool animation_on = false;
bool new_ha_mqtt_msg = false;
uint16_t color_temp = 327; // min is 154 and max is 500
#endif
//#define ENABLE_MQTT_HOSTNAME_CHIPID // Uncomment/comment to add ESPChipID to end of MQTT hostname
#ifdef ENABLE_MQTT_HOSTNAME_CHIPID
char mqtt_clientid[64];
#else
const char mqtt_clientid[] = HOSTNAME;
#endif
char mqtt_host[64] = "";
char mqtt_port[6] = "";
char mqtt_user[32] = "";
char mqtt_pass[32] = "";
#endif
// ***************************************************************************
// Global variables / definitions
// ***************************************************************************
#define DBG_OUTPUT_PORT Serial // Set debug output port
// List of all color modes
#ifdef ENABLE_LEGACY_ANIMATIONS
#ifdef ENABLE_E131
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM, E131 };
#else
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM };
#endif
MODE mode = RAINBOW; // Standard mode that is active when software starts
bool exit_func = false; // Global helper variable to get out of the color modes when mode changes
#else
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, CUSTOM };
MODE mode = SET_MODE; // Standard mode that is active when software starts
#endif
MODE prevmode = mode;
int ws2812fx_speed = 196; // Global variable for storing the delay between color changes --> smaller == faster
int brightness = 196; // Global variable for storing the brightness (255 == 100%)
int ws2812fx_mode = 0; // Helper variable to set WS2812FX modes
bool shouldSaveConfig = false; // For WiFiManger custom config
struct ledstate // Data structure to store a state of a single led
{
uint8_t red;
uint8_t green;
uint8_t blue;
};
typedef struct ledstate LEDState; // Define the datatype LEDState
LEDState ledstates[NUMLEDS]; // Get an array of led states to store the state of the whole strip
LEDState main_color = { 255, 0, 0 }; // Store the "main color" of the strip used in single color modes
#define ENABLE_STATE_SAVE_SPIFFS // If defined, saves state on SPIFFS
//#define ENABLE_STATE_SAVE_EEPROM // If defined, save state on reboot
#ifdef ENABLE_STATE_SAVE_EEPROM
char current_state[32]; // Keeps the current state representation
char last_state[32]; // Save the last state as string representation
unsigned long time_statechange = 0; // Time when the state last changed
int timeout_statechange_save = 5000; // Timeout in ms to wait before state is saved
bool state_save_requested = false; // State has to be saved after timeout
#endif
#ifdef ENABLE_STATE_SAVE_SPIFFS
bool updateStateFS = false;
#endif
// Button handling
#ifdef ENABLE_BUTTON
#define BTN_MODE_SHORT "STA| 1| 0|245|196|255|255|255" // Static white
#define BTN_MODE_MEDIUM "STA| 1| 48|245|196|255|102| 0" // Fire flicker
#define BTN_MODE_LONG "STA| 1| 46|253|196|255|102| 0" // Fireworks random
unsigned long keyPrevMillis = 0;
const unsigned long keySampleIntervalMs = 25;
byte longKeyPressCountMax = 80; // 80 * 25 = 2000 ms
byte mediumKeyPressCountMin = 20; // 20 * 25 = 500 ms
byte KeyPressCount = 0;
byte prevKeyState = HIGH; // button is active low
boolean buttonState = false;
#endif
I would need a little help. I would like to use the project on an ESP-01. I followed the instructions, but it does not work that way. Maybe someone can give me a well-described manual or help? In my PlatformIO.ino, I have entered the following:
And mine definitions.h looks like this:
But unfortunately I can not upload INDEX.htm. The connection with the MQTT works. But the LEDs do not synonymous unfortunately. Is there perhaps an illustrated instructions on how to adjust all this for an ESP-01 with connection to which PIN? I would really appreciate an answer as this project is really great.