diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc843153..398d895d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,8 @@ jobs: - "esp32-m5tough-ble" - "esp32-m5stick-c-ble" - "esp32-m5stick-cp-ble" - - "esp32-m5atom" + - "esp32-m5atom-matrix" + - "esp32-m5atom-lite" - "esp32dev-rtl_433" - "heltec-rtl_433" - "esp32dev-multi_receiver" diff --git a/docs/upload/web-install.md b/docs/upload/web-install.md index b4e61f02..87631d5a 100644 --- a/docs/upload/web-install.md +++ b/docs/upload/web-install.md @@ -19,7 +19,8 @@ The table below describes the libraries and the modules of each board configurat |:-:|:-:|:-:|:-:|:-:|:-:|:-:| |**ESP32**| |esp32-lolin32lite-ble|ESP32 Lolin lite|Suitable for low power with BLE gateway, [tutorial](https://1technophile.blogspot.com/2021/04/low-power-esp32-ble-gateway.html)|-|-|X|-| -|esp32-m5atom|M5Atom|Compact enclosure ESP32 with BLE gateway|-|(Emit)|X|-| +|esp32-m5atom-lite|M5Atom Lite|Compact enclosure ESP32 with BLE gateway|-|(Emit)|X|-| +|esp32-m5atom-matrix|M5Atom Matrix|Compact enclosure ESP32 with BLE gateway|-|(Emit)|X|-| |esp32-m5stack-ble|M5Stack Core|Expandable module with BLE gateway, display, and little IR emitter|-|-|X|-| |esp32-m5stick-ble|M5Stick Grey|Expandable module with BLE gateway and little IR emitter|-|(Emit)|X|-| |esp32-m5stick-c-ble|M5Stick C Orange|Expandable module with BLE gateway, display, and little IR emitter|-|(Emit)|X|-| @@ -33,6 +34,8 @@ The table below describes the libraries and the modules of each board configurat |esp32dev-ble|ESP32 dev board|BLE gateway with one scan every 55s per default|-|-|X|-| |esp32dev-ble-openhab|ESP32 dev board|BLE gateway with one scan every 55s per default and OpenHAB discovery|-|-|X|-| |esp32dev-ble-mqtt-undecoded|ESP32 dev board|BLE gateway with the decoding offloaded to [Theengs Gateway](https://gateway.theengs.io/)|-|-|X|-| +|esp32s3-dev-c1-ble|ESP32 dev board|BLE gateway with one scan every 55s per default|-|-|X|-| +|esp32c3-dev-m1-ble|ESP32 dev board|BLE gateway with one scan every 55s per default|-|-|X|-| |esp32dev-gf-sun-inverter|ESP32 dev board|RS232 reading of GridFree Sun Inverter|-|-|-|-| |esp32dev-ir|ESP32 dev board|Infrared (Emitting and receiving) using [IRremoteESP8266](https://github.com/crankyoldgit/IRremoteESP8266)|-|X|-|-| |esp32dev-multi_receiver|ESP32 dev board|Multi RF library with the possibility to switch between [ESPilight](https://github.com/puuu/ESPiLight), [RTL_433_ESP](https://github.com/NorthernMan54/rtl_433_ESP), [NewRemoteSwitch](https://github.com/1technophile/NewRemoteSwitch) and [RCSwitch](https://github.com/1technophile/rc-switch), need CC1101|X|-|-|-| diff --git a/main/User_config.h b/main/User_config.h index 50e9aa6c..d5142b15 100644 --- a/main/User_config.h +++ b/main/User_config.h @@ -388,48 +388,88 @@ int lowpowermode = DEFAULT_LOW_POWER_MODE; # define ota_timeout_millis 30000 #endif +#ifndef RGB_INDICATORS // Management of Errors, reception/emission and informations indicators with basic LED /*-------------DEFINE PINs FOR STATUS LEDs----------------*/ -#ifndef LED_SEND_RECEIVE -# ifdef ESP8266 -# define LED_SEND_RECEIVE 40 -# elif ESP32 -# define LED_SEND_RECEIVE 40 -# elif __AVR_ATmega2560__ //arduino mega -# define LED_SEND_RECEIVE 40 -# else //arduino uno/nano -# define LED_SEND_RECEIVE 40 +# ifndef LED_SEND_RECEIVE +# ifdef ESP8266 +# define LED_SEND_RECEIVE 40 +# elif ESP32 +# define LED_SEND_RECEIVE 40 +# elif __AVR_ATmega2560__ //arduino mega +# define LED_SEND_RECEIVE 40 +# else //arduino uno/nano +# define LED_SEND_RECEIVE 40 +# endif # endif -#endif -#ifndef LED_SEND_RECEIVE_ON -# define LED_SEND_RECEIVE_ON HIGH -#endif -#ifndef LED_ERROR -# ifdef ESP8266 -# define LED_ERROR 42 -# elif ESP32 -# define LED_ERROR 42 -# elif __AVR_ATmega2560__ //arduino mega -# define LED_ERROR 42 -# else //arduino uno/nano -# define LED_ERROR 42 +# ifndef LED_SEND_RECEIVE_ON +# define LED_SEND_RECEIVE_ON HIGH # endif -#endif -#ifndef LED_ERROR_ON -# define LED_ERROR_ON HIGH -#endif -#ifndef LED_INFO -# ifdef ESP8266 -# define LED_INFO 44 -# elif ESP32 -# define LED_INFO 44 -# elif __AVR_ATmega2560__ //arduino mega -# define LED_INFO 44 -# else //arduino uno/nano -# define LED_INFO 44 +# ifndef LED_ERROR +# ifdef ESP8266 +# define LED_ERROR 42 +# elif ESP32 +# define LED_ERROR 42 +# elif __AVR_ATmega2560__ //arduino mega +# define LED_ERROR 42 +# else //arduino uno/nano +# define LED_ERROR 42 +# endif # endif -#endif -#ifndef LED_INFO_ON -# define LED_INFO_ON HIGH +# ifndef LED_ERROR_ON +# define LED_ERROR_ON HIGH +# endif +# ifndef LED_INFO +# ifdef ESP8266 +# define LED_INFO 44 +# elif ESP32 +# define LED_INFO 44 +# elif __AVR_ATmega2560__ //arduino mega +# define LED_INFO 44 +# else //arduino uno/nano +# define LED_INFO 44 +# endif +# endif +# ifndef LED_INFO_ON +# define LED_INFO_ON HIGH +# endif +# define SetupIndicators() \ + pinMode(LED_SEND_RECEIVE, OUTPUT); \ + pinMode(LED_INFO, OUTPUT); \ + pinMode(LED_ERROR, OUTPUT); \ + SendReceiveIndicatorOFF(); \ + InfoIndicatorOFF(); \ + ErrorIndicatorOFF(); + +# define ErrorIndicatorON() digitalWrite(LED_ERROR, LED_ERROR_ON) +# define ErrorIndicatorOFF() digitalWrite(LED_ERROR, !LED_ERROR_ON) +# define SendReceiveIndicatorON() digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON) +# define SendReceiveIndicatorOFF() digitalWrite(LED_SEND_RECEIVE, !LED_SEND_RECEIVE_ON) +# define InfoIndicatorON() digitalWrite(LED_INFO, LED_INFO_ON) +# define InfoIndicatorOFF() digitalWrite(LED_INFO, !LED_INFO_ON) +#else // Management of Errors, reception/emission and informations indicators with RGB LED +# include +CRGB leds[FASTLED_IND_NUM_LEDS]; +# define SetupIndicators() \ + FastLED.addLeds(leds, FASTLED_IND_NUM_LEDS); \ + FastLED.setBrightness(20); /* Error, warning and infos display management*/ +# define ErrorIndicatorON() \ + leds[0] = CRGB::Red; \ + FastLED.show() +# define ErrorIndicatorOFF() \ + leds[0] = CRGB::Black; \ + FastLED.show() +# define SendReceiveIndicatorON() \ + leds[0] = CRGB::Blue; \ + FastLED.show() +# define SendReceiveIndicatorOFF() \ + leds[0] = CRGB::Black; \ + FastLED.show() +# define InfoIndicatorON() \ + leds[0] = CRGB::Green; \ + FastLED.show() +# define InfoIndicatorOFF() \ + leds[0] = CRGB::Black; \ + FastLED.show() #endif #ifdef ESP8266 diff --git a/main/ZboardM5.ino b/main/ZboardM5.ino index d020c337..d7348c42 100644 --- a/main/ZboardM5.ino +++ b/main/ZboardM5.ino @@ -218,7 +218,7 @@ void drawLogo(int logoSize, int circle1X, int circle1Y, bool circle1, bool circl } void M5Print(char* line1, char* line2, char* line3) { - if (lowpowermode == 2) digitalWrite(LED_INFO, LED_INFO_ON); + if (lowpowermode == 2) InfoIndicatorON(); wakeScreen(NORMAL_LCD_BRIGHTNESS); M5.Lcd.fillScreen(TFT_WHITE); drawLogo(M5.Lcd.width() * 0.1875, (M5.Lcd.width() / 2) - M5.Lcd.width() * 0.24, M5.Lcd.height() * 0.5, true, true, true, true, true, true); @@ -227,6 +227,6 @@ void M5Print(char* line1, char* line2, char* line3) { M5.Lcd.drawString(line2, 5, M5.Lcd.height() * 0.8, 1); M5.Lcd.drawString(line3, 5, M5.Lcd.height() * 0.9, 1); delay(2000); - digitalWrite(LED_INFO, !LED_INFO_ON); // to switch off no need of condition + InfoIndicatorOFF(); // to switch off no need of condition } #endif diff --git a/main/main.ino b/main/main.ino index 660930a9..291f4546 100644 --- a/main/main.ino +++ b/main/main.ino @@ -316,7 +316,7 @@ void pub(const char* topicori, JsonObject& data) { String dataAsString = ""; serializeJson(data, dataAsString); Log.notice(F("Send on %s msg %s" CR), topicori, dataAsString.c_str()); - digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON); + SendReceiveIndicatorON(); String topic = String(mqtt_topic) + String(gateway_name) + String(topicori); #if valueAsATopic # ifdef ZgatewayPilight @@ -576,9 +576,9 @@ void connectMQTT() { if (mqtt_secure) Log.warning(F("failed, ssl error code=%d" CR), ((WiFiClientSecure*)eClient)->getLastSSLError()); #endif - digitalWrite(LED_ERROR, LED_ERROR_ON); + ErrorIndicatorON(); delayWithOTA(2000); - digitalWrite(LED_ERROR, !LED_ERROR_ON); + ErrorIndicatorOFF(); delayWithOTA(5000); if (failure_number_mqtt > maxRetryWatchDog) { unsigned long millis_since_last_ota; @@ -630,12 +630,7 @@ void setup() { Log.notice(F(CR "************* WELCOME TO OpenMQTTGateway **************" CR)); //setup LED status - pinMode(LED_SEND_RECEIVE, OUTPUT); - pinMode(LED_INFO, OUTPUT); - pinMode(LED_ERROR, OUTPUT); - digitalWrite(LED_SEND_RECEIVE, !LED_SEND_RECEIVE_ON); - digitalWrite(LED_INFO, !LED_INFO_ON); - digitalWrite(LED_ERROR, !LED_ERROR_ON); + SetupIndicators(); #if defined(ESP8266) || defined(ESP32) # ifdef ESP8266 @@ -901,8 +896,8 @@ void setOTA() { ArduinoOTA.onStart([]() { Log.trace(F("Start OTA, lock other functions" CR)); - digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON); - digitalWrite(LED_ERROR, LED_ERROR_ON); + ErrorIndicatorON(); + SendReceiveIndicatorON(); last_ota_activity_millis = millis(); # if defined(ZgatewayBT) && defined(ESP32) stopProcessing(); @@ -912,8 +907,8 @@ void setOTA() { ArduinoOTA.onEnd([]() { Log.trace(F("\nOTA done" CR)); last_ota_activity_millis = 0; - digitalWrite(LED_SEND_RECEIVE, !LED_SEND_RECEIVE_ON); - digitalWrite(LED_ERROR, !LED_ERROR_ON); + ErrorIndicatorOFF(); + SendReceiveIndicatorOFF(); # if defined(ZgatewayBT) && defined(ESP32) startProcessing(); # endif @@ -925,8 +920,8 @@ void setOTA() { }); ArduinoOTA.onError([](ota_error_t error) { last_ota_activity_millis = millis(); - digitalWrite(LED_SEND_RECEIVE, !LED_SEND_RECEIVE_ON); - digitalWrite(LED_ERROR, !LED_ERROR_ON); + ErrorIndicatorOFF(); + SendReceiveIndicatorOFF(); # if defined(ZgatewayBT) && defined(ESP32) startProcessing(); # endif @@ -1241,8 +1236,8 @@ void setup_wifimanager(bool reset_settings) { } # endif - digitalWrite(LED_ERROR, LED_ERROR_ON); - digitalWrite(LED_INFO, LED_INFO_ON); + ErrorIndicatorON(); + InfoIndicatorON(); Log.notice(F("Connect your phone to WIFI AP: %s with PWD: %s" CR), WifiManager_ssid, WifiManager_password); //fetches ssid and pass and tries to connect //if it does not connect it starts an access point with the specified name @@ -1254,8 +1249,8 @@ void setup_wifimanager(bool reset_settings) { watchdogReboot(3); delay(5000); } - digitalWrite(LED_ERROR, !LED_ERROR_ON); - digitalWrite(LED_INFO, !LED_INFO_ON); + ErrorIndicatorOFF(); + InfoIndicatorOFF(); } displayPrint("Wifi connected"); @@ -1391,8 +1386,8 @@ void loop() { // Switch off of the LED after TimeLedON if (now > (timer_led_measures + (TimeLedON * 1000))) { timer_led_measures = millis(); - digitalWrite(LED_INFO, !LED_INFO_ON); - digitalWrite(LED_SEND_RECEIVE, !LED_SEND_RECEIVE_ON); + InfoIndicatorOFF(); + SendReceiveIndicatorOFF(); } #if defined(ESP8266) || defined(ESP32) @@ -1407,7 +1402,7 @@ void loop() { #endif failure_number_ntwk = 0; if (client.loop()) { // MQTT client is still connected - digitalWrite(LED_INFO, LED_INFO_ON); + InfoIndicatorON(); failure_number_ntwk = 0; // We have just re-connected if connected was previously false bool justReconnected = !connected; @@ -1534,9 +1529,9 @@ void loop() { } else { // disconnected from network connected = false; Log.warning(F("Network disconnected:" CR)); - digitalWrite(LED_ERROR, LED_ERROR_ON); + ErrorIndicatorON(); delay(2000); // add a delay to avoid ESP32 crash and reset - digitalWrite(LED_ERROR, !LED_ERROR_ON); + ErrorIndicatorOFF(); delay(2000); #if defined(ESP8266) || defined(ESP32) && !defined(ESP32_ETHERNET) # ifdef ESP32 // If used with ESP8266 this method prevent the reconnection @@ -1791,7 +1786,7 @@ void receivingMQTT(char* topicOri, char* datacallback) { MQTTHttpsFWUpdate(topicOri, jsondata); # endif #endif - digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON); + SendReceiveIndicatorON(); MQTTtoSYS(topicOri, jsondata); } else { // not a json object --> simple decoding @@ -1862,8 +1857,8 @@ void MQTTHttpsFWUpdate(char* topicOri, JsonObject& HttpsFwUpdateData) { # endif Log.warning(F("Starting firmware update" CR)); - digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON); - digitalWrite(LED_ERROR, LED_ERROR_ON); + SendReceiveIndicatorON(); + ErrorIndicatorON(); # if defined(ZgatewayBT) && defined(ESP32) stopProcessing(); @@ -1958,8 +1953,8 @@ void MQTTHttpsFWUpdate(char* topicOri, JsonObject& HttpsFwUpdateData) { break; } - digitalWrite(LED_SEND_RECEIVE, !LED_SEND_RECEIVE_ON); - digitalWrite(LED_ERROR, !LED_ERROR_ON); + SendReceiveIndicatorOFF(); + ErrorIndicatorOFF(); # if defined(ZgatewayBT) && defined(ESP32) startProcessing(); diff --git a/platformio.ini b/platformio.ini index 1b6cd00e..daba70f4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -56,7 +56,8 @@ extra_configs = ;default_envs = esp32-m5tough-ble ;default_envs = esp32-m5stick-c-ble ;default_envs = esp32-m5stick-cp-ble -;default_envs = esp32-m5atom +;default_envs = esp32-m5atom-matrix +;default_envs = esp32-m5atom-lite ;default_envs = tinypico-ble ;default_envs = ttgo-lora32-v1-868 ;default_envs = ttgo-lora32-v1-915 @@ -123,7 +124,7 @@ wifimanager8266 = https://github.com/tzapu/WiFiManager.git#2.0.5-beta ethernet = Ethernet esp8266_mdns = esp8266_mdns wire = Wire -fastled = fastled/FastLED@3.3.2 +fastled = fastled/FastLED@3.5.0 onewire = paulstoffregen/OneWire@2.3.7 dallastemperature = DallasTemperature m5stickc = M5StickC@0.2.0 @@ -729,7 +730,7 @@ build_flags = '-DGateway_Name="OpenMQTTGateway_ESP32_M5STICK_CP_BLE_IR"' board_upload.speed = 1500000 -[env:esp32-m5atom] +[env:esp32-m5atom-matrix] platform = ${com.esp32_platform} board = pico32 board_build.partitions = min_spiffs.csv @@ -739,6 +740,7 @@ lib_deps = ${libraries.ble} ${libraries.decoder} ${libraries.irremoteesp} + ${libraries.fastled} build_flags = ${com-esp.build_flags} '-DZgatewayBT="BT"' @@ -746,7 +748,36 @@ build_flags = '-DTRIGGER_GPIO=39' '-DSLEEP_BUTTON=39' '-DIR_EMITTER_GPIO=12' - '-DGateway_Name="OpenMQTTGateway_ESP32_ATOM_BLE_IR"' + '-DFASTLED_IND_DATA_GPIO=27,GRB' + '-DFASTLED_IND_TYPE=WS2812' + '-DFASTLED_IND_NUM_LEDS=25' + '-DRGB_INDICATORS=true' + '-DGateway_Name="OpenMQTTGateway_ATOM_M"' +board_upload.speed = 1500000 + +[env:esp32-m5atom-lite] +platform = ${com.esp32_platform} +board = pico32 +board_build.partitions = min_spiffs.csv +lib_deps = + ${com-esp.lib_deps} + ${libraries.wifimanager32} + ${libraries.ble} + ${libraries.decoder} + ${libraries.irremoteesp} + ${libraries.fastled} +build_flags = + ${com-esp.build_flags} + '-DZgatewayBT="BT"' + '-DZgatewayIR="IR"' + '-DTRIGGER_GPIO=39' + '-DSLEEP_BUTTON=39' + '-DIR_EMITTER_GPIO=12' + '-DFASTLED_IND_DATA_GPIO=27,GRB' + '-DFASTLED_IND_TYPE=WS2812' + '-DFASTLED_IND_NUM_LEDS=1' + '-DRGB_INDICATORS=true' + '-DGateway_Name="OpenMQTTGateway_ATOM_L"' board_upload.speed = 1500000 [env:esp32dev-rtl_433] @@ -1398,13 +1429,14 @@ lib_deps = ${libraries.wifimanager32} ${libraries.ble} ${libraries.decoder} + ${libraries.fastled} build_flags = ${com-esp.build_flags} '-DZgatewayBT="BT"' - '-DLED_SEND_RECEIVE=12' - '-DLED_SEND_RECEIVE_ON=0' - '-DLED_INFO=13' - '-DLED_ERROR=14' + '-DFASTLED_IND_DATA_GPIO=48' + '-DFASTLED_IND_TYPE=NEOPIXEL' + '-DFASTLED_IND_NUM_LEDS=1' + '-DRGB_INDICATORS=true' '-DGateway_Name="OpenMQTTGateway_ESP32_BLE"' [env:esp32c3-dev-m1-ble] @@ -1416,11 +1448,12 @@ lib_deps = ${libraries.wifimanager32} ${libraries.ble} ${libraries.decoder} + ${libraries.fastled} build_flags = ${com-esp.build_flags} '-DZgatewayBT="BT"' - '-DLED_SEND_RECEIVE=2' - '-DLED_SEND_RECEIVE_ON=0' - '-DLED_INFO=6' - '-DLED_ERROR=7' + '-DFASTLED_IND_DATA_GPIO=8' + '-DFASTLED_IND_TYPE=NEOPIXEL' + '-DFASTLED_IND_NUM_LEDS=1' + '-DRGB_INDICATORS=true' '-DGateway_Name="OpenMQTTGateway_ESP32_BLE"'