diff --git a/.github/workflows/compile_development.yml b/.github/workflows/compile_development.yml index ffde2d21..4913d726 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 src/.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..a50ec355 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 src/.pio/build/opendtufusionv1-release/ota.bin + - name: Rename Binary files id: rename-binary-files working-directory: src diff --git a/Getting_Started.md b/Getting_Started.md index e73277f0..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** | | --- | --- | @@ -154,7 +152,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 +160,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 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!** 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 diff --git a/scripts/getVersion.py b/scripts/getVersion.py index 0ebe1ec2..e8393ae1 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,14 @@ 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(src + "ota.bin", dst + "ota.bin") + os.rename("../scripts/gh-action-dev-build-flash.html", path + "install.html") print("name=" + versionnumber[:-1] ) diff --git a/src/CHANGES.md b/src/CHANGES.md index debcf40d..0a2613ae 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,33 +1,6 @@ -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 commuinication (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 (repsonsive 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 +* only publish new inverter data #826 +* potential fix of WiFi hostname during boot up #752 diff --git a/src/app.cpp b/src/app.cpp index 7d9f75ba..7a0e5f2a 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -389,30 +389,40 @@ void app::mqttSubRxCb(JsonObject obj) { //----------------------------------------------------------------------------- void app::setupLed(void) { - /** LED connection diagram - * \\ - * PIN ---- |<----- 3.3V - * - * */ + + uint8_t led_off = (mConfig->led.led_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) { + + 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); 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); + } + } + + 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 069f3c7d..34db9aad 100644 --- a/src/app.h +++ b/src/app.h @@ -217,8 +217,8 @@ class app : public IApp, public ah::Scheduler { void mqttSubRxCb(JsonObject obj); - void setupLed(void); - void updateLed(void); + 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 6d58b406..e895a8a9 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("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("led_high_active")]; } } 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 { diff --git a/src/platformio.ini b/src/platformio.ini index cae35934..5d4c655d 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -138,6 +138,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 = diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index f75c4068..e717ee7c 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -50,7 +50,6 @@ class PubMqtt { mSubscriptionCb = NULL; memset(mLastIvState, MQTT_STATUS_NOT_AVAIL_NOT_PROD, MAX_NUM_INVERTERS); memset(mIvLastRTRpub, 0, MAX_NUM_INVERTERS * 4); - mLastAnyAvail = false; } 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..97bf5608 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 47bdeb1d..4d322fac 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -34,7 +34,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 } } 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);