diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..96c6568 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,20 @@ +{ + "files.associations": { + "*.cps": "javascript", + "*.config": "cpp", + "__bit_reference": "cpp", + "__hash_table": "cpp", + "__split_buffer": "cpp", + "__tree": "cpp", + "array": "cpp", + "deque": "cpp", + "initializer_list": "cpp", + "map": "cpp", + "regex": "cpp", + "string": "cpp", + "string_view": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "ostream": "cpp" + } +} \ No newline at end of file diff --git a/docs/assets/img/screenshots/robodyn-vs-zc-module-grid-power.jpeg b/docs/assets/img/screenshots/robodyn-vs-zc-module-grid-power.jpeg new file mode 100644 index 0000000..0c1ec77 Binary files /dev/null and b/docs/assets/img/screenshots/robodyn-vs-zc-module-grid-power.jpeg differ diff --git a/docs/assets/img/screenshots/robodyn-vs-zc-module-ha.jpeg b/docs/assets/img/screenshots/robodyn-vs-zc-module-ha.jpeg new file mode 100644 index 0000000..33e335a Binary files /dev/null and b/docs/assets/img/screenshots/robodyn-vs-zc-module-ha.jpeg differ diff --git a/docs/assets/img/screenshots/robodyn-vs-zc-module-pid-tuning.jpeg b/docs/assets/img/screenshots/robodyn-vs-zc-module-pid-tuning.jpeg new file mode 100644 index 0000000..c0b2410 Binary files /dev/null and b/docs/assets/img/screenshots/robodyn-vs-zc-module-pid-tuning.jpeg differ diff --git a/docs/blog.md b/docs/blog.md index 2b28bfb..88f3c81 100644 --- a/docs/blog.md +++ b/docs/blog.md @@ -6,7 +6,8 @@ description: Blog # Blog -- [2024-07-01 - Shelly Solar Diverter / Router](/blog/2024-07-01_shelly_solar_diverter) -- [2024-06-26 - Everything on le JSY](/blog/2024-06-26_everything_on_the_jsy) -- [2024-06-25 - Remote JSY through UDP](/blog/2024-06-25_remote_jsy) -- [2024-06-23 - Development is still in progress](/blog/2024-06-23_development_is_still_in_progress) +- [2024-07-24 - The Importance of a good ZCD circuit](./blog/2024-07-24_the_importance_of_a_good_zcd_circuit) +- [2024-07-01 - Shelly Solar Diverter / Router](./blog/2024-07-01_shelly_solar_diverter) +- [2024-06-26 - Everything on le JSY](./blog/2024-06-26_everything_on_the_jsy) +- [2024-06-25 - Remote JSY through UDP](./blog/2024-06-25_remote_jsy) +- [2024-06-23 - Development is still in progress](./blog/2024-06-23_development_is_still_in_progress) diff --git a/docs/blog/2024-07-24_the_importance_of_a_good_zcd_circuit.md b/docs/blog/2024-07-24_the_importance_of_a_good_zcd_circuit.md new file mode 100644 index 0000000..72109a3 --- /dev/null +++ b/docs/blog/2024-07-24_the_importance_of_a_good_zcd_circuit.md @@ -0,0 +1,52 @@ +--- +layout: default +title: Blog +description: "The Importance of a good ZCD circuit" +--- + +_Date: 2024-07-024_ + +# The Importance of a good ZCD circuit + +During YaSolR development, I've tested several ZCD modules with an oscilloscope, but also programmatically with a library allowing me to analyse the quality of the detection of ZCD pulses. + +My conclusions, which are also common to a lot of other experts in Solar Routers, is that **the quality of the ZCD module is very important for the accuracy of routing.** + +## What is a ZCD circuit? + +Please read the [YaSolR Overview](../overview#zero-cross-detection-zcd) to understand the concept of Zero-Cross Detection. +A Wikipedia article is also available [here](https://en.wikipedia.org/wiki/Zero_crossing). + +Using a good ZCD circuit producing a reliable pulse is very important. + +If the pulses are not reliable, some short flickering could be caused by a mis-detection of the zero point or by the existence of spurious pulses (false-positives), and consequently cause the TRIAC to fire at the wrong time, or the calculations for the burst fire sequence to be wrong. +These are visible if you plug an incandescent light bulb to the dimmer output: the bulb will flicker from time to time. +The effect on a water tank resistance is even bigger: it will create some spurious spikes of power consumption, that the router will try to compensate just after by considerably reducing the dimming level. +This creates some waves instead of keeping the import and export at a near-0 level. + +These phenomena are not visible with a good ZCD module coupled with a Random SSR. + +The Robodyn is such a device that has an unreliable ZC pulse: all experts working on Solar Routers who have measured that correctly, tend to agree with the fact that **the Robodyn is one of the worst device to use because of its unreliable ZC and poor quality circuit and heat sink**. + +Here is below a YaSolR screenshot of the Grid Power graph showing the effect of a bad ZCD module on the power consumption and import. +On the lef side, the Robodyn ZCD is used, then I've switched (live) to a dedicated ZCD module. + +[![](assets/img/screenshots/robodyn-vs-zc-module-grid-power.jpeg)](assets/img/screenshots/robodyn-vs-zc-module-grid-power.jpeg) + +Here is another example below of th YaSolR PID Tuning view showing the input value of the PID controller. +The dedicated ZCD module was used, then I've switched (live) to a Robodyn ZCD module. +The update rate is high: 3 times per second. +All the JSY measurements are captured and displayed. +You can clearly see the flickering caused by the bad quality of the Robodyn ZCD pulses, which gets compensated just after by the PID controller. + +[![](assets/img/screenshots/robodyn-vs-zc-module-pid-tuning.jpeg)](assets/img/screenshots/robodyn-vs-zc-module-pid-tuning.jpeg) + +Lastly, here is a graph showing in Home Assistant the effect of the Robodyn ZCD on the dimmer output. +The Robodyn ZCD was used form 11:58 to 12:02, then I've switched (live) to a dedicated ZCD module. + +[![](assets/img/screenshots/robodyn-vs-zc-module-ha.jpeg)](assets/img/screenshots/robodyn-vs-zc-module-ha.jpeg) + +You can read more about these issues here also: + +- [About dimmer boards](https://github.com/fabianoriccardi/dimmable-light/wiki/About-dimmer-boards) +- [Notes about specific architectures](https://github.com/fabianoriccardi/dimmable-light/wiki/Notes-about-specific-architectures#esp32) diff --git a/docs/build.md b/docs/build.md index b00bcec..79e6ece 100644 --- a/docs/build.md +++ b/docs/build.md @@ -11,7 +11,7 @@ description: Build - [The Minimalist](#the-minimalist) - [The Adventurer](#the-adventurer) - [The Elite](#the-elite) - - [The Professional (🚧)](#the-professional-%F0%9F%9A%A7) + - [The Professional](#the-professional) - [Possible Upgrades](#possible-upgrades) - [Remote JSY](#remote-jsy) - [Alternative: The Shelly Solar Diverter](#alternative-the-shelly-solar-diverter) @@ -42,7 +42,7 @@ Here are below some examples: - [The Minimalist](#the-minimalist): the cheapest and easiest to build - [The Adventurer](#the-adventurer): for people who want to mitigate the flaws of the Robodyn and do some improvements over the existing Robodyn - [The Elite](#the-elite): for people who want to use a Random SSR instead of a Robodyn to safely dim more power and have a better Zero-Cross Detection circuit -- [The Professional (🚧)](#the-professional-%F0%9F%9A%A7): probably the best and safe solution out there but requires an additional power source +- [The Professional](#the-professional): probably the best and safe solution out there but requires an additional power source - [Possible Upgrades](#possible-upgrades): some additional components you can add to your router - [Remote JSY](#remote-jsy): a standalone application to place in your electrical panel to send the JSY metrics through UDP for remote installations - [Alternative: The Shelly Solar Diverter](#alternative-the-shelly-solar-diverter): a limited Solar Diverter / Router with Shelly devices and a voltage regulator @@ -61,7 +61,7 @@ Reuse your existing Shelly EM or Shelly 3EM to build a router! > - Supports **Phase Control** and **Burst mode** > - Reuse your Shelly EM or 3EM and send through MQTT grid power and voltage > - You can also use a SSR and ZCD module instead of the Robodyn -> {: .block-tip } +{: .block-tip } > ##### WARNING > @@ -70,7 +70,7 @@ Reuse your existing Shelly EM or Shelly 3EM to build a router! > - Bypass mode will use the Robodyn dimmer at 100% power > - Not as precise as a JSY (MQTT delays) > - No local measurement in place to measure the routed power (statistics will be empty) -> {: .block-warning } +{: .block-warning } ### The Minimalist @@ -84,14 +84,14 @@ The _Minimalist_ build uses inexpensive and easy to use components to start a ro > > - Robodyn includes Zero-Cross Detection circuit > - Supports **Phase Control** and **Burst mode** -> {: .block-tip } +{: .block-tip } > ##### WARNING > > - Advised load not more than 2000W > - Robodyn has poor quality heat sink, soldering and Zero-Cross pulse > - Bypass mode will use the Robodyn dimmer at 100% power -> {: .block-warning } +{: .block-warning } ### The Adventurer @@ -107,7 +107,7 @@ See the [Robodyn](#robodyn) section for more information. > > - Robodyn includes Zero-Cross Detection circuit > - Supports **Phase Control** and **Burst mode** -> {: .block-tip } +{: .block-tip } > ##### WARNING > @@ -115,7 +115,7 @@ See the [Robodyn](#robodyn) section for more information. > - Robodyn has poor quality heat sink, soldering and Zero-Cross pulse > - Bypass mode will use the Robodyn dimmer at 100% power > - Requires to unsolder the heat sink and triac and put a new triac on a new heat sink -> {: .block-warning } +{: .block-warning } ### The Elite @@ -132,14 +132,16 @@ The _Elite_ build is for people who want to use a Random SSR instead of a Robody > - Supports **Phase Control** and **Burst mode** > - Other types of Heat Sink are available: the image above is just an example. Pick one according to your load. > - All the components can be easily attached onto a DIN rail -> {: .block-tip } +{: .block-tip } > ##### WARNING > > - Bypass mode will use the SSR dimmer set at 100% power -> {: .block-warning } +{: .block-warning } -### The Professional (🚧) +### The Professional + +(🚧) The _Professional_ build uses a Voltage Regulator to control the power routing. This is probably the best reliable and efficient solution, but it is more complex to setup and wire. @@ -155,13 +157,13 @@ It requires an additional 12V power supply. > - Supports **Phase Control** and **Burst mode** > - Heat sink are bigger and better quality: bigger models are also available > - All the components can be easily attached onto a DIN rail -> {: .block-tip } +{: .block-tip } > ##### WARNING > > - Requires an additional 12V power supply (i.e. Mean Well HDR-15-15 12V DC) > - Bypass mode will use the dimmer set at 100% power -> {: .block-warning } +{: .block-warning } ### Possible Upgrades @@ -333,7 +335,7 @@ Links are provided for reference only, you can find them on other websites. > 2. The heat sink must be chosen according to the SSR / Triac. Here is a good video about the theory: [Calcul du dissipateur pour le triac d'un routeur](https://www.youtube.com/watch?v=_zAx1Q2IvJ8) (from Pierre) > > 3. Make sure to [improve the Robodyn wiring/soldering](https://sites.google.com/view/le-professolaire/routeur-professolaire) -> {: .block-important } +{: .block-important } ### Random and Zero-Cross SSR diff --git a/docs/index.md b/docs/index.md index 422d7e5..29b9ce6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -22,8 +22,8 @@ But this website will help you pick and build your router. YaSolR is one of the **most optimized and powerful** Solar Router firmware available: - **12-bits resolution** with linear interpolation for a precise TRIAC control -- **25 measurements / second** with a local JSY -- **20 measurements / second** with a remote JSY +- **Up to 25 measurements / second** with a local JSY +- **Up to 20 measurements / second** with a remote JSY - **PID Controller** optimized and customizable - **PID Tuning** web interface - **RMT Peripheral** used for DS18 readings @@ -31,6 +31,9 @@ YaSolR is one of the **most optimized and powerful** Solar Router firmware avail - **Custom dimmer library** optimized for ESP32 (🚧) - **MCPWM** (Motor Control Pulse Width Modulator) for phase control (🚧) - **3-Phase** support +- **Precise Zero-Cross Detection with pulse analysis** +- **Dimmer range remapping** like Shelly Dimmers +- **Detailed Calibration** This is a big **Open-Source** project following **best development practices**. YaSolR is: @@ -145,7 +148,10 @@ Each output supports an optional measurement device to measure the power routed - `Dimmer Duty Limiter`: Set a limit to the dimmer power to avoid routing too much power - `Dimmer Temperature Limiter`: Set a limit to the dimmer to stop it when a temperature is reached. This temperature can be different than the temperature used in auto bypass mode. - `Statistics`: Harmonic information, power factor, energy, routed power, etc -- `Automatic Resistance Calibration` (🚧): if a JSY or PZEM is installed, automatically discover and save the resistance value of the connected load. +- `Automatic Resistance Detection`: if a JSY or PZEM is installed, automatically discover and save the resistance value of the connected load. +- `Dimmer Range Remapping`: Remap the dimmer duty to a different range (e.g. 10-80%). + Some dimmers (especially voltage regulator controlled through a PWM-analog conversion), are working between 1-8V so remapping the duty is necessary. +- `Zero-Cross Pulse Analysis` (🚧): YaSolR will try to get some pulse analysis from the Zero-Cross Detection ### Grid Power Measurement @@ -209,7 +215,6 @@ The router can be completely controlled remotely through a Home Automation Syste - `Access Point Mode`: router can **work in AP mode without WiFi and Internet** - `Admin Password`: to protect the website, API and Access Point - `Captive Portal` a captive portal is started first time to help you connect the router -- `DNS & mDNS`: Discover the device on the network through mDNS (Bonjour) or DNS - `Ethernet & Wifi`: **ESP32 boards with Ethernet and WiFi are supported** - `NTP` support to synchronize time and date with Internet. If not activated, it is still possible to manually sync with your browser. - `Offline Mode`: **The router can work without WiFi, even teh features requiring time and date.** diff --git a/docs/manual.md b/docs/manual.md index 6c97088..43fce66 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -18,6 +18,7 @@ description: Manual - [`Output` sections](#output-sections) - [`Relays` section](#relays-section) - [`Management` section](#management-section) + - [Logging](#logging) - [`Network` section](#network-section) - [`MQTT` section](#mqtt-section) - [MQTT as a Grid Source](#mqtt-as-a-grid-source) @@ -27,21 +28,22 @@ description: Manual - [`Hardware` section](#hardware-section) - [`Hardware Config` section](#hardware-config-section) - [Grid Frequency](#grid-frequency) + - [Dimmer Range Remapping](#dimmer-range-remapping) - [Display](#display) - - [Relays](#relays) + - [Relay Types](#relay-types) + - [Relay Automatic Control](#relay-automatic-control) - [Resistance Calibration](#resistance-calibration) - [PZEM Pairing](#pzem-pairing) - [`PID Controller` section](#pid-controller-section) - [`Statistics` section](#statistics-section) - [Important Hardware Information](#important-hardware-information) - [Bypass Relay](#bypass-relay) - - [Display](#display) - [JSY-MK-194T (local)](#jsy-mk-194t-local) - [JSY-MK-194T (remote)](#jsy-mk-194t-remote) - [LEDs](#leds) - [Temperature Sensor](#temperature-sensor) - - [Zero-Cross Detection](#zero-cross-detection) - [Virtual Grid Power / Compatibility with EV box](#virtual-grid-power--compatibility-with-ev-box) + - [Zero-Cross Detection](#zero-cross-detection) - [Help and support](#help-and-support) ## Quick Start @@ -97,17 +99,18 @@ For example on Mac, it is often `/dev/cu.usbserial-0001` instead of `/dev/ttyUSB With [Espressif Flash Tool](https://www.espressif.com/en/support/download/other-tools) (Windows): > ##### IMPORTANT +> > Be careful to not forget the `0` -{: .block-important } +> {: .block-important } ![Espressif Flash Tool](assets/img/screenshots/Espressif_Flash_Tool.png) ### Captive Portal (Access Point) and WiFi - > ##### TIP +> > Captive Portal and Access Point address: [http://192.168.4.1/](http://192.168.4.1/) -{: .block-tip } +> {: .block-tip } A captive portal (Access Point) is started for the first time to configure the WiFi network, or when the application starts and cannot join an already configured WiFi network fro 15 seconds. @@ -151,6 +154,7 @@ It allows to see the raw current configuration of the router and edit it. [![](assets/img/screenshots/config.jpeg)](assets/img/screenshots/config.jpeg) > ##### WARNING +> > This page should not normally be used, except for debugging purposes. ### `/console` page @@ -205,8 +209,9 @@ The output sections show the state of the outputs and the possibility to control - `Energy`: The total accumulated energy routed by this output, stored in hardware (JSY and/or PZEM). > ##### IMPORTANT +> > A PZEM is required to see the measurements of each outputs. -{: .block-important } +> {: .block-important } **Dimmer Control:** @@ -237,62 +242,18 @@ The following settings are visible if `Bypass Automatic Control` is activated. - `Bypass Stop Temperature`: The temperature threshold when the auto bypass will stop: the temperature of the water tank needs to be higher than this threshold. > ##### TIP +> > All these settings are applied immediately and do not require a restart -{: .block-tip } +> {: .block-tip } ### `Relays` section -YaSolR supports 2 additional relays (Electromechanical or SSR, controlled with 3.3V DC) to control external loads, or to be connected to the A1 and A2 terminals of a power contactor. -Relays can also be connected to the other resistance of the water tank (tri-phase resistance) as described in the [recommendations to reduce harmonics and flickering](./overview#recommendations-to-reduce-harmonics-and-flickering), in order to improve the routing and reduce harmonics. -You must use a SSR for that, because the relay will be switched on and off frequently. - -> ##### NOTE -> Remember that the voltage is not dimmed: these are 2 normal relays -{: .block-note } - [![](assets/img/screenshots/relays.jpeg)](assets/img/screenshots/relays.jpeg) -- `Relay X Automatic Control: Connected Load (Watts)`: You can specify the resistive load power in watts connected to the relay. - If you do so, the relay will be activated automatically based on the grid power. - `Relay X Manual Control`: ON/OFF switch to control the relay manually. Only available when the relay is not in automatic mode. Otherwise the relay state is displayed. -> ##### WARNING -> Pay attention that there is little to no hysteresis on the relays. -> So do not use the automatic feature to switch non-resistive loads such as pumps, electric vehicle chargers, etc. -> If you need to switch other types of load in a more complex way with some hysteresis or other complex conditions, you can use the MQTT, REST API, Home Assistant or Jeedom to query the `Virtual Power` metric and execute an automation based on this value. -> The automation can then control the router relays remotely. The relays need to be set in `Manual Control`. -> Remember that these relays are not power contactors and should not be used to directly control high power loads like an Electric Vehicle charge, a pump, etc. -{: .block-warning } - -> ##### TIP -> -> - All these settings are applied immediately and do not require a restart -> -> - **For an EV charge control**: see [Virtual Grid Power / Compatibility with EV box](#virtual-grid-power--compatibility-with-ev-box) -> -> - **For a pump**: a contactor is recommended which can be coupled with a Shelly EM to activate / deactivate the contactor remotely, and it can be automated by Home Assistant or Jeedom based on the `Virtual Power` metric of this router, but also the hours of day, days of week, depending on the weather, and of course with some hysteresis and safety mechanisms to force the pump ON or OFF depending on some rules. -{: .block-tip } - -**Rules of Automatic Switching** - -`Grid Virtual Power` is calculated by the router as `Grid Power - Routed Power`. -This is the power that would be sent to the grid if the router was not routing any power to the resistive loads. - -`Grid Virtual Power` is negative on export and positive on import. - -- The relay will automatically start when `Grid Virtual Power + Relay Load <= -3% of Relay Load`. - In other words, the relay will automatically start when there is enough excess to absorb both the load connected to the relay plus 3% more of it. - When the relay will start, the remaining excess not absorbed by the load will be absorbed by the dimmer. - -- The relay will automatically stop when `Grid Virtual Power >= 3% of Relay Threshold`. - In other words, the relay will automatically stop when there is no excess anymore but a grid import equal to or more than 3% of the relay threshold. - When the relay will stop, there will be some excess again, which will be absorbed by the dimmer. - -For a 3000W tri-phase resistance, 3% means 30W per relay because there is 3x 1000W resistances. -For a 2100W tri-phase resistance, 3% means 21W per relay because there is 3x 700W resistances. - ### `Management` section [![](assets/img/screenshots/management.jpeg)](assets/img/screenshots/management.jpeg) @@ -303,9 +264,24 @@ For a 2100W tri-phase resistance, 3% means 21W per relay because there is 3x 700 - `Restart`: Restart the router. - `Energy Reset`: Reset the energy stored in all devices (JSY and PZEM) of the router. - `Factory Reset`: Reset the router to factory settings and restart it. + +#### Logging + - `Debug`: Activate or deactivate debug logging. -- `Console`: Go to the Web Console page. -- `Debug Information`: Link to the API page which will output useful debug information to give to support. +- `Debug Information`: Outputs useful debug information to give to support. + **Only available when `Debug` is activated.** +- `Console`: Go to the Web Console page to see the logs + +If you need to record the logs during a long period of time to troubleshoot an issue, you can activate `Debug` and then stream the logs into a file using `websocat` from another computer. +Make sure the computer won't g oto sleep! + +```bash +> websocat ws://192.168.125.123/wserial > logs.txt +``` + +> ##### NOTE +> +> The special characters (like `??f??OO`) at the beginning of each line are normal. ### `Network` section @@ -350,8 +326,9 @@ For a 2100W tri-phase resistance, 3% means 21W per relay because there is 3x 700 The ID won't change except if you change the ESP board. > ##### IMPORTANT +> > MQTT must be restarted to apply the changes. -{: .block-important } +> {: .block-important } #### MQTT as a Grid Source @@ -363,8 +340,9 @@ For a 2100W tri-phase resistance, 3% means 21W per relay because there is 3x 700 The reason is that it is impossible to know if the second channel of the JSY is really installed and used to monitor the grid power or not. > ##### IMPORTANT +> > The ESP32 must be restarted to apply the changes. -{: .block-important } +> {: .block-important } MQTT topics are less accurate because depend on the refresh rate of this topic, and an expiration delay of a few seconds is set in order to stop any routing if no update is received in time. Also, there is **1 minute expiration delay** after which the values will be considered as invalid. @@ -381,8 +359,9 @@ So this is important to make sure that the topic will be refreshed, otherwise fe - `Output 2 Temperature MQTT Topic`: if set to a MQTT Topic, the router will listen to it to read the temperature linked to output 2 > ##### IMPORTANT +> > The ESP32 must be restarted to apply the changes. -{: .block-important } +> {: .block-important } #### Home Assistant Discovery @@ -396,8 +375,9 @@ YaSolR supports Home Assistant Discovery: if configured, it will **automatically I strongly recommend to keep this default value and configure Home Assistant to use this topic prefix for Discovery in order to separate state topics from discovery topics. > ##### IMPORTANT +> > MQTT must be restarted to apply the changes. -{: .block-important } +> {: .block-important } The complete reference of the published data in MQTT is available [here](mqtt). The published data can be explored with [MQTT Explorer](https://mqtt-explorer.com/). @@ -447,8 +427,9 @@ data. It perfectly OK for a ZCD, but you cannot use a pin that can only be read for a relay, DS18 sensor, etc. > ##### IMPORTANT +> > If you change one of these settings, please stop and restart the corresponding Hardware. -{: .block-important } +> {: .block-important } ### `Hardware` section @@ -465,7 +446,7 @@ All these components are activated **live without the need to restart the router > > - `Relay 1` / `Relay 2`: these are the SSR or Electromechanical relays connected to the ESP32 and used to control external loads. > Only activate if you have connected some relays to be used for external loads. -{: .block-note } +> {: .block-note } ### `Hardware Config` section @@ -474,13 +455,40 @@ This section allows to further configure some hardware settings and calibrate th [![](assets/img/screenshots/hardware_config.jpeg)](assets/img/screenshots/hardware_config.jpeg) > ##### IMPORTANT +> > If you change one of these settings in the hardware section, please restart the corresponding hardware or the YaSolR device. -{: .block-important } +> {: .block-important } #### Grid Frequency - `Nominal Grid Frequency`: the nominal grid frequency. +#### Dimmer Range Remapping + +> ##### DANGER +> +> For advanced users only. +> {: .block-danger } + +- `Output 1 Dimmer Min/Max Remapping` +- `Output 2 Dimmer Min/Max Remapping` + +This feature allows to remap where the 0% power is set (`Min`) and where the 100% power is set (`Max`). +When remapped, the new duty range (0-100%) will match values from `Min` to `Max` instead of `0` to `100%`. + +This is especially useful when using a module converting the PWM signal to an analog voltage range between 0-10V for a voltage regulator. +But voltage regulators like LSA do work on a voltage range which is closer to 1-8V, 1 being 0% on the voltage regulator and 8V matching 100%. + +For example, if you set the range to `10-80%, then the new 0 will match a duty cycle of 10% and the new full power (100%) will match a duty cycle of 80%. + +> ##### TIP +> +> If you use a voltage regulator with a conversion module, you will need to do some testing to find the best range. +> A good start is to find the triggering voltage of the voltage regulator (usually around 1V) and the maximum voltage (usually around 8V) which matches 100%. +> This is usually written in the specifications of the voltage regulator. +> Then remap the dimmer ranges to match these values like the example above. +> {: .block-tip } + #### Display - `Display Speed`: the speed at which the display will switch to the next page. @@ -488,13 +496,77 @@ This section allows to further configure some hardware settings and calibrate th - `Display Type`: the type of display used. - `Display Rotation`: the rotation of the display. -#### Relays +Supported displays are any I2C OLED Display of type `SSD1307`, `SH1106`, `SH1107`. + +`SH1106` is recommended and has been extensively tested. + +The display will look like a carousel with a maximum of 5 pages: + +- Global information +- Network information +- Router information with relays +- Output 1 information +- Output 2 information + +[![](assets/img/screenshots/display.gif)](assets/img/screenshots/display.gif) + +#### Relay Types - `Output 1 Relay Type (Bypass)`: the relay type for Output 1 Bypass: Normally Open (NO) or Normally Closed (NC). - `Output 2 Relay Type (Bypass)`: the relay type for Output 2 Bypass: Normally Open (NO) or Normally Closed (NC). - `Relay 1 Type`: the relay type for Relay 1: Normally Open (NO) or Normally Closed (NC). - `Relay 2 Type`: the relay type for Relay 2: Normally Open (NO) or Normally Closed (NC). +#### Relay Automatic Control + +- `Relay X Automatic Control: Connected Load (Watts)`: You can specify the resistive load power in watts connected to the relays. + If you do so, the relay will be activated automatically based on the grid power. + +YaSolR supports 2 additional relays (Electromechanical or SSR, controlled with 3.3V DC) to control external loads, or to be connected to the A1 and A2 terminals of a power contactor. +Relays can also be connected to the other resistance of the water tank (tri-phase resistance) as described in the [recommendations to reduce harmonics and flickering](./overview#recommendations-to-reduce-harmonics-and-flickering), in order to improve the routing and reduce harmonics. +You must use a SSR for that, because the relay will be switched on and off frequently. + +> ##### NOTE +> +> Remember that the voltage is not dimmed: these are 2 normal relays +> {: .block-note } + +> ##### WARNING +> +> Pay attention that there is little to no hysteresis on the relays. +> So do not use the automatic feature to switch non-resistive loads such as pumps, electric vehicle chargers, etc. +> If you need to switch other types of load in a more complex way with some hysteresis or other complex conditions, you can use the MQTT, REST API, Home Assistant or Jeedom to query the `Virtual Power` metric and execute an automation based on this value. +> The automation can then control the router relays remotely. The relays need to be set in `Manual Control`. +> Remember that these relays are not power contactors and should not be used to directly control high power loads like an Electric Vehicle charge, a pump, etc. +> {: .block-warning } + +> ##### TIP +> +> - All these settings are applied immediately and do not require a restart +> +> - **For an EV charge control**: see [Virtual Grid Power / Compatibility with EV box](#virtual-grid-power--compatibility-with-ev-box) +> +> - **For a pump**: a contactor is recommended which can be coupled with a Shelly EM to activate / deactivate the contactor remotely, and it can be automated by Home Assistant or Jeedom based on the `Virtual Power` metric of this router, but also the hours of day, days of week, depending on the weather, and of course with some hysteresis and safety mechanisms to force the pump ON or OFF depending on some rules. +> {: .block-tip } + +**Rules of Automatic Switching** + +`Grid Virtual Power` is calculated by the router as `Grid Power - Routed Power`. +This is the power that would be sent to the grid if the router was not routing any power to the resistive loads. + +`Grid Virtual Power` is negative on export and positive on import. + +- The relay will automatically start when `Grid Virtual Power + Relay Load <= -3% of Relay Load`. + In other words, the relay will automatically start when there is enough excess to absorb both the load connected to the relay plus 3% more of it. + When the relay will start, the remaining excess not absorbed by the load will be absorbed by the dimmer. + +- The relay will automatically stop when `Grid Virtual Power >= 3% of Relay Threshold`. + In other words, the relay will automatically stop when there is no excess anymore but a grid import equal to or more than 3% of the relay threshold. + When the relay will stop, there will be some excess again, which will be absorbed by the dimmer. + +For a 3000W tri-phase resistance, 3% means 30W per relay because there is 3x 1000W resistances. +For a 2100W tri-phase resistance, 3% means 21W per relay because there is 3x 700W resistances. + #### Resistance Calibration **The router needs to know the resistance value of the load to correctly calculate the dimmer values**. @@ -527,14 +599,13 @@ Then you just have to report it in the `Hardware Config` page. - **JSY-MK-194T:** If you have a JSY-MK-194T, you can activate the dimmers one by one to 100% and wait for the values to stabilize. The router will then display the resistance value in the `Overview` page, thanks to the JSY. -**Using the automatic detection feature** (🚧) +**Using the automatic detection feature** -- `Output 1 Resistance Detection`: start the automatic detection of the resistance value of the load connected to Output 1 -- `Output 2 Resistance Detection`: start the automatic detection of the resistance value of the load connected to Output 2 +- `Resistance Detection`: start the automatic detection of the resistance value of the loads connected to Output 1 and 2 This is the easiest way to calibrate the resistance values: when a PZEM or JSY is installed, the router will be able to automatically calculate the resistance. -For that, click on the corresponding buttons and wait a few seconds. -You can at the same time check the statistics on the `Output` or `Overview` sections. +For that, click on the corresponding buttons and wait about 10-15 seconds. +You can at the same time check the statistics on the `Output` or `Overview` sections, and the logs in the Web console for a more detailed output. Once done, the resistance value will be put in the corresponding field. Any previously set value will be erased. @@ -579,29 +650,44 @@ You can read more at: ### `PID Controller` section > ##### DANGER +> > For advanced users only. -{: .block-danger } +> {: .block-danger } This page allows to tune the PID algorithm used to control the automatic routing. Use only if you know what you are doing and know how to tweak a PID controller. You can change the PID settings at runtime and the effect will appear immediately. +**Default Settings** + +- `Proportional Mode`: `On Input` +- `Derivative Mode`: `On Error` +- `Integral Correction`: `Advanced` +- `Kp`: `0.3` +- `Ki`: `0.6` +- `Kd`: `0.1` +- `Output Min`: `-1000` +- `Output Max`: `5000` + +To reset the other values to their default value, just click on the validate / enter green button. + > ##### TIP +> > If you find better settings, please do not hesitate to share them with the community. -{: .block-tip } +> {: .block-tip } [![](assets/img/screenshots/pid_tuning.jpeg)](assets/img/screenshots/pid_tuning.jpeg) -- `Real-time PID Data`: can be activated to see the PID action in real time in teh graphs. +- `Real-time Data`: can be activated to see the PID action in real time in teh graphs. - `Chart Reset`: click to reset the charts (has no effect on the PID controller). > ##### IMPORTANT > -> - Do not leave `Real-time PID Data` option always activated because the data flow is so high that it impacts the ESP32 performance. +> - Do not leave `Real-time Data` option always activated because the data flow is so high that it impacts the ESP32 performance. > > - you are supposed to know how to tune a PID controller. If not, please research on Google. -{: .block-important } +> {: .block-important } Here are some basic links to start with, which talks about the code used under the hood: @@ -610,21 +696,9 @@ Here are some basic links to start with, which talks about the code used under t - [Introducing Proportional On Measurement](http://brettbeauregard.com/blog/2017/06/introducing-proportional-on-measurement/) - [Proportional on Measurement – The Code](http://brettbeauregard.com/blog/2017/06/proportional-on-measurement-the-code/) -**Default Settings** - -- `Proportional Mode`: `On Input` -- `Derivative Mode`: `On Error` -- `Integral Correction`: `Advanced` -- `Setpoint`: `0` -- `Kp`: `0.3` -- `Ki`: `0.3` -- `Kd`: `0.1` -- `Output Min`: `-10000` -- `Output Max`: `10000` - **PID Tuning through WebSocket** -When `Real-time PID Data` is activated, a WebSocket endpoint is available at `/ws/pid/csv` and will stream all the PID data in real time in a `CSV` format when automatic dimmer control is activated. +When `Real-time Data` is activated, a WebSocket endpoint is available at `/ws/pid/csv` and will stream all the PID data in real time in a `CSV` format when automatic dimmer control is activated. You can quickly show then and process then in `bash` with `websocat` by typing for example: ```bash @@ -679,22 +753,6 @@ If no relay is installed, the dimmer will be used and will be set to 100%. In the `Hardware Config` section, `Output 1 Relay Type (Bypass)` and `Output 2 Relay Type (Bypass)` are used to specify the type of the relay: `Normally Open` or `Normally Closed`. -### Display - -Supported displays are any I2C OLED Display of type `SSD1307`, `SH1106`, `SH1107`. - -`SH1106` is recommended and has been extensively tested. - -[![](assets/img/screenshots/display.gif)](assets/img/screenshots/display.gif) - -The display will look like a carousel with a maximum of 5 pages: - -- Global information -- Network information -- Router information with relays -- Output 1 information -- Output 2 information - ### JSY-MK-194T (local) The JSY is used to measure: @@ -721,9 +779,10 @@ When using a remote JSY with the router, the following rules apply: - The grid power will always be read first from MQTT, then from a remote JSY, then from a connected JSY. > ##### TIP +> > JSY Remote app is automatically detected on the same network: you don't need to configure anything. > As soon as the Sender app will start sending data, YaSolR will receive it and display it. -{: .block-tip } +> {: .block-tip } ### LEDs @@ -758,31 +817,32 @@ Supported temperature sensor: `DS18B20` A temperature sensor can also be used to monitor the router box itself (`Overview` section). +### Virtual Grid Power / Compatibility with EV box + +The router exposes through API and MQTT the **Virtual Grid Power**, which is the value of Grid Power you would have if the router was not routing. + +You can use this value to inject in the EV box in order to prioritize EV charging over routing to the water tank. + +This is usually acceptable to give the EV box a priority over the water tank, because the water tank only need a small amount of routed energy to start heating, while the EV usually requires a threshold to start charging. +So the router will take whatever is not used by the EV box. + ### Zero-Cross Detection The Zero-Cross Detection (ZCD) module is used to detect the zero-crossing of the grid voltage. It is required, whether you use a Robodyn or SSR or any routing algorithm (phase control or burst mode). > ##### TIP +> > The Robodyn includes a ZCD (its ZC pin). > Do not forget to activate the ZCD module in the `Hardware` section. -{: .block-tip } +> {: .block-tip } You can also use a dedicated ZCD module like the one suggested on this website (build menu). -### Virtual Grid Power / Compatibility with EV box - -The router exposes through API and MQTT the **Virtual Grid Power**, which is the value of Grid Power you would have if the router was not routing. - -You can use this value to inject in the EV box in order to prioritize EV charging over routing to the water tank. - -This is usually acceptable to give the EV box a priority over the water tank, because the water tank only need a small amount of routed energy to start heating, while the EV usually requires a threshold to start charging. -So the router will take whatever is not used by the EV box. - > ##### IMPORTANT > > `Virtual Grid Power` requires a PZEM or JSY in place to measure the routed power. -{: .block-important } +> {: .block-important } ## Help and support diff --git a/docs/mqtt.md b/docs/mqtt.md index b3b4a58..de6a5d7 100644 --- a/docs/mqtt.md +++ b/docs/mqtt.md @@ -11,8 +11,6 @@ description: MQTT API - [`/grid`](#grid) - [`/router`](#router) - [`/router/outputX`](#routeroutputx) -- [`/router/outputX/dimmer`](#routeroutputxdimmer) -- [`/router/relayX`](#routerrelayx) - [`/system/app`](#systemapp) - [`/system/device`](#systemdevice) - [`/system/device/restart`](#systemdevicerestart) @@ -149,55 +147,40 @@ lights = 🟢 🟡 ⚫ power = 239.4906921 power_factor = 0.495258361 temperature = 26.30999947 +relay1 = off +relay2 = off thdi = 1.550398946 virtual_grid_power = -503.7492371 ``` -## `/router/outputX` - -```properties -bypass = on -state = Idle -temperature = 26.3 -``` - **Update** ```properties -# Switch bypass on or off -/router/outputX/bypass/set = "on" -/router/outputX/bypass/set = "off" +# Switch relay on or off or for a duration in milliseconds +/router/relayX/set = "on" +/router/relayX/set = "on=5000" +/router/relayX/set = "off" ``` -## `/router/outputX/dimmer` +## `/router/outputX` ```properties -duty = 1000 +state = Idle +bypass = on +dimmer = on duty_cycle = 100 -state = on +temperature = 26.3 ``` **Update** ```properties -# Update the dimmer duty / duty cycle -/router/outputX/dimmer/duty/set = [0, 4095] -/router/outputX/dimmer/duty_cycle/set = [0.0, 100.0] -``` - -## `/router/relayX` - -```properties -state = off -``` - -**Update** +# Switch bypass on or off +/router/outputX/bypass/set = "on" +/router/outputX/bypass/set = "off" -```properties -# Switch relay on or off or for a duration in milliseconds -/router/relayX/state/set = "on" -/router/relayX/state/set = "on=5000" -/router/relayX/state/set = "off" +# Update the dimmer duty cycle +/router/outputX/duty_cycle/set = [0.0, 100.0] ``` ## `/system/app` diff --git a/docs/overview.md b/docs/overview.md index f4ffd27..add5883 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -9,6 +9,7 @@ description: Overview - [What is a Solar Router ?](#what-is-a-solar-router-) - [How a Solar Router work ?](#how-a-solar-router-work-) - [Zero-Cross Detection (ZCD)](#zero-cross-detection-zcd) + - [The Importance of a good ZCD circuit](#the-importance-of-a-good-zcd-circuit) - [Robodyn and Solid State Relay (SSR)](#robodyn-and-solid-state-relay-ssr) - [Phase Control](#phase-control) - [Harmonics](#harmonics) @@ -60,6 +61,42 @@ Here are below some examples of how a ZCD circuit works by looking at 2 differen When the AC voltage curve crosses the Zero point, the ZCD circuit sends a pulse (with a custom duration) to the controller board, which now knows that the voltage is at zero. The board then does some calculation to determine when to send the signal to the TRIAC (or Random SSR or Robodyn) to activate it, based on the excess power, or if using burst fire control, to know when to let the current pass and for how many semi-periods. +### The Importance of a good ZCD circuit + +Using a good ZCD circuit producing a reliable pulse is very important. + +If the pulses are not reliable, some short flickering could be caused by a mis-detection of the zero point or by the existence of spurious pulses (false-positives), and consequently cause the TRIAC to fire at the wrong time, or the calculations for the burst fire sequence to be wrong. +These are visible if you plug an incandescent light bulb to the dimmer output: the bulb will flicker from time to time. +The effect on a water tank resistance is even bigger: it will create some spurious spikes of power consumption, that the router will try to compensate just after by considerably reducing the dimming level. +This creates some waves instead of keeping the import and export at a near-0 level. + +These phenomena are not visible with a good ZCD module coupled with a Random SSR. + +The Robodyn is such a device that has an unreliable ZC pulse: all experts working on Solar Routers who have measured that correctly, tend to agree with the fact that **the Robodyn is one of the worst device to use because of its unreliable ZC and poor quality circuit and heat sink**. + +Here is below a YaSolR screenshot of the Grid Power graph showing the effect of a bad ZCD module on the power consumption and import. +On the lef side, the Robodyn ZCD is used, then I've switched (live) to a dedicated ZCD module. + +[![](assets/img/screenshots/robodyn-vs-zc-module-grid-power.jpeg)](assets/img/screenshots/robodyn-vs-zc-module-grid-power.jpeg) + +Here is another example below of th YaSolR PID Tuning view showing the input value of the PID controller. +The dedicated ZCD module was used, then I've switched (live) to a Robodyn ZCD module. +The update rate is high: 3 times per second. +All the JSY measurements are captured and displayed. +You can clearly see the flickering caused by the bad quality of the Robodyn ZCD pulses, which gets compensated just after by the PID controller. + +[![](assets/img/screenshots/robodyn-vs-zc-module-pid-tuning.jpeg)](assets/img/screenshots/robodyn-vs-zc-module-pid-tuning.jpeg) + +Lastly, here is a graph showing in Home Assistant the effect of the Robodyn ZCD on the dimmer output. +The Robodyn ZCD was used form 11:58 to 12:02, then I've switched (live) to a dedicated ZCD module. + +[![](assets/img/screenshots/robodyn-vs-zc-module-ha.jpeg)](assets/img/screenshots/robodyn-vs-zc-module-ha.jpeg) + +You can read more about these issues here also: + +- [About dimmer boards](https://github.com/fabianoriccardi/dimmable-light/wiki/About-dimmer-boards) +- [Notes about specific architectures](https://github.com/fabianoriccardi/dimmable-light/wiki/Notes-about-specific-architectures#esp32) + ### Robodyn and Solid State Relay (SSR) A Solid State Relay is a relay that does not have any moving parts and is based on a semiconductor. @@ -96,7 +133,7 @@ Here are 3 different views from an Owon VDS6104 oscilloscope of: 3. The control voltage of the random SSR (or Robodyn) that is sent from the ESP32 board. The TRIAC will let the current pass when the control voltage is >= 3.3V (blue) 4. The dimmed AC current at dimmer output (pink) -| | **Dimmer Duty 10 / 4095** | **Dimmer Duty 2047 / 4095 (50%)** | **Dimmer Duty 4090 / 4095** | +| | **Dimmer Duty 0.24%** | **Dimmer Duty 50%** | **Dimmer Duty 4090 / 4095** | | :-------------------: | :---------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------: | | **Robodyn** | [![](assets/img/measurements/Robodyn_duty_10.png)](assets/img/measurements/Robodyn_duty_10.png) | [![](assets/img/measurements/Robodyn_duty_2047.png)](assets/img/measurements/Robodyn_duty_2047.png) | [![](assets/img/measurements/Robodyn_duty_4090.png)](assets/img/measurements/Robodyn_duty_4090.png) | | **Better ZCD Module** | [![](assets/img/measurements/ZCD_duty_10.png)](assets/img/measurements/ZCD_duty_10.png) | [![](assets/img/measurements/ZCD_duty_2047.png)](assets/img/measurements/ZCD_duty_2047.png) | [![](assets/img/measurements/ZCD_duty_4090.png)](assets/img/measurements/ZCD_duty_4090.png) | diff --git a/docs/rest.md b/docs/rest.md index 9d51cba..01cd3dd 100644 --- a/docs/rest.md +++ b/docs/rest.md @@ -27,7 +27,6 @@ curl -X GET http:///api { "config": "http://192.168.125.123/api/config", "config/backup": "http://192.168.125.123/api/config/backup", - "debug": "http://192.168.125.123/api/debug", "grid": "http://192.168.125.123/api/grid", "router": "http://192.168.125.123/api/router", "system": "http://192.168.125.123/api/system", @@ -201,76 +200,56 @@ curl -X GET http:///api/router ```json { "lights": "🟢 ⚫ ⚫", - "temperature": 26.12999916, - "virtual_grid_power": 688.6345825, + "relay1": "off", + "relay2": "off", + "temperature": 24.5, + "virtual_grid_power": -171.6903992, "measurements": { "apparent_power": 0, "current": 0, - "energy": 0, + "energy": 0.810000002, "power": 0, "power_factor": 0, "resistance": 0, "thdi": 0, - "voltage": 237.3479004, + "voltage": 0, "voltage_dimmed": 0 }, "output1": { + "state": "IDLE", "bypass": "off", - "state": "Idle", - "temperature": 24.62999916, - "dimmer": { - "duty": 0, - "duty_cycle": 0, - "state": "off" - }, + "dimmer": "off", + "duty_cycle": 0, + "temperature": 24.25, "measurements": { "apparent_power": 0, "current": 0, - "energy": 0.388000011, + "energy": 0, "power": 0, "power_factor": 0, "resistance": 0, "thdi": 0, - "voltage": 237.3999939, + "voltage": 0, "voltage_dimmed": 0 - }, - "relay": { - "state": "off", - "switch_count": 0 } }, "output2": { + "state": "IDLE", "bypass": "off", - "state": "Idle", - "temperature": 24.62999916, - "dimmer": { - "duty": 0, - "duty_cycle": 0, - "state": "off" - }, + "dimmer": "off", + "duty_cycle": 0, + "temperature": 0, "measurements": { "apparent_power": 0, "current": 0, - "energy": 0.647000015, + "energy": 0, "power": 0, "power_factor": 0, "resistance": 0, "thdi": 0, - "voltage": 237.6000061, + "voltage": 0, "voltage_dimmed": 0 - }, - "relay": { - "state": "off", - "switch_count": 0 } - }, - "relay1": { - "state": "off", - "switch_count": 0 - }, - "relay2": { - "state": "off", - "switch_count": 0 } } ``` @@ -283,13 +262,6 @@ curl -X POST \ http:///api/router/relay1 ``` -```bash -# Set the duty of the dimmer -curl -X POST \ - -F "duty=4095" \ - http:///api/router/output1/dimmer -``` - ```bash # Set the duty cycle of the dimmer [0.0, 100.0] curl -X POST \