From e2af1b5f3bb6f37bc06d4c51103fb203387d22e9 Mon Sep 17 00:00:00 2001 From: rori1977 <56794204+rori1977@users.noreply.github.com> Date: Tue, 28 Mar 2023 09:22:27 +0200 Subject: [PATCH 01/14] Update CHANGES.md correction of 2 spelling mistakes only --- src/CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index debcf40d..e0591a00 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -3,7 +3,7 @@ Changelog v0.6.0 ## General * improved night time calculation time to 1 minute after last communication pause #515 * refactored code for better readability -* improved Hoymiles commuinication (retransmits, immediate power limit transmission, timing at all) +* improved Hoymiles communication (retransmits, immediate power limit transmission, timing at all) * renamed firmware binaries * add login / logout to menu * add display support for `SH1106`, `SSD1306`, `Nokia` and `ePaper 1.54"` (ESP32 only) @@ -13,7 +13,7 @@ Changelog v0.6.0 * improved wifi connection and stability (connect to strongest AP) * addded Hoymiles alarm IDs to log * improved `System` information page (eg. radio statitistics) -* improved UI (repsonsive design, (optional) dark mode) +* improved UI (responsive design, (optional) dark mode) * improved system stability (reduced `heap-fragmentation`, don't break settings on failure) #644, #645 * added support for 2nd generation of Hoymiles inverters, MI series * improved JSON API for more stable WebUI From 3b4c727d5cc118f0a295799a36449661422a429b Mon Sep 17 00:00:00 2001 From: Argafal Date: Wed, 29 Mar 2023 09:09:13 +0200 Subject: [PATCH 02/14] Update Getting_Started.md --- Getting_Started.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Getting_Started.md b/Getting_Started.md index e73277f0..876a68ea 100644 --- a/Getting_Started.md +++ b/Getting_Started.md @@ -154,7 +154,7 @@ Example wiring for a 38pin ESP32 module ##### ESP32 GPIO settings -For this wiring, set the 3 individual GPIOs under the /setup URL: +CS, CE, IRQ must be set according to how they are wired up. For the diagram above, set the 3 individual GPIOs under the /setup URL as follows: ``` CS D1 (GPIO5) @@ -162,14 +162,14 @@ CE D2 (GPIO4) IRQ D0 (GPIO16 - no IRQ!) ``` -ATTENTION: From development version 108 onwards, also MISO, MOSI and SCLK -are configurable. Their defaults are correct for 'standard' ESP32 boards -and non-settable for ESP8266 (as this chip cannot move them elsewhere). -If you have an existing install though, you might see '0' in the web GUI. +IMPORTANT: From development version 108/release 0.6.0 onwards, also MISO, MOSI, and SCLK +are configurable. On new installations, their defaults are correct for most ESP32 boards. +These pins cannot be configured for ESP82xx boards, as this chip cannot move them elsewhere. -Set MISO=19, MOSI=23, SCLK=18 in GUI and save for existing installs, this is the old -correct default for most ESP32 boards, for ESP82xx, a simple settings save should suffice. -Reboot afterwards. +If you are upgrading an existing install though, you might see that these pins are set to '0' in the web GUI. +Communication with the NRF module wont work. For upgrading an existing installations, set MISO=19, MOSI=23, SCLK=18 in the settings. +This is the correct default for most ESP32 boards. On ESP82xx, simply saving the settings without changes should suffice. +Save and reboot. ## Flash the Firmware on your Ahoy DTU Hardware From 1bc2d2551cc60f4b9cc005bb0efd4472e7f76be4 Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 31 Mar 2023 00:08:40 +0200 Subject: [PATCH 03/14] improved phrasing of readme's --- Getting_Started.md | 16 +++++++--------- README.md | 6 ++---- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Getting_Started.md b/Getting_Started.md index 876a68ea..3a031af0 100644 --- a/Getting_Started.md +++ b/Getting_Started.md @@ -1,13 +1,12 @@ ## Overview -This page describes how the module of a Wemos D1 mini and ESP8266 is wired to the radio module and is flashed with the latest Firmware.
-Further information will help you to communicate to the compatible inverters. +On this page, you'll find detailed instructions on how to wire the module of a Wemos D1 mini or ESP32 to the radio module, as well as how to flash it with the latest firmware. This information will enable you to communicate with compatible inverters. You find the full [User_Manual here](User_Manual.md) ## Compatiblity -For now the following Inverters should work out of the box: +The following inverters are currently supported out of the box: Hoymiles Inverters @@ -55,12 +54,11 @@ Solenso Inverters: ## Things needed -In order to build your own Ahoy DTU, you will need some things.
-This list is not closing as the Maker Community offers more Boards than we could cover in this Readme.

+If you're interested in building your own AhoyDTU, you'll need a few things to get started. While we've provided a list of recommended boards below, keep in mind that the maker community is constantly developing new and innovative options that we may not have covered in this readme.. -We suggest to use a WEMOS D1 mini Board as well as a NRF24L01+ Breakout Board as a bare minimum.
-Any other ESP8266 Board with at least 4MBytes of ROM could work as well, depending on your skills and goals.
-Make sure the NRF24L01+ module has the "+" in its name as we depend on the 250kbps features provided only with the plus-variant. +For optimal performance, we recommend using a Wemos D1 mini or ESP32 along with a NRF24L01+ breakout board as a bare minimum. However, if you have experience working with other ESP boards, any board with at least 4MBytes of ROM may be suitable, depending on your skills. + +Just be sure that the NRF24L01+ module you choose includes the "+" in its name, as we rely on the 250kbps features that are only provided by the plus-variant. | **Parts** | **Price** | | --- | --- | @@ -70,7 +68,7 @@ Make sure the NRF24L01+ module has the "+" in its name as we depend on the 250kb | Jumper Wire Steckbrücken Steckbrett weiblich-weiblich | 2,49 Euro | | **Total costs** | **10,34 Euro** | -To also run our sister project OpenDTU and be upwards compatible for the future we would recommend to spend some more money on an ESP32 board which has two CPU cores and a NRF24L01+ module with external antenna. +If you're interested in using our sister project OpenDTU or you want to future-proof your setup, we recommend investing in an ESP32 board that features two CPU cores. As Radio you can also use a NRF24L01+ module with an external antenna. While this option may cost a bit more, it will provide superior performance and ensure compatibility with upcoming developments. | **Parts** | **Price** | | --- | --- | diff --git a/README.md b/README.md index 78094c78..73c4184f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This work is licensed under a # 🖐 Ahoy! ![Logo](https://github.com/grindylow/ahoy/blob/main/doc/logo1_small.png?raw=true) -**Communicate with Hoymiles inverters via radio**. Get actual values like power, current, daily energy and set parameters like the power limit via web interface or MQTT. In this repository you will find different approaches means Hardware / Software to realize the described functionalities. +This repository offers hardware and software solutions for communicating with Hoymiles inverters via radio. With our system, you can easily obtain real-time values such as power, current, and daily energy. Additionally, you can set parameters like the power limit of your inverter to achieve zero export. You can access these functionalities through our user-friendly web interface, MQTT, or JSON. Whether you're monitoring your solar panel system's performance or fine-tuning its settings, our solutions make it easy to achieve your goals. Table of approaches: @@ -43,9 +43,7 @@ Table of approaches: - [The root of development](https://www.mikrocontroller.net/topic/525778) ### Development -If you encounter issues use the issues here on github. - -Please try to describe your issues as precise as possible and think about if this is a issue with the software here in the repository or other software components. +If you run into any issues, please feel free to use the issue tracker here on Github. When describing your issue, please be as detailed and precise as possible, and take a moment to consider whether the issue is related to our software. This will help us to provide more effective solutions to your problem. **Contributors are always welcome!** From f6993fdc696780284353ecd27a010c38ac40269b Mon Sep 17 00:00:00 2001 From: Markus Krause Date: Fri, 31 Mar 2023 00:12:01 +0200 Subject: [PATCH 04/14] fix S3 bin distribution --- scripts/getVersion.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/getVersion.py b/scripts/getVersion.py index 0ebe1ec2..7fbe0e1b 100644 --- a/scripts/getVersion.py +++ b/scripts/getVersion.py @@ -50,6 +50,7 @@ def readVersion(path, infile): versionnumber += line[p+13:].rstrip() + "." os.mkdir(path + "firmware/") + os.mkdir(path + "firmware/s3/") sha = os.getenv("SHA",default="sha") versionout = version[:-1] + "_" + sha + "_esp8266.bin" @@ -80,7 +81,7 @@ def readVersion(path, infile): versionout = version[:-1] + "_" + sha + "_esp32s3.bin" src = path + ".pio/build/opendtufusionv1-release/firmware.bin" - dst = path + "firmware/" + versionout + dst = path + "firmware/s3/" + versionout os.rename(src, dst) # other ESP32 bin files @@ -89,6 +90,15 @@ def readVersion(path, infile): os.rename(src + "bootloader.bin", dst + "bootloader.bin") os.rename(src + "partitions.bin", dst + "partitions.bin") genOtaBin(path + "firmware/") + + # other ESP32S3 bin files + src = path + ".pio/build/opendtufusionv1-release/" + dst = path + "firmware/s3/" + os.rename(src + "bootloader.bin", dst + "bootloader.bin") + os.rename(src + "partitions.bin", dst + "partitions.bin") + os.rename("~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin", dst + "ota.bin") + genOtaBin(path + "firmware/s3/") + os.rename("../scripts/gh-action-dev-build-flash.html", path + "install.html") print("name=" + versionnumber[:-1] ) From 2eb845a9cb6e63df886d455fbe2375d6efb0f370 Mon Sep 17 00:00:00 2001 From: Markus Krause Date: Fri, 31 Mar 2023 00:21:16 +0200 Subject: [PATCH 05/14] remove redundant call --- scripts/getVersion.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/getVersion.py b/scripts/getVersion.py index 7fbe0e1b..e3927907 100644 --- a/scripts/getVersion.py +++ b/scripts/getVersion.py @@ -97,7 +97,6 @@ def readVersion(path, infile): os.rename(src + "bootloader.bin", dst + "bootloader.bin") os.rename(src + "partitions.bin", dst + "partitions.bin") os.rename("~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin", dst + "ota.bin") - genOtaBin(path + "firmware/s3/") os.rename("../scripts/gh-action-dev-build-flash.html", path + "install.html") From c9b6cc5f6f09dd7f79528ffbc54226a75123d16f Mon Sep 17 00:00:00 2001 From: Markus Krause Date: Fri, 31 Mar 2023 00:49:48 +0200 Subject: [PATCH 06/14] fix ota bin copy --- .github/workflows/compile_development.yml | 3 ++ .github/workflows/compile_release.yml | 3 ++ ahoy.code-workspace | 45 +++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 ahoy.code-workspace diff --git a/.github/workflows/compile_development.yml b/.github/workflows/compile_development.yml index ffde2d21..768a522f 100644 --- a/.github/workflows/compile_development.yml +++ b/.github/workflows/compile_development.yml @@ -49,6 +49,9 @@ jobs: - name: Run PlatformIO run: pio run -d src --environment esp8266-release --environment esp8266-release-prometheus --environment esp8285-release --environment esp32-wroom32-release --environment esp32-wroom32-release-prometheus --environment opendtufusionv1-release + - name: Copy boot_app0.bin + run: cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin .pio/build/opendtufusionv1-release/ota.bin + - name: Rename Binary files id: rename-binary-files working-directory: src diff --git a/.github/workflows/compile_release.yml b/.github/workflows/compile_release.yml index 84ad5111..25f34fa6 100644 --- a/.github/workflows/compile_release.yml +++ b/.github/workflows/compile_release.yml @@ -53,6 +53,9 @@ jobs: - name: Run PlatformIO run: pio run -d src --environment esp8266-release --environment esp8266-release-prometheus --environment esp8285-release --environment esp32-wroom32-release --environment esp32-wroom32-release-prometheus --environment opendtufusionv1-release + - name: Copy boot_app0.bin + run: cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin .pio/build/opendtufusionv1-release/ota.bin + - name: Rename Binary files id: rename-binary-files working-directory: src diff --git a/ahoy.code-workspace b/ahoy.code-workspace new file mode 100644 index 00000000..20d5909e --- /dev/null +++ b/ahoy.code-workspace @@ -0,0 +1,45 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "src" + } + ], + "settings": { + "files.associations": { + "algorithm": "cpp", + "array": "cpp", + "chrono": "cpp", + "deque": "cpp", + "format": "cpp", + "forward_list": "cpp", + "functional": "cpp", + "initializer_list": "cpp", + "iterator": "cpp", + "list": "cpp", + "memory": "cpp", + "queue": "cpp", + "random": "cpp", + "regex": "cpp", + "vector": "cpp", + "xhash": "cpp", + "xlocmon": "cpp", + "xlocnum": "cpp", + "xmemory": "cpp", + "xstring": "cpp", + "xtree": "cpp", + "xutility": "cpp", + "*.tcc": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "string_view": "cpp", + "sstream": "cpp", + "istream": "cpp", + "ostream": "cpp" + }, + "editor.formatOnSave": false + } +} \ No newline at end of file From 2eb0a6542db3693502f7d5f79b40202839d76f93 Mon Sep 17 00:00:00 2001 From: Markus Krause Date: Fri, 31 Mar 2023 00:53:59 +0200 Subject: [PATCH 07/14] take new ota.bin --- scripts/getVersion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/getVersion.py b/scripts/getVersion.py index e3927907..e8393ae1 100644 --- a/scripts/getVersion.py +++ b/scripts/getVersion.py @@ -96,7 +96,7 @@ def readVersion(path, infile): dst = path + "firmware/s3/" os.rename(src + "bootloader.bin", dst + "bootloader.bin") os.rename(src + "partitions.bin", dst + "partitions.bin") - os.rename("~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin", dst + "ota.bin") + os.rename(src + "ota.bin", dst + "ota.bin") os.rename("../scripts/gh-action-dev-build-flash.html", path + "install.html") From 3043eaca1f94ddc326e8cb1e17d4a174152255b1 Mon Sep 17 00:00:00 2001 From: Markus Krause Date: Fri, 31 Mar 2023 01:04:39 +0200 Subject: [PATCH 08/14] fix path --- .github/workflows/compile_development.yml | 2 +- .github/workflows/compile_release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile_development.yml b/.github/workflows/compile_development.yml index 768a522f..4913d726 100644 --- a/.github/workflows/compile_development.yml +++ b/.github/workflows/compile_development.yml @@ -50,7 +50,7 @@ jobs: run: pio run -d src --environment esp8266-release --environment esp8266-release-prometheus --environment esp8285-release --environment esp32-wroom32-release --environment esp32-wroom32-release-prometheus --environment opendtufusionv1-release - name: Copy boot_app0.bin - run: cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin .pio/build/opendtufusionv1-release/ota.bin + run: cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin src/.pio/build/opendtufusionv1-release/ota.bin - name: Rename Binary files id: rename-binary-files diff --git a/.github/workflows/compile_release.yml b/.github/workflows/compile_release.yml index 25f34fa6..a50ec355 100644 --- a/.github/workflows/compile_release.yml +++ b/.github/workflows/compile_release.yml @@ -54,7 +54,7 @@ jobs: run: pio run -d src --environment esp8266-release --environment esp8266-release-prometheus --environment esp8285-release --environment esp32-wroom32-release --environment esp32-wroom32-release-prometheus --environment opendtufusionv1-release - name: Copy boot_app0.bin - run: cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin .pio/build/opendtufusionv1-release/ota.bin + run: cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin src/.pio/build/opendtufusionv1-release/ota.bin - name: Rename Binary files id: rename-binary-files From ba996f56dd1b32c6d6beca5b9e085f1f5179ea9f Mon Sep 17 00:00:00 2001 From: Markus Krause Date: Fri, 31 Mar 2023 02:10:09 +0200 Subject: [PATCH 09/14] change build settings fpr S3 to address flash instability --- src/platformio.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platformio.ini b/src/platformio.ini index 4e2e92fd..7cb7cbfe 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -137,6 +137,10 @@ monitor_filters = [env:opendtufusionv1-release] platform = espressif32 board = esp32-s3-devkitc-1 +upload_protocol = esp-builtin +upload_speed = 115200 +debug_tool = esp-builtin +debug_speed = 12000 build_flags = -D RELEASE -std=gnu++14 build_unflags = -std=gnu++11 monitor_filters = From 33264cc776b1c8501b2894a8f2f8ebfee9cd93a4 Mon Sep 17 00:00:00 2001 From: Markus Krause Date: Fri, 31 Mar 2023 22:51:01 +0200 Subject: [PATCH 10/14] make LED polarity selectable --- src/app.cpp | 28 +++++++++++++++------------- src/app.h | 4 ++-- src/config/settings.h | 4 ++++ src/web/RestApi.h | 1 + src/web/html/setup.html | 12 ++++++++++++ src/web/web.h | 3 ++- 6 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index d3fba12a..088454f6 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -69,7 +69,7 @@ void app::setup() { mPayload.addAlarmListener(std::bind(&PubMqttType::alarmEventListener, &mMqtt, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); } #endif - setupLed(); + setupLed(mConfig->led.led_high_active); mWeb.setup(this, &mSys, mConfig); mWeb.setProtection(strlen(mConfig->sys.adminPwd) != 0); @@ -353,7 +353,7 @@ void app::tickSend(void) { } yield(); - updateLed(); + updateLed(mConfig->led.led_high_active); } //----------------------------------------------------------------------------- @@ -386,31 +386,33 @@ void app::mqttSubRxCb(JsonObject obj) { } //----------------------------------------------------------------------------- -void app::setupLed(void) { - /** LED connection diagram - * \\ - * PIN ---- |<----- 3.3V - * - * */ +void app::setupLed(uint8_t is_high_active) { + + uint8_t led_off = (is_high_active != 0) ? LOW : HIGH; + if (mConfig->led.led0 != 0xff) { pinMode(mConfig->led.led0, OUTPUT); - digitalWrite(mConfig->led.led0, HIGH); // LED off + digitalWrite(mConfig->led.led0, led_off); } if (mConfig->led.led1 != 0xff) { pinMode(mConfig->led.led1, OUTPUT); - digitalWrite(mConfig->led.led1, HIGH); // LED off + digitalWrite(mConfig->led.led1, led_off); } } //----------------------------------------------------------------------------- -void app::updateLed(void) { +void app::updateLed(uint8_t is_high_active) { + + uint8_t led_off = (is_high_active != 0) ? LOW : HIGH; + uint8_t led_on = (is_high_active != 0) ? HIGH : LOW; + if (mConfig->led.led0 != 0xff) { Inverter<> *iv = mSys.getInverterByPos(0); if (NULL != iv) { if (iv->isProducing(mTimestamp)) - digitalWrite(mConfig->led.led0, LOW); // LED on + digitalWrite(mConfig->led.led0, led_on); else - digitalWrite(mConfig->led.led0, HIGH); // LED off + digitalWrite(mConfig->led.led0, led_off); } } } diff --git a/src/app.h b/src/app.h index cbf7e6a1..252434ae 100644 --- a/src/app.h +++ b/src/app.h @@ -213,8 +213,8 @@ class app : public IApp, public ah::Scheduler { void mqttSubRxCb(JsonObject obj); - void setupLed(void); - void updateLed(void); + void setupLed(uint8_t is_high_active); + void updateLed(uint8_t is_high_active); void tickReboot(void) { DPRINTLN(DBG_INFO, F("Rebooting...")); diff --git a/src/config/settings.h b/src/config/settings.h index 6d58b406..7449a0b6 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -100,6 +100,7 @@ typedef struct { typedef struct { uint8_t led0; // first LED pin uint8_t led1; // second LED pin + uint8_t led_high_active; // determines if LEDs are high or low active } cfgLed_t; typedef struct { @@ -378,6 +379,7 @@ class settings { mCfg.led.led0 = DEF_PIN_OFF; mCfg.led.led1 = DEF_PIN_OFF; + mCfg.led.led_high_active = LOW; memset(&mCfg.inst, 0, sizeof(cfgInst_t)); @@ -517,9 +519,11 @@ class settings { if(set) { obj[F("0")] = mCfg.led.led0; obj[F("1")] = mCfg.led.led1; + obj[F("2")] = mCfg.led.led_high_active; } else { mCfg.led.led0 = obj[F("0")]; mCfg.led.led1 = obj[F("1")]; + mCfg.led.led_high_active = obj[F("2")]; } } diff --git a/src/web/RestApi.h b/src/web/RestApi.h index b224f239..8c193e28 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -391,6 +391,7 @@ class RestApi { obj[F("miso")] = mConfig->nrf.pinMiso; obj[F("led0")] = mConfig->led.led0; obj[F("led1")] = mConfig->led.led1; + obj[F("led_high_active")] = mConfig->led.led_high_active; } void getRadio(JsonObject obj) { diff --git a/src/web/html/setup.html b/src/web/html/setup.html index bfbda402..fbe29010 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -411,6 +411,10 @@ [47, "GPIO47"], [48, "GPIO48"], ]; + var led_high_active = [ + [0, "low active"], + [1, "high active"], + ]; const re = /11[2,4,6]1.*/; @@ -670,6 +674,14 @@ ]) ); } + e.append( + ml("div", { class: "row mb-3" }, [ + ml("div", { class: "col-12 col-sm-3 my-2" }, "LED polarity"), + ml("div", { class: "col-12 col-sm-9" }, + sel('pinLedHighActive', led_high_active, obj["led_high_active"]) + ) + ]) + ); } function parseRadio(obj) { diff --git a/src/web/web.h b/src/web/web.h index c141e013..94f6ece7 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -33,7 +33,7 @@ #define WEB_SERIAL_BUF_SIZE 2048 -const char *const pinArgNames[] = {"pinCs", "pinCe", "pinIrq", "pinSclk", "pinMosi", "pinMiso", "pinLed0", "pinLed1"}; +const char *const pinArgNames[] = {"pinCs", "pinCe", "pinIrq", "pinSclk", "pinMosi", "pinMiso", "pinLed0", "pinLed1", "pinLedHighActive"}; template class Web { @@ -532,6 +532,7 @@ class Web { case 5: mConfig->nrf.pinMiso = ((pin != 0xff) ? pin : DEF_MISO_PIN); break; case 6: mConfig->led.led0 = pin; break; case 7: mConfig->led.led1 = pin; break; + case 8: mConfig->led.led_high_active = pin; break; // this is not really a pin but a polarity, but handling it close to here makes sense } } From 48a6bf021cf11f79ca71a25fa9eae571779d3748 Mon Sep 17 00:00:00 2001 From: Markus Krause Date: Sat, 1 Apr 2023 13:00:38 +0200 Subject: [PATCH 11/14] add MQTT status to LED update, try to fix settings save for led polarity --- src/app.cpp | 22 +++++++++++++++------- src/app.h | 4 ++-- src/config/settings.h | 4 ++-- src/web/html/setup.html | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index 088454f6..9ec6ff26 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -69,7 +69,7 @@ void app::setup() { mPayload.addAlarmListener(std::bind(&PubMqttType::alarmEventListener, &mMqtt, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); } #endif - setupLed(mConfig->led.led_high_active); + setupLed(); mWeb.setup(this, &mSys, mConfig); mWeb.setProtection(strlen(mConfig->sys.adminPwd) != 0); @@ -353,7 +353,7 @@ void app::tickSend(void) { } yield(); - updateLed(mConfig->led.led_high_active); + updateLed(); } //----------------------------------------------------------------------------- @@ -386,9 +386,9 @@ void app::mqttSubRxCb(JsonObject obj) { } //----------------------------------------------------------------------------- -void app::setupLed(uint8_t is_high_active) { +void app::setupLed(void) { - uint8_t led_off = (is_high_active != 0) ? LOW : HIGH; + uint8_t led_off = (mConfig->led.led_high_active != 0) ? LOW : HIGH; if (mConfig->led.led0 != 0xff) { pinMode(mConfig->led.led0, OUTPUT); @@ -401,10 +401,10 @@ void app::setupLed(uint8_t is_high_active) { } //----------------------------------------------------------------------------- -void app::updateLed(uint8_t is_high_active) { +void app::updateLed(void) { - uint8_t led_off = (is_high_active != 0) ? LOW : HIGH; - uint8_t led_on = (is_high_active != 0) ? HIGH : LOW; + uint8_t led_off = (mConfig->led.led_high_active != 0) ? LOW : HIGH; + uint8_t led_on = (mConfig->led.led_high_active != 0) ? HIGH : LOW; if (mConfig->led.led0 != 0xff) { Inverter<> *iv = mSys.getInverterByPos(0); @@ -415,4 +415,12 @@ void app::updateLed(uint8_t is_high_active) { digitalWrite(mConfig->led.led0, led_off); } } + + if (mConfig->led.led1 != 0xff) { + if (getMqttIsConnected()) { + digitalWrite(mConfig->led.led1, led_on); + } else { + digitalWrite(mConfig->led.led1, led_off); + } + } } diff --git a/src/app.h b/src/app.h index 252434ae..6dfc404c 100644 --- a/src/app.h +++ b/src/app.h @@ -213,8 +213,8 @@ class app : public IApp, public ah::Scheduler { void mqttSubRxCb(JsonObject obj); - void setupLed(uint8_t is_high_active); - void updateLed(uint8_t is_high_active); + void setupLed(); + void updateLed(); void tickReboot(void) { DPRINTLN(DBG_INFO, F("Rebooting...")); diff --git a/src/config/settings.h b/src/config/settings.h index 7449a0b6..e895a8a9 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -519,11 +519,11 @@ class settings { if(set) { obj[F("0")] = mCfg.led.led0; obj[F("1")] = mCfg.led.led1; - obj[F("2")] = mCfg.led.led_high_active; + obj[F("led_high_active")] = mCfg.led.led_high_active; } else { mCfg.led.led0 = obj[F("0")]; mCfg.led.led1 = obj[F("1")]; - mCfg.led.led_high_active = obj[F("2")]; + mCfg.led.led_high_active = obj[F("led_high_active")]; } } diff --git a/src/web/html/setup.html b/src/web/html/setup.html index fbe29010..97bf5608 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -678,7 +678,7 @@ ml("div", { class: "row mb-3" }, [ ml("div", { class: "col-12 col-sm-3 my-2" }, "LED polarity"), ml("div", { class: "col-12 col-sm-9" }, - sel('pinLedHighActive', led_high_active, obj["led_high_active"]) + sel('pinLedHighActive', led_high_active, obj['led_high_active']) ) ]) ); From 7050a3486813e6e066c2252f4e40f112f67b0e47 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 1 Apr 2023 23:34:48 +0200 Subject: [PATCH 12/14] 0.6.1 * merge LED fix - LED1 shows MqTT state, LED configureable active high/low #839 --- src/CHANGES.md | 35 +++-------------------------------- src/defines.h | 2 +- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index e0591a00..cbaa465a 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,33 +1,4 @@ -Changelog v0.6.0 +# Development Changes -## General -* improved night time calculation time to 1 minute after last communication pause #515 -* refactored code for better readability -* improved Hoymiles communication (retransmits, immediate power limit transmission, timing at all) -* renamed firmware binaries -* add login / logout to menu -* add display support for `SH1106`, `SSD1306`, `Nokia` and `ePaper 1.54"` (ESP32 only) -* add yield total correction - move your yield to a new inverter or correct an already used inverter -* added import / export feature -* added `Prometheus` endpoints -* improved wifi connection and stability (connect to strongest AP) -* addded Hoymiles alarm IDs to log -* improved `System` information page (eg. radio statitistics) -* improved UI (responsive design, (optional) dark mode) -* improved system stability (reduced `heap-fragmentation`, don't break settings on failure) #644, #645 -* added support for 2nd generation of Hoymiles inverters, MI series -* improved JSON API for more stable WebUI -* added option to disable input display in `/live` (`max-power` has to be set to `0`) -* updated documentation -* improved settings on ESP32 devices while setting SPI pins (for `NRF24` radio) - -## MqTT -* added `comm_disabled` #529 -* added fixed interval option #542, #523 -* improved communication, only required publishes -* improved retained flags -* added `set_power_limit` acknowledge MQTT publish #553 -* added feature to reset values on midnight, communication pause or if the inverters are not available -* partially added Hoymiles alarm ID -* improved autodiscover (added total values on multi-inverter setup) -* improved `clientID` a part of the MAC address is added to have an unique name +## 0.6.1 - 2023-04-01 +* merge LED fix - LED1 shows MqTT state, LED configureable active high/low #839 diff --git a/src/defines.h b/src/defines.h index 1be438ff..28275eff 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 6 -#define VERSION_PATCH 0 +#define VERSION_PATCH 1 //------------------------------------- typedef struct { From db8b17502e043d6b957e8e4e8ee80611a936f1e4 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 1 Apr 2023 23:47:51 +0200 Subject: [PATCH 13/14] 0.6.1 * only publish new inverter data #826 --- src/CHANGES.md | 1 + src/publisher/pubMqtt.h | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index cbaa465a..9df7d29c 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,3 +2,4 @@ ## 0.6.1 - 2023-04-01 * merge LED fix - LED1 shows MqTT state, LED configureable active high/low #839 +* only publish new inverter data #826 diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index b008d8d2..e717ee7c 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -49,6 +49,7 @@ class PubMqtt { mTxCnt = 0; mSubscriptionCb = NULL; memset(mLastIvState, MQTT_STATUS_NOT_AVAIL_NOT_PROD, MAX_NUM_INVERTERS); + memset(mIvLastRTRpub, 0, MAX_NUM_INVERTERS * 4); mLastAnyAvail = false; } @@ -522,7 +523,13 @@ class PubMqtt { void sendData(Inverter<> *iv, uint8_t curInfoCmd) { record_t<> *rec = iv->getRecordStruct(curInfoCmd); - if (iv->getLastTs(rec) > 0) { + uint32_t lastTs = iv->getLastTs(rec); + bool pubData = (lastTs > 0); + if (curInfoCmd == RealTimeRunData_Debug) + pubData &= (lastTs != mIvLastRTRpub[iv->id]); + + if (pubData) { + mIvLastRTRpub[iv->id] = lastTs; for (uint8_t i = 0; i < rec->length; i++) { bool retained = false; if (curInfoCmd == RealTimeRunData_Debug) { @@ -653,6 +660,7 @@ class PubMqtt { subscriptionCb mSubscriptionCb; bool mLastAnyAvail; uint8_t mLastIvState[MAX_NUM_INVERTERS]; + uint32_t mIvLastRTRpub[MAX_NUM_INVERTERS]; uint16_t mIntervalTimeout; // last will topic and payload must be available trough lifetime of 'espMqttClient' From 521c7ca3071f1e2adec98c2fdaa6614b7c627efb Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 2 Apr 2023 00:08:06 +0200 Subject: [PATCH 14/14] 0.6.1 * potential fix of WiFi hostname during boot up #752 --- src/CHANGES.md | 1 + src/wifi/ahoywifi.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 9df7d29c..0a2613ae 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -3,3 +3,4 @@ ## 0.6.1 - 2023-04-01 * merge LED fix - LED1 shows MqTT state, LED configureable active high/low #839 * only publish new inverter data #826 +* potential fix of WiFi hostname during boot up #752 diff --git a/src/wifi/ahoywifi.cpp b/src/wifi/ahoywifi.cpp index 0acdf9e2..9677e7ee 100644 --- a/src/wifi/ahoywifi.cpp +++ b/src/wifi/ahoywifi.cpp @@ -1,6 +1,6 @@ //----------------------------------------------------------------------------- -// 2023 Ahoy, https://www.mikrocontroller.net/topic/525778 -// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +// 2023 Ahoy, https://ahoydtu.de +// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed //----------------------------------------------------------------------------- #if defined(ESP32) && defined(F) @@ -160,6 +160,9 @@ void ahoywifi::setupAp(void) { DBGPRINTLN(mApIp.toString()); DBGPRINTLN(F("---------\n")); + if(String(mConfig->sys.deviceName) != "") + WiFi.hostname(mConfig->sys.deviceName); + WiFi.mode(WIFI_AP_STA); WiFi.softAPConfig(mApIp, mApIp, IPAddress(255, 255, 255, 0)); WiFi.softAP(WIFI_AP_SSID, WIFI_AP_PWD);