Skip to content

Coturex/Wifi_Mqtt_SolarBalancer

Repository files navigation

Python Solar Energy Balancer

The aim is to allocate solar energy production on multiple equipments (resistive load) in order to improve grid resiliency and reduce homeowner electric bills. Equipments priority should be managed. Communication through Wifi/Mqtt.

Thanks a lot to Pierre

Here is a Pierre's forked version.

Let update/improve this code to your needs...

archi

Hardware requirements :

  • At least 2 Wifi MQTT Energy Smartmeter modules
    • Here a third Pzem Smartmeter is used, connected to the WaterHeater in order to improve Grafana charts and to detect Over Load when the thermostat goes to off/on.
  • n Wifi MQTT Energy Variator module(s)
  • n Wifi MQTT Energy Commutator (like Sonoff Relay etc...)
  • 1 Raspberry Pi Zero 2 / Pi3 / Pi4 (which host this python program and Mosquito Mqtt broker)

Installation :

By installing 2 Wifi MQTT Energy Smartmeter in your solar system, and clamping the first PZEM toroid onto main house loads and the second PZEM toroid onto solar inverter, you can monitor "Grid Consumption Energy" (the energy consumed from the grid), " Solar Production Energy" (the energy producted by solar panels), and "Exported Energy" (the calculated energy exported to the grid)

→ Installation

→ Compteur

You can monitor the energy flow of the solar system, as following ;

→ Grafana

Above, Grafana screenshot. (here EDF is the Grid Consumtion Energy)

→ Domoticz

Above, Domoticz screenshot (from domoticz's page called 'Floorplans')

Python requirements :

  • python 3
  • paho-mqtt : $> pip3 install paho-mqtt

Features - Addons

Pierre vs Coturex

  • At startup it Calculate 'Polynomial Regression' Vector' depending on Power Variator technology and differents calibrations/equipment directly from CSV calibration files -> implemented in VariablePowerEquipment subclass
  • Do calibration through Mqtt (instead of pzem hardware attachment)
  • Read 'Config file' at startup (all parameters/settings are located in this file)
  • Dynamic load of equipments (rules in 'Config file')
  • Save/Load 'status of equipments' while restarting the program (and every xx seconds cf. 'status_time' in Config file)
  • Cloud forecast, using OpenWeatherMap (https://openweathermap.org/)
  • 'Water heater fallback' if not enough dayly or 2days solar energy : Seasons consideration

Todo - ideas :


My topic mapping :

Python Regulation

  - regul/mode/{(un)forced mode.json}
  
  - regul/status/{evaluate status.json}   

Wifi_MQTT_Energy_Smartmeter : (pzem_topic = smeter/pzem)

<pzem_topic>/<pzem_id>/

  - smeter/pzem/{boot.json}

  - smeter/pzem/id_0/{pzem.json}

  - smeter/pzem/id_n/{pzem.json}

Wifi_MQTT_Power_Variator : (vload_topic = regul/vload)

<vload_topic>/<vload_id>/

  - regul/vload/{boot.json}
 
  - regul/vload/id_0/{percent power}

  - regul/vload/id_n/{percent power}
  
  ...

Constant Power Equipment : (cload_topic = regul/cload)

<kload_topic>/<kload_id>/

  ...

Domoticz link (then influxDb, Grafana) : (and Constant Power Equipment too)

  - domoticz/in/{json} 
  - domoticz/out/{json} 

About

Python Solar Energy Balancer. This is an Mqtt PvRouter

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors