Close
0%
0%

PV Energy Management

ESP32 Socket Switch Control.. Needs only the ESP32.. Reads Battery Voltage from PV, switching WLAN Power Sockets on configuration conditions

Similar projects worth following
The Project controls Power Sockets, depends on Web-Based Configuration Menu.

At first the Control System gets the Battery Voltage (or Wattage) accessed as Modbus data located in CerboGX PV Control. (Victron Energy)

So as Example, you have a Infrared Heater (500W) in Every Room, A Battery Charger System and a Water Heater. Every Device is using a Simple HTTP Request Based Wlan Power Socket.

You can create different Scenes, depencys, Voltages and Scheduling to switch automatically on or off on Empty Battery, Good Conditions, sinking Battery Voltage or to Switch a Charger as System Backup.

You can create different Rules on Name and URL/IP

1. Min Voltage, Max Voltage as Hysterese, (invert for Charger)
2. delon/deloff : Delay On and Off in Minutes before Fire this Event.
3. depon/depoff: Condition On,Off as id pointing to other Device Entry
4. Times Between to Fire the Event OnOff (or Not Between offon)

Overall Details.

Normally you have an off-grid system that can, if necessary, be powered by a battery charger from the power grid. If there is less sun in the winter transition periods, the battery voltage drops due to discharging during the shade periods. 

 For example, you can store an entry in the configuration as follows.

 An inverted hysteresis 23v-27v, which means switching the charger on at 23v and switching it off again at 27v. best during the bright times of the day. 

A hysteresis of 24V to 27V can be set for one consumer, the same for the next consumer, but with the first consumer being ON and a delay of 10 minutes. The result is a gentle cascade.


1. this Source Code uses "Fritz Smart Home" Api. (DECT Switched Sockets, managed in Fritzbox Webinterface) Change a few Lines to Switch Tasmota Sockets or other HTTP Request based WLAN Sockets.

1.1 Login Credentials, Session Handling and Switchon/Off using Library "ArduinoFritzApi"

2. TCP Modbus Request IP, UnitID 100, Holding Register 840 (Battery System Voltage)

2.1 Used Library "esp32ModbusTCP"

3. Webinterface,  Simple Configuration Management using "Json-Form". Json-Form is a Javascript Formular Engine. Json Document->Formular View in Browser->Formular Post->Json-Document parsed in and out by Arduino-json in ESP32.

3.1 Used Librarys:  ArduinoJson.h, JSON-Form

4. Easy Webserver managed by ESPAsyncWebServer Library to post and get Ajax Calls in ESP32.

  • 1 × 1x ESP32 WROOM

  • Status Database

    Schupp03/20/2024 at 12:22 0 comments

    Ongoing Submodule, save every Switch-Action to a Database and create a Timeline to Check if all works okay.

    Later maybe onboard as Rolling Buffer and live Notifications to Main Browser Menu. 

  • Updated Github Code

    Schupp03/09/2024 at 19:22 0 comments

    change all Variables to English for better understanding.

View all 2 project logs

  • 1
    Hardcoded Settings in main.cpp / Installation

    On first the Code Checks if Settings Uploaded as config.json in Spiffs Image, then starts first as Access Point (Captive Portal) to set these Settings if Settings not available at Boot.

    Other Hand there are Five Settings they are hardcoded:

    NTP Server Settings:

    const char TIME_ZONE[] = "MEZ-1MESZ-2,M3.5.0/02:00:00,M10.5.0/03:00:00";
    const char NTP_SERVER_POOL[] = "192.168.178.1";

    Modbus Configuration, IP,Port,Unit:

    esp32ModbusTCP cerbogx(100, { 192, 168, 178, 68 }, 502); 

     Holding Register and Register Format:

    modbusData modbusRegisters[] = {    "batteryvoltage", 840, 1, UFIX0, 0, 100 // Voltage
    };

    Socket HTTP Request Parsing, change for another WLAN Power Socket Api:

    int switchon(String ain);
    int switchoff(String ain)

    MDNS Hostname, change for your local Network

     MDNS.begin("switcher.fritz.box");

    Other settings and Sync Times on NTP and other Delays are also Hardcoded at this time.

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates