logo elektroda
logo elektroda
X
logo elektroda

Low-cost water heating project from photovoltaic overproduction on ESP8266 and Tasmota

Daro1003 5874 26

TL;DR

  • A low-cost ESP8266 and Tasmota project switches a water heater on when photovoltaic overproduction reaches a chosen threshold.
  • A PZEM-004T power meter sits on the inverter’s direct phase wire, and a relay on a free GPIO controls the heater.
  • The whole build should cost no more than 100 zł, even if the parts are bought on Allegro.
  • The prototype works in Tasmota, but it still lacks a finished enclosure and advanced functions.
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • Over-production water heating for PV users under new billing rules.

    I would like to present a low-cost project that can be done by anyone who likes electronics and happens to hold a soldering iron in their hand.
    The project is designed to switch on the heater when our photovoltaic installation generates a certain power. A control problem often encountered by users of photovoltaic installations - i.e. how to heat water when it is lit.

    The system I have presented is very simple to build and cheap, it does not have advanced functions like the systems you can buy for over a thousand zlotys, but I think it will certainly help.

    Everything is based on a circuit:
    1. ESP8266
    PZEM 004-t module, which sees the flow of power with current regardless of the direction, so the final assembly is important to be on a direct wire from the inverter.
    3. Free software TASMOTA which we win to the ESP8266 using e.g. NodeMCU Flasher .

    The elements I used in the project are:

    1. PZEM 004-t measuring module
    2. ESP 8266 + board with 5V stabilizer because I just had it, but we can use wemos D1 mini or NodeMCU then we won't need USB TTL programmer but just USB cable from phone to program wemos. For those new to the subject, I would recommend buying a Wems D1 mini, it has everything you need on board for programming and operation once the tasmot is loaded.
    3. a button - which will be used to put the ESP into a configuration state.
    4. wires to connect the ESP8226 to the input of the PZEM 004-t Module, you can also buy the original cable with plug that fits the PZEM 004-t.
    5. the female-to-female wires will also be useful if you purchase the Wemos D1mini.
    6. 5V relay module
    7. 5V power supply - a phone charger can be used.
    8. Tasmota software and NodeMCU Flasher links above.

    Components for a heater control project in a photovoltaic system. .

    How to connect the module
    PZEM to ESP there is a lot of this on the internet, as well as how to upload the Tasmota and its first start-up. I do not want to duplicate these instructions here, they can be found on google.
    Borrowed diagram from google:
    Wiring diagram of PZEM module to ESP8266 .

    We connect the PZEM module to GPIO 4 and GPIO 5 GPIO 4 TX PZEM to GPIO 5 RX PZEM.
    We connect the relay module to the free GPIO.
    To GPIO 0 and to GND we connect the button giving GND to GPIO0 6 times puts the module into hot-spot mode while giving GND to GPIO while turning on ESP puts it into flash mode.

    After loading the tasmota and the first start-up, having the ESP with the tasmota already in our local network, we move on to the module settings:

    Screenshot of Tasmota configuration showing GPIO port settings. .

    Such settings we save the module restarts and we have the screen:

    User interface for the Tasmota system displaying voltage and power data. .

    We can check if our relay is working and if we have voltage on the PZEM
    Of course we connect 230V to the PEM according to the diagram above.

    I for testing did it like this:

    ESP8266 module with relay module and wiring. ESP8266 and PZEM 004-t modules connected to a 4-channel relay .

    The picture shows a 4 channel relay module connected under two GPIOs because I was testing two rules which are designed to switch on individual relays at different powers. That is, for example, the power going through the PZEM, e.g. above 2000W turns on relay 1, the power going above 3000W turns on relay 2.

    How much power we set is an individual matter.

    Another key setting is the rule by which the whole system works. A rule borrowed from another forum from my colleague isom to whom I thank for his kindness.

    Go to the console tab:

    We specify the key rule to run.

    Rule1 on Energy#Power>2000 do Power1 1 ENDON on Energy#Power<2000 do Power1 0 ENDON
    .

    And enabling the rule to make it work:

    Rule1 on
    .

    In the first part of the rule:
    Energy#Power> 2000 - we specify from above what power the relay should turn on.

    In the second part of the rule:
    Energy#Power< 2000 - we specify from below what power the transmitter should switch off.

    Now checking that everything is working is enough to mount it in the switchgear.
    We mount the measuring clamp on the phase conductor going directly from the inverter and take 230V from the same phase to the PZEM.
    The PZEM module sees the power and current flow no matter which way it flows, so we have to mount it directly on the wire from the inverter.

    The cost of the whole project should not exceed 100zł even if you buy the components on allegro.

    I encourage colleagues to discuss and comment on my idea, maybe thanks to colleagues from Smart Home IoT the project will get more functions and will be extended.

    I have also made a project on 3 PZEM modules which monitors the energy consumption for the house was mounted directly on the power supply of the distribution blocks for the protection on the house. The inverter has been plugged in front of the blocks that supply the house thanks to this in tasmotoa I can see the energy consumption of the house and the current power flowing from the inverter.

    Relay modules and ESP8266 on a prototype board in an electrical distribution box. .

    The above project has not yet gained a casing is currently a prototype but I think that the casing and implementation will already be an individual matter of each, I wanted to throw in a general idea of making such a control for water heating counting on the ideas of other more experienced users in the software Tasmota and ESP8266.

    Cool? Ranking DIY
    About Author
    Daro1003
    Level 34  
    Offline 
    Daro1003 wrote 2709 posts with rating 603, helped 295 times. Live in city Szerzyny. Been with us since 2008 year.
  • ADVERTISEMENT
  • #2 21178285
    __Maciek__
    Level 21  
    Posts: 366
    Help: 25
    Rate: 91
    Board Language: polish
    Not a bad idea, but ...
    - It would be useful to have some kind of hysteresis ... or a timer, so that the relay doesn't click like crazy at the limit (for this, a properly located current measurement).
    - With - net billing - the net works like a battery with a short holding time ... so you can accumulate for 50 minutes and use it up in the last 10 minutes ( unless 15 minute timers come in ) - a more sophisticated system could use this free battery to the full.
  • #3 21179148
    michal.zd
    Level 31  
    Posts: 1603
    Help: 83
    Rate: 262
    Board Language: polish
    Daro1003 wrote:
    Module PZEM 004-t which sees the flow of power o current regardless of direction
    .
    Do I understand this correctly? There is no information about the direction of energy flow, so you used it to measure the actual power generated by the pv inverter?
    If so, it is simpler to read this directly from the inverter. There are two methods.
    You can parse the information from the html, a simple GET to the appropriate port on the inverter.
    The best way is to use Modbus data. This is what I did too, in addition I also have phase voltage information, which I use to react to a rise above the norm.
    I wrote myself a broker between the inverter and the MQTT server.
    The code is available on my git https://github.com/michalzd/pvInverterBroker/tree/mqtt
    for a sofar ktlx-g3 inverter with a wifi logger attached. It is written so that it can be compiled and run on routers with OpenWrt. To do this you still need the https://github.com/michalzd/MQTT_LinuxLib library.
    The current compilation in the repo is for the raspberry pi zero W, and A, Aplus. Previously it was just running on a tplink tlwr 740n, but the router died after a few years. It now runs on the rpi A, as an mqtt server and nodered control logic is needed anyway. The price of these rpi is so low that it makes no sense to combine with a router. The executive module is a Sonoff 4ch with the firmware changed to AFEfirmware. For my part, I recommend this firmware, it is very easy to configure and stable as a rock.
    Adding another inverter is no problem, you just need to know the registers and modbus data format. To change the code only in the following files: inverter/Sofar.c and Sofar.h
  • ADVERTISEMENT
  • #4 21179171
    Daro1003
    Level 34  
    Posts: 2709
    Help: 295
    Rate: 603
    Board Language: polish
    michal.zd wrote:
    Do I understand correctly? There is no information about the direction of the energy flow, so you used it to measure the actual power generated by the pv inverter?


    This is exactly why the installation of a measuring clamp is important.

    A project for people like me who only use off-the-shelf software.

    Tell me more about how to construct your project and I will be happy to test it on my Sofar Safar HYD15KTL-3PH inverter.

    I must admit, however, that the design you presented is less impressive but certainly much simpler to implement.
  • #5 21179301
    michal.zd
    Level 31  
    Posts: 1603
    Help: 83
    Rate: 262
    Board Language: polish
    The program can be compiled on any Linux. The test version was run by me on a normal Debian laptop. I can upload the binaries to git as well.
    There are two in total, a broker and a library.
    For the rpi with the Broadcom BCM2835 SoC[3], which consists of the ARM1176JZF-S processor, you can download the binaries from the dist subdirectories....
    I'll have a moment, I'll describe in github how to run the broker.

    Added after 4 [minutes]: .

    Daro1003 wrote:
    It has to be said, however, that the design presented by me is less impressive but certainly much simpler to realise.

    Yes,
    It can also be adapted to use my broker, as it also has an interface via UDP.
    Then information about the status of the inverter and the network will be sent from the broker as a structure.

    Added after 3 [minutes]:

    Daro1003 wrote:
    HYD15KTL-3PH
    .
    The data available via Modbus is probably identical across the Sofar family.
    In addition there is also information about the status of the energy storage.
    Do you have a wifi logger for it?
  • #6 21179322
    Daro1003
    Level 34  
    Posts: 2709
    Help: 295
    Rate: 603
    Board Language: polish
    michal.zd wrote:
    Do you have a wifi logger for it?


    Yes I have one connected to the app.

    I also have pin 1 and 3 out for communication and pin 5 and 6 used for communication with the meter it works with.

    Table of pin assignments and connection diagram for inverter and measurement devices. .

    I tried to communicate this with the RBPi on which I have Domoticz. But somehow I failed.
    Topic about this where someone even created a plugin for this but you still have to set up other topics and I relented.

    If I managed to get all the available data from Sofar into domoticz it would be fun to use. So far in domoticz I only have what the reading from tasmota allows me to do.
  • #7 21179328
    michal.zd
    Level 31  
    Posts: 1603
    Help: 83
    Rate: 262
    Board Language: polish
    Which rpi do you have? Version.
    The current version communicates with the logger via wifi.
  • ADVERTISEMENT
  • #8 21179332
    Daro1003
    Level 34  
    Posts: 2709
    Help: 295
    Rate: 603
    Board Language: polish
    All on 3B+ with SSD to somehow make domoticz work stably. I also have a broker on it for integration with Tasmota, AFE or others.
  • #9 21179341
    michal.zd
    Level 31  
    Posts: 1603
    Help: 83
    Rate: 262
    Board Language: polish
    Ok, and do you have mosquitto there? The mqtt server is needed to send data to domoticz. Broker - is that what you mean by mqtt?
    I use nodered, it's more transparent for me compared to domoticz.
    I think even domoticz needs it?
  • #10 21179402
    Daro1003
    Level 34  
    Posts: 2709
    Help: 295
    Rate: 603
    Board Language: polish
    michal.zd wrote:
    Ok, and do you have mosquitto there?
    .
    I do.
    michal.zd wrote:
    I use nodered, it is more transparent for me compared to domoticz.
    .
    Unfortunately NodeRed I have nothing about it I don't know what and how.
    michal.zd wrote:
    I guess even domoticz needs it?
    .
    Apparently so, and not much can be achieved in domoticz without it, but I have no knowledge of it at all, so I am somehow combining things differently. Surely with it a lot of information from various devices would be gained in domoticz.
  • #11 21179432
    michal.zd
    Level 31  
    Posts: 1603
    Help: 83
    Rate: 262
    Board Language: polish
    Daro1003 wrote:
    NodeRed I don't have anything about it I don't know what or how.

    it's great, there's basically nothing you can't do on it.
    domoticz it doesn't even compare with nodered along with dashboard.
    see example view with nodered, i took a screenshot a while ago.
    Screenshot of a Node-RED dashboard displaying inverter status and voltage graphs for three phases. .
    and this is in a minute:
    Screenshot of the Node-RED interface displaying inverter status and voltage charts. .

    The status of the inverter is itself transmitted via mqtt from my broker.
    The data for the voltage graphs also, the pink line is the instantaneous voltage, while the turquoise line is the average voltage over the last ten minutes. This data serves as input to the block responsible for keeping the voltages normal, switching on the heaters in the buffer. If possible, of course, because sometimes the mains voltage is so high that no amount of power will help. Fortunately, such a situation is not frequent, and also the duration is several minutes. But thanks to the fact that I know that at this point my inverter has switched off, I also switch off the heaters. The controller logic is just written in javascript and works as a 'node' in nodered. The status is shown at the bottom as a light with a 'UNF' label indicating which phase has exceeded the voltage (this still needs to be worked out, it's fresh functionality)
    I also have domoticz, but after struggling for a few hours to integrate it with my broker, it turned out that nodered was the necessary middleman here. As soon as I started using nodered, I realised that domoticz here was really completely missing the point, just consuming memory and prock percentage. It flew out of rpi, I only have nodered.
    It's worth a go, I was already able to do what I want in it after two days of learning. Javascript is a simple language, and there is no need to use it as long as the 'node' blocks available in nodered are sufficient.

    Added after 1 [minute]: .

    Daro1003 wrote:
    I'm sure it would benefit a lot in domoticz information from different devices.

    After a few days of using nodered you will come to the same conclusion as I did: and on Pippi Långstrump mi domoticz.

    Added after 44 [minutes]:

    Quite an accessible course
    https://m.youtube.com/watch?v=9fTMpgr3EU0
  • #12 21179545
    Daro1003
    Level 34  
    Posts: 2709
    Help: 295
    Rate: 603
    Board Language: polish
    Thanks for the course, I need to start first with the installation of NodeRed.
    How better on the same RBPi as domoticz or on another ?
  • #13 21179552
    michal.zd
    Level 31  
    Posts: 1603
    Help: 83
    Rate: 262
    Board Language: polish
    If you have an ssd, two side by side will do fine. Besides, you probably have GB of ram,
    Do you know a bit about Linux from the terminal side?
    There is a program called htop that shows you the current load of your machine. You can check how much ram and CPU domoticz eats, but probably not much. NodeRed on mine takes about 100MB and the CPU percentage is under 5

    Added after 32 [minutes]:

    I also looked at the discussion on the smart home forum you have a link to.
    It appears to me that this plugin is attached to the inverter via a cable connector.
    I immediately communicate via wifi with the LSW logger attached.

    Added after 28 [minutes]: .

    In order for you to test my broker, you need to compile these two programs at your Raspberry, I have a different processor in my rpi.
    Some preparations needed for compilation:
    1. a 'C' compiler along with the necessary libraries:
    https://linux.how2shout.com/hwo-to-install-build-essential-on-debian-such-as-12-and-11/

    2. the first program needed is the library https://github.com/michalzd/MQTT_LinuxLib
    you can download it in two ways:
    way 1: download the repository as a zip by clicking on the green 'Code' button and unzip in any user directory on the rpi, e.g: /home/user_name/MQTT_LinuxLib
    method 2: install git on the malinka:
    # sudo apt-get install git git-core
    # cd ~
    # mkdir MQTT_LinuxLib
    # cd ./MQTT_LinuxLib
    # git clone https://github.com/michalzd/MQTT_LinuxLib.git

    3. after that in the MQTT_LinuxLib directory
    # make

    should compile. once you have that, I'll tell you what to do next.

    Added after 15 [minutes]: .

    I also have an rpi 4 with an ARM-8 Cortex-A72 processor, the 3 has an ARM-8 Cortex-A53.
    I wonder if they are compatible from the code side. I can run a test. I will prepare a simple test program to run at your place. If it runs without a problem, I will compile the broker at home.

    Added after 1 [hour] 1 [minute]: .

    First attempt, compile a simple test on a raspberry pi 1 B (mine) with the compiler flag -mcpu=cortex-a53 -mfpu=neon-fp-armv8 .
    upload it to your home directory and fire it up. See if it works.
    only after copying it to the raspberry you need to give it the rights to run:
    # chmod a+rwx ./testcortexa53.bin
    Attachments:
    • testcortexa53.bin (7.88 KB) You must be logged in to download this attachment.
    • testcortexa53.bin (7.88 KB) You must be logged in to download this attachment.
  • #14 21179926
    Daro1003
    Level 34  
    Posts: 2709
    Help: 295
    Rate: 603
    Board Language: polish
    @michal.zd I very much appreciate your work and commitment but you approach the subject in a very advanced way. Personally, I don't really know what to do and how with your information. I approach the subject in such a way that anyone who likes to hold a soldering iron in their hand can make something simple for their own use to heat water. In your case, as I already wrote, the idea is certainly better and more effective, because it is the data from the inverter that will play the main role, but the instructions from you are, in my opinion, for a programmer, not for an electrician who is green in programming and uses ready-made solutions.

    As the topic has gone a bit in a different direction, it would be nice to create another topic with your idea starting with what is needed for this project to be able to assemble it - I myself would be happy to order components and would like to assemble it according to your idea as I see more potential in it by using the data from the inverter. An important issue of the project is the cost - it is well known that there are already solutions of this type on the market for about 1 thousand zlotys, so if you can heat it on some cheap RBPi e.g. zero memory card and power supply or possibly a USB->RS485 converter it will be cool, but let's start from the beginning.
  • #15 21180001
    michal.zd
    Level 31  
    Posts: 1603
    Help: 83
    Rate: 262
    Board Language: polish
    Daro1003 wrote:
    the instructions from you are in my opinion for a programmer
    .
    rather for someone who is already familiar with Linux and not afraid of compilation.
    That's why I asked earlier how you feel about the Linux terminal.
    But the following list of steps is not complicated ;) .
    But as recompiling for me under a different architecture is not a problem, in addition I was able to run the test on my second malinka 4, I already have some observations.
    The processor in the tinyka 4 ran the test program compiled under rpi 1 B+ without any problems. In principle, ARM Cortex-A are compatible upwards, this is just normal. On the other hand, the processor in the raspberry 1 is not cortex, this made me doubt whether the program would work.
    Also I compiled these programs for your version of the processor too, the binaries are available in my github.
    So the whole process of compiling the program is dropped, you just need to download the binary and put it in the right directory.

    For you it would be this library:
    https://github.com/michalzd/MQTT_LinuxLib/tre...dist/Release/GNU-Linux/RaspberryPi/Cortex-A53
    place the file in a directory, you don't need to do anything else
    /usr/lib

    Broker program:
    https://github.com/michalzd/pvInverterBroker/...dist/Release/GNU-Linux/RaspberryPi/Cortex-A53
    preferably in the /usr directory, create a directory like the following and put the binary there
    /usr/inverter
    You will probably even very much have to give this binary execution rights. The easiest way to do this is with mc.

    For this you still need the configuration file from
    https://github.com/michalzd/pvInverterBroker/tree/mqtt/etc
    and put it into (you also need to create a directory in /etc)
    /etc/ime
    In this file there will be a few lines to change:
    
    # Sofar Logger 
    logger_sn	2363445823
    logger_addr	192.168.10.70
    logger_port	8899
    
    # refresh time in sec
    refresh_time	30
    
    # broker udp port 
    service_port	8898
    
    # mqtt server  topic danych textowych oraz binarnych  
    mqtt_server		192.168.10.80:1883
    mqtt_topic		ime/inverter/
    mqtt_binary_topic	ime/inverterbin
    
    .

    at the top, the access to the logger, and the address to mosquitto - which is the same as malinka has.
    the data will be sent to the mqtt server with the topics as in the file, of course you can also change it.
    the best thing to do is to start mosquitto_sub on the tinker to listen on the topic with mqtt_topic, i.e. 'ime/inverter/#'.
    you should get information from the inverter every half minute.

    Added after 3 [minutes]: .

    For uploading files to a raspberry from Windows, download the program:
    https://winscp.net/eng/downloads.php#additional
    preferably "Portable executables", a link to which is slightly below on this page.
  • ADVERTISEMENT
  • #16 21180417
    speedy9
    Helpful for users
    Posts: 12019
    Help: 1231
    Rate: 2414
    Board Language: polish
    Tuya makes ready-made modules that additionally detect the direction of current flow. So if someone is using the Tuya system anyway, there is no simpler or cheaper way to realise the above functionality. A module with a single-point measurement costs about PLN 70, a two-point module about PLN 85. It is possible to configure dependencies, enter hysteresis.
  • #17 21180429
    Daro1003
    Level 34  
    Posts: 2709
    Help: 295
    Rate: 603
    Board Language: polish
    speedy9 wrote:
    uya makes ready-made modules that additionally detect the direction of current flow.
    .
    You can insert a link I will be happy to test.
  • #18 21180439
    speedy9
    Helpful for users
    Posts: 12019
    Help: 1231
    Rate: 2414
    Board Language: polish
    Even cheaper than I wrote before: https://www.aliexpress.com/item/1005005885768083.html
    I am thinking of buying a similar module, but a three-phase one: https://www.aliexpress.com/item/1005006456832377.html Rather out of curiosity, as I have a PV under the old rules and don't really have a need to use the surplus somehow. Rather out of curiosity as to what the power consumption looks like on the individual phases.
  • #19 21180446
    Daro1003
    Level 34  
    Posts: 2709
    Help: 295
    Rate: 603
    Board Language: polish
    I have a 3 phase build on a PZEM 004-t on each phase the power is identical rather there is no point in measuring from the inverter the power on each phase unless you want to use it to measure the power consumption in the house.
    Single-channel 57zl two-channel 66zl you have to order a single-channel one to test what and how you can set it there.

    We still don't have any information about the over production that the inverter has, and in total this is the most important thing, i.e. the power that goes into the grid and above e.g. 1500W we switch on the heater.

    Inverter display screen showing power generation and transmission values. .
  • #20 21180461
    speedy9
    Helpful for users
    Posts: 12019
    Help: 1231
    Rate: 2414
    Board Language: polish
    That's why you put the measurement on the output to the grid. The direction of the current flow tells you whether you have an overproduction and send it to the grid or a shortage and take it. You can make a second measuring point on the heater. You need to think about the measurement points, especially if you have a three-phase installation and inverter.
    I'm not interested in monitoring the power on the phases from the inverter, that's what I have in the app from the inverter. However, my inverter does not show what you have on the display, because it can only do such things after attaching a so-called SmartMeter, which costs too much to satisfy curiosity ;) .
  • #21 21180468
    Daro1003
    Level 34  
    Posts: 2709
    Help: 295
    Rate: 603
    Board Language: polish
    speedy9 wrote:
    SmartMeter, which costs too much to satisfy curiosity


    That's exactly how I ended up with a seller - a friend who, in the price of the inverter, gave me this meter tz. said that it comes with the inverter every other seller takes it out of the box and sells it separately.
  • #22 21180471
    speedy9
    Helpful for users
    Posts: 12019
    Help: 1231
    Rate: 2414
    Board Language: polish
    I have a Huawei inverter and there this meter was always separate.
  • #23 21180478
    Daro1003
    Level 34  
    Posts: 2709
    Help: 295
    Rate: 603
    Board Language: polish
    speedy9 wrote:
    This is why you put the measurement on the output to the grid. The direction of current flow tells you whether you have an overproduction and send it to the grid or a shortage and take it.
    .

    In a system like this it only makes sense to me to have a 3 phase to catch the overproduction in total you can catch the overproduction flying through this phase and mount a heater on this phase. Well maybe ok
  • #24 21180883
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1297
    Board Language: polish
    Just out of curiosity, what is the definition of overproduction in this case ?
  • #25 21182849
    chemik_16
    Level 27  
    Posts: 999
    Help: 74
    Rate: 127
    Board Language: polish
    I had about 8pc of these PRZEMs, they did not work for me. They generated a lot of "spikes", some sudden measurements of 150kW. In the event of a power cut, they went completely crazy. After half a year 4 pieces died, only the red diode was lightly lit, probably the voltage stabiliser circuits went out.
  • #26 21191474
    jaros12
    Level 12  
    Posts: 11
    Board Language: polish
    >>21179148 Measurement of current alone (i.e. indirectly power) without direction of flow, can also be done without PZEM, directly on the analogue input of the ESP. All you need is a transformer for 20PLN + a few resistors and a capacitor.
  • #27 21299109
    kolo9
    Level 14  
    Posts: 310
    Help: 7
    Rate: 46
    Board Language: polish
    Daro1003 wrote:
    .
    In such an arrangement it only makes sense to me to have a 3 phase to catch the overproduction in total you can catch the overproduction flying through this phase and mount a heater on this phase. Well maybe ok
    I wonder from what date did the contracts get so unfavourable to make it worthwhile to heat from overproduction? I have a 3 phase Huawey and am facing a refurbishment as part of which it would make sense to change the CWU.
📢 Listen (AI):

Topic summary

✨ The discussion centers on a low-cost DIY project for heating water using surplus photovoltaic (PV) power under new net billing regulations. The core system uses an ESP8266 microcontroller combined with a PZEM-004T energy meter module to measure power flow on the direct wire from the inverter, controlled via free Tasmota firmware flashed with NodeMCU Flasher. Key challenges include detecting overproduction accurately, managing relay switching with hysteresis or timers to avoid rapid toggling, and handling three-phase installations. Alternative approaches suggest reading inverter data directly via Modbus or HTTP interfaces, enabling more precise control and integration with home automation platforms like Domoticz or Node-RED through MQTT brokers. Some users report reliability issues with PZEM-004T modules, while others recommend Tuya modules capable of detecting current flow direction, offering simpler and cheaper solutions with configurable hysteresis. The importance of measuring power flow direction at the grid output is emphasized to identify true overproduction. Discussions also cover hardware compatibility, software compilation on Raspberry Pi models, and integration complexities for users less familiar with Linux or programming. The project aims to provide a simple, affordable solution for electronics enthusiasts to utilize PV overproduction for water heating, contrasting with more expensive commercial systems.
Generated by the language model.

FAQ

TL;DR: For PV owners, this ~100 zł controller uses ESP8266, PZEM-004T, and a 5 V relay; as one poster put it, "anyone who likes electronics" can build it. It switches a heater from measured export power in Tasmota, but adding hysteresis or reading the inverter directly over Modbus makes control steadier and smarter. [#21178107]

Why it matters: Under net billing, self-consuming surplus PV can be more valuable than exporting it cheaply and buying energy back later.

Approach Hardware Typical cost from thread Main strength Main limit
DIY Tasmota + PZEM ESP8266, PZEM-004T, 5 V relay ≤100 zł Simple, low-cost, solder-and-configure build Needs careful clamp placement and better anti-chatter logic
Inverter data via Wi‑Fi/Modbus Raspberry Pi, logger, MQTT broker Reuses existing Pi/logger Reads richer Sofar data, including status and voltages Harder for non-Linux users
Tuya direction-sensing module Tuya meter module ~57–85 zł Cheap, ready-made, supports hysteresis/dependencies Less open and less DIY-flexible

Key insight: The most important design choice is where you measure power. If you measure on the inverter feed or grid connection correctly, you can detect actual export; if you measure in the wrong place, you control the heater from the wrong power signal.

Quick Facts

  • The starter build uses 8 parts: PZEM-004T, ESP8266 board, button, wiring, female-to-female jumpers, 5 V relay module, 5 V supply, and Tasmota flashed with NodeMCU Flasher. [#21178107]
  • The published relay rule uses a 2000 W threshold: Energy#Power>2000 turns the relay on, and Energy#Power<2000 turns it off. [#21178107]
  • The author states the full DIY controller should cost no more than 100 zł, even when buying parts on Allegro. [#21178107]
  • Reported reliability problems exist: one user saw false spikes up to 150 kW, and 4 of about 8 PZEM units failed after roughly half a year. [#21182849]
  • Thread price points for alternatives were lower than expected: a Tuya single-point module was quoted at about 57–70 zł, and a two-point version at about 66–85 zł. [#21180439]

How do I build a low-cost PV overproduction water heater controller with ESP8266, PZEM-004T, a 5V relay, and Tasmota?

Build it from an ESP8266 board, one PZEM-004T, a 5 V relay, a button, and a 5 V phone charger. 1. Flash Tasmota to a Wemos D1 mini, NodeMCU, or ESP8266 board. 2. Wire the PZEM to the ESP and the relay to a free GPIO. 3. Add a Tasmota rule that switches the relay when measured power exceeds your export threshold, such as 2000 W. The author says the complete project should stay under 100 zł and is meant for people using ready-made software, not custom firmware. [#21178107]

What GPIO connections and Tasmota module settings are needed to get a PZEM-004T and relay working on a Wemos D1 mini or NodeMCU?

Use GPIO4 and GPIO5 for the PZEM serial link, and use any free GPIO for the relay. The post states GPIO4 goes to PZEM TX, GPIO5 goes to PZEM RX, and the button goes between GPIO0 and GND. Pressing GPIO0 to GND six times enters hotspot mode, while holding GPIO0 low during power-up enters flash mode. In Tasmota, save the module settings so the PZEM and relay are assigned correctly, then verify relay switching and voltage reading before connecting the final 230 V wiring. [#21178107]

How do I write a Tasmota Rule1 command that turns a heater relay on above 2000 W and off below the threshold?

Use this Rule1 command: Rule1 on Energy#Power>2000 do Power1 1 ENDON on Energy#Power<2000 do Power1 0 ENDON. Then enable it with Rule1 on. This switches relay 1 on when measured power rises above 2000 W and turns it off when power drops below 2000 W. The thread also notes that the exact wattage is an individual setting, so you can replace 2000 with your own export threshold. [#21178107]

What is hysteresis in a PV surplus heater controller, and how can I add it in Tasmota so the relay does not chatter near the switching point?

Hysteresis is a gap between the ON and OFF thresholds that prevents rapid relay switching near one limit. Add it by using different values, not the same 2000 W point both ways. For example, turn the relay on above 2000 W and off below a lower value, or add a timer. One forum reply explicitly warned that without hysteresis or timing, the relay can "click like crazy at the limit." That makes hysteresis the first upgrade to the original rule. [#21178285]

Why does the mounting position of the PZEM measuring clamp matter when I want to detect PV export instead of total household power?

The clamp position matters because the controller reacts to whatever conductor you measure. The author says the PZEM sees power and current regardless of flow direction, so the final assembly must be on the direct wire from the inverter if you want PV-related power, not mixed household demand. Another reply adds that if you want true export, put measurement on the output to the grid, because current direction then shows whether energy is being sent out or taken in. Wrong placement gives the heater the wrong trigger signal. [#21180461]

What is net billing in the context of photovoltaic installations, and why does it change whether heating water from overproduction makes sense?

"Net billing" is a settlement model that credits exported PV energy financially rather than returning the same energy later, so the grid acts like a short-term store with pricing and timing limits. In the thread, one user says the grid works like a battery with a short holding time, giving an example of accumulating for 50 minutes and using it in the last 10. That changes the economics: if export terms are weak, using surplus for hot water can make more sense than selling low and buying back later. [#21178285]

Tasmota with PZEM-004T vs reading data directly from a Sofar inverter over Modbus or HTML — which approach is better for controlling a water heater?

Reading the inverter directly is better when you want richer and more accurate control, but Tasmota with PZEM is easier to build. The PZEM route needs only cheap hardware and a simple Tasmota rule. The Sofar route can read HTML or, better, Modbus data and expose more signals, including phase voltages and storage status. One contributor said, "The best way is to use Modbus data," because he also reacts to voltage rising above the norm. Choose PZEM for simplicity and inverter data for smarter automation. [#21179148]

How can I read Sofar HYD15KTL-3PH inverter data over Wi-Fi from the logger and send it to MQTT using a Raspberry Pi?

Use the inverter’s Wi‑Fi logger, a Raspberry Pi, and an MQTT broker such as Mosquitto. The thread describes a broker program that talks to the Sofar logger over Wi‑Fi, then publishes inverter status to MQTT every 30 seconds. The same contributor says the current version communicates with the logger over Wi‑Fi and was already used on Raspberry Pi hardware. The author of the main project confirms his HYD15KTL-3PH has a Wi‑Fi logger connected to the app, which makes this path possible without reading power through a PZEM first. [#21180001]

What files, directories, and config settings are needed to run michal.zd's pvInverterBroker and MQTT_LinuxLib on a Raspberry Pi 3B+ with Mosquitto?

You need one library, one broker binary, and one config file. Put the MQTT_LinuxLib binary in /usr/lib. Put the pvInverterBroker binary in /usr/inverter. Create a config directory in /etc/ime and place the broker config there. Then edit logger_sn, logger_addr, logger_port 8899, refresh_time 30, service_port 8898, mqtt_server, mqtt_topic ime/inverter/, and mqtt_binary_topic ime/inverterbin. The post says to monitor ime/inverter/# with mosquitto_sub and expect messages every half minute. [#21180001]

Node-RED vs Domoticz for PV automation and heater control — which is easier and more flexible on Raspberry Pi?

Node-RED is presented as more flexible and ultimately easier for complex PV logic. One contributor says it replaced Domoticz on his Raspberry Pi because Node-RED handled MQTT data, dashboard views, voltage graphs, and JavaScript control logic in one flow-based environment. He reports Node-RED used about 100 MB of RAM and under 5% CPU on his setup. Domoticz still works for simpler use, but the thread’s strongest opinion is that Node-RED is the better fit when you want transparent automation and custom heater rules. [#21179552]

What is a SmartMeter in a PV inverter setup, and what extra measurements does it provide compared with app-only inverter monitoring?

"SmartMeter" is a meter used with a PV inverter that measures grid-side energy exchange and adds import/export visibility that the basic inverter app may not show on its own. In the thread, one Huawei user says his inverter app does not show the same data as another screenshot and that such functions appear only after adding a SmartMeter. That means app-only monitoring may show inverter output, while SmartMeter data can reveal what is actually going to or from the grid. [#21180461]

How should I place measurement points in a single-phase or three-phase installation to detect true overproduction sent to the grid and switch a heater correctly?

Place the main measurement where grid exchange is visible, not only where inverter output is visible. In a single-phase system, put the measurement on the line to the grid so current direction shows export versus import. In a three-phase system, think through all phases carefully, because surplus can appear on one phase while household loads sit on another. One reply also suggests a second measurement point on the heater itself. That arrangement lets the controller see real export and the heater load, instead of reacting to incomplete phase data. [#21180461]

Why do some PZEM modules show spikes like 150 kW or fail after power outages, and what can I do to make measurements more reliable?

Some PZEM units in the thread showed unstable readings and hardware failures, especially around outages. One user reports sudden false values of 150 kW, erratic behavior during power cuts, and 4 failed units out of about 8 after half a year. To improve reliability, verify readings before using them for control, avoid trusting a single noisy sample, and add logic that filters spikes or delays switching. If you need better data quality, the thread points toward inverter-native readings over Modbus instead of relying only on low-cost external measurement. [#21182849]

What Tuya modules can detect current direction for cheaper PV surplus water-heating control, and how do they compare with a DIY ESP8266 plus PZEM setup?

The thread mentions Tuya modules that detect current direction and cost about 70 zł for a single-point version and about 85 zł for a two-point version, with later links showing about 57 zł and 66 zł. Their advantage is simplicity: they already support dependencies and hysteresis. Compared with ESP8266 plus PZEM, Tuya can be cheaper and easier if you already use the Tuya ecosystem. The DIY ESP8266 route stays more open, more hackable, and was estimated at under 100 zł for the full controller. [#21180417]

What exactly counts as 'overproduction' in this kind of PV water-heating project, and from when did contract terms become unfavorable enough that using surplus for hot water became worthwhile?

Overproduction here means PV power that is not consumed locally and is instead sent into the grid. The thread makes that explicit by saying the key value is "the power that goes into the grid" and giving 1500 W as an example threshold for switching a heater on. The discussion does not name a contract start date when terms became unfavorable; it only links the idea to the "new billing rules" and later asks that date as an open question without answering it. So the usable definition is clear, but the timeline is not provided. [#21180446]
Generated by the language model.
ADVERTISEMENT