GridFree SUN-2000G (#926)
* Support for GridFree Sun-2000G inverter * Bump version of GFSunInverter Co-authored-by: Martin Korbel <korbel@blackserver.cz>
This commit is contained in:
1 parent
e7b964ef5b
commit
23cd2a3104
5 files changed
+168
No files matched your search
@@ -193,6 +193,7 @@ int lowpowermode = DEFAULT_LOW_POWER_MODE;
|
|||||||
//#define ZgatewayLORA "LORA" //ESP8266, Arduino, ESP32
|
//#define ZgatewayLORA "LORA" //ESP8266, Arduino, ESP32
|
||||||
//#define ZgatewayPilight "Pilight" //ESP8266, Arduino, ESP32
|
//#define ZgatewayPilight "Pilight" //ESP8266, Arduino, ESP32
|
||||||
//#define ZgatewayWeatherStation "WeatherStation" //ESP8266, Arduino, ESP32
|
//#define ZgatewayWeatherStation "WeatherStation" //ESP8266, Arduino, ESP32
|
||||||
|
//#define ZgatewayGFSunInverter "GFSunInverter" //ESP32
|
||||||
//#define ZgatewayBT "BT" //ESP8266, ESP32
|
//#define ZgatewayBT "BT" //ESP8266, ESP32
|
||||||
//#define ZgatewayRF2 "RF2" //ESP8266, Arduino, ESP32
|
//#define ZgatewayRF2 "RF2" //ESP8266, Arduino, ESP32
|
||||||
//#define ZgatewaySRFB "SRFB" // Sonoff RF Bridge
|
//#define ZgatewaySRFB "SRFB" // Sonoff RF Bridge
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
OpenMQTTGateway - ESP8266 or Arduino program for home automation
|
||||||
|
|
||||||
|
Act as a wifi or ethernet gateway between your GridFree SUN-2000G inverter and a MQTT broker.
|
||||||
|
Send inverter metrics by MQTT.
|
||||||
|
|
||||||
|
This gateway enables to:
|
||||||
|
- publish MQTT data, which are received by RS232 ModBus.
|
||||||
|
|
||||||
|
Library for read metrics from GWL Power, GridFree SUN-2000G inverter <https://shop.gwl.eu/GridFree-Inverters/GridFree-AC-Inverter-with-limiter-2kW-SUN-2000G-45-90V.html>.
|
||||||
|
|
||||||
|
This file is part of OpenMQTTGateway.
|
||||||
|
|
||||||
|
OpenMQTTGateway is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenMQTTGateway is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "User_config.h"
|
||||||
|
|
||||||
|
#ifdef ZgatewayGFSunInverter
|
||||||
|
|
||||||
|
GfSun2000 GF = GfSun2000();
|
||||||
|
|
||||||
|
void GFSunInverterDataHandler(GfSun2000Data data) {
|
||||||
|
StaticJsonBuffer<2 * JSON_MSG_BUFFER> jsonBuffer;
|
||||||
|
JsonObject& jdata = jsonBuffer.createObject();
|
||||||
|
|
||||||
|
jdata.set("device_id", (char*)data.deviceID);
|
||||||
|
Log.trace(F("Device ID : %s\n" CR), data.deviceID);
|
||||||
|
jdata.set("ac_voltage", data.ACVoltage);
|
||||||
|
Log.trace(F("AC Voltage : %.1f\tV\n" CR), data.ACVoltage);
|
||||||
|
jdata.set("dc_voltage", data.DCVoltage);
|
||||||
|
Log.trace(F("DC Voltage : %.1f\tV\n" CR), data.DCVoltage);
|
||||||
|
jdata.set("power", data.averagePower);
|
||||||
|
Log.trace(F("Output Power : %.1f\tW (5min avg)\n" CR), data.averagePower);
|
||||||
|
jdata.set("c_energy", data.customEnergyCounter);
|
||||||
|
Log.trace(F("Custom Energy : %.1f\tkW/h (can be reseted)\n" CR), data.customEnergyCounter);
|
||||||
|
jdata.set("t_energy", data.totalEnergyCounter);
|
||||||
|
Log.trace(F("Total Energy : %.1f\tkW/h\n" CR), data.totalEnergyCounter);
|
||||||
|
|
||||||
|
# ifdef GFSUNINVERTER_DEVEL
|
||||||
|
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer2;
|
||||||
|
JsonObject& jregister = jsonBuffer2.createObject();
|
||||||
|
char buffer[4];
|
||||||
|
std::map<int16_t, int16_t>::iterator itr;
|
||||||
|
for (itr = data.modbusRegistry.begin(); itr != data.modbusRegistry.end(); ++itr) {
|
||||||
|
Log.notice("%d: %d\n", itr->first, itr->second);
|
||||||
|
sprintf(buffer, "%d", itr->first);
|
||||||
|
jregister.set(buffer, itr->second);
|
||||||
|
}
|
||||||
|
jdata.set("register", jregister);
|
||||||
|
# endif
|
||||||
|
pub(subjectRFtoMQTT, jdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GFSunInverterErrorHandler(int errorId, char* errorMessage) {
|
||||||
|
char buffer[50];
|
||||||
|
sprintf(buffer, "Error response: %02X - %s\n", errorId, errorMessage);
|
||||||
|
Log.error(buffer);
|
||||||
|
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
|
||||||
|
JsonObject& jdata = jsonBuffer.createObject();
|
||||||
|
jdata.set("status", "error");
|
||||||
|
jdata.set("msg", errorMessage);
|
||||||
|
jdata.set("id", errorId);
|
||||||
|
pub(subjectRFtoMQTT, jdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupGFSunInverter() {
|
||||||
|
GF.setup(Serial2);
|
||||||
|
GF.setDataHandler(GFSunInverterDataHandler);
|
||||||
|
GF.setErrorHandler(GFSunInverterErrorHandler);
|
||||||
|
Log.trace(F("ZgatewayGFSunInverter setup done " CR));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZgatewayGFSunInverterMQTT() {
|
||||||
|
GF.readData();
|
||||||
|
delay(GFSUNINVERTER_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
OpenMQTTGateway - ESP8266 or Arduino program for home automation
|
||||||
|
|
||||||
|
Act as a wifi or ethernet gateway between your GridFree SUN-2000G inverter and a MQTT broker.
|
||||||
|
Send inverter metrics by MQTT.
|
||||||
|
|
||||||
|
This gateway enables to:
|
||||||
|
- publish MQTT data, which are received by RS232 ModBus.
|
||||||
|
|
||||||
|
Library for read metrics from GWL Power, GridFree SUN-2000G inverter <https://shop.gwl.eu/GridFree-Inverters/GridFree-AC-Inverter-with-limiter-2kW-SUN-2000G-45-90V.html>.
|
||||||
|
|
||||||
|
This file is part of OpenMQTTGateway.
|
||||||
|
|
||||||
|
OpenMQTTGateway is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenMQTTGateway is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef config_GFSunInverter_h
|
||||||
|
#define config_GFSunInverter_h
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
#include <GfSun2000.h>
|
||||||
|
|
||||||
|
extern void setupGFSunInverter();
|
||||||
|
extern void ZgatewayGFSunInverterMQTT();
|
||||||
|
|
||||||
|
/*----------------------------USER PARAMETERS-----------------------------*/
|
||||||
|
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
|
||||||
|
#define subjectRFtoMQTT "/GFSuntoMQTT"
|
||||||
|
#ifndef GFSUNINVERTER_DELAY
|
||||||
|
# define GFSUNINVERTER_DELAY 10000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Enable to publish a whole dbus registry
|
||||||
|
// #define GFSUNINVERTER_DEVEL 1
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -56,6 +56,13 @@ unsigned long timer_sys_measures = 0;
|
|||||||
StaticJsonBuffer<JSON_MSG_BUFFER> modulesBuffer;
|
StaticJsonBuffer<JSON_MSG_BUFFER> modulesBuffer;
|
||||||
JsonArray& modules = modulesBuffer.createArray();
|
JsonArray& modules = modulesBuffer.createArray();
|
||||||
|
|
||||||
|
#ifndef ZgatewayGFSunInverter
|
||||||
|
// Arduino IDE compiles, it automatically creates all the header declarations for all the functions you have in your *.ino file.
|
||||||
|
// Unfortunately it ignores #if directives.
|
||||||
|
// This is a simple workaround for this problem.
|
||||||
|
struct GfSun2000Data {};
|
||||||
|
#endif
|
||||||
|
|
||||||
// Modules config inclusion
|
// Modules config inclusion
|
||||||
#if defined(ZgatewayRF) || defined(ZgatewayRF2) || defined(ZgatewayPilight) || defined(ZactuatorSomfy) || defined(ZgatewayRTL_433)
|
#if defined(ZgatewayRF) || defined(ZgatewayRF2) || defined(ZgatewayPilight) || defined(ZactuatorSomfy) || defined(ZgatewayRTL_433)
|
||||||
# include "config_RF.h"
|
# include "config_RF.h"
|
||||||
@@ -63,6 +70,9 @@ JsonArray& modules = modulesBuffer.createArray();
|
|||||||
#ifdef ZgatewayWeatherStation
|
#ifdef ZgatewayWeatherStation
|
||||||
# include "config_WeatherStation.h"
|
# include "config_WeatherStation.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ZgatewayGFSunInverter
|
||||||
|
# include "config_GFSunInverter.h"
|
||||||
|
#endif
|
||||||
#ifdef ZgatewayLORA
|
#ifdef ZgatewayLORA
|
||||||
# include "config_LORA.h"
|
# include "config_LORA.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -653,6 +663,10 @@ void setup() {
|
|||||||
setupWeatherStation();
|
setupWeatherStation();
|
||||||
modules.add(ZgatewayWeatherStation);
|
modules.add(ZgatewayWeatherStation);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ZgatewayGFSunInverter
|
||||||
|
setupGFSunInverter();
|
||||||
|
modules.add(ZgatewayGFSunInverter);
|
||||||
|
#endif
|
||||||
#ifdef ZgatewaySRFB
|
#ifdef ZgatewaySRFB
|
||||||
setupSRFB();
|
setupSRFB();
|
||||||
modules.add(ZgatewaySRFB);
|
modules.add(ZgatewaySRFB);
|
||||||
@@ -1253,6 +1267,9 @@ void loop() {
|
|||||||
#ifdef ZgatewayWeatherStation
|
#ifdef ZgatewayWeatherStation
|
||||||
ZgatewayWeatherStationtoMQTT();
|
ZgatewayWeatherStationtoMQTT();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ZgatewayGFSunInverter
|
||||||
|
ZgatewayGFSunInverterMQTT();
|
||||||
|
#endif
|
||||||
#ifdef ZgatewayPilight
|
#ifdef ZgatewayPilight
|
||||||
PilighttoMQTT();
|
PilighttoMQTT();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ extra_configs =
|
|||||||
;default_envs = esp32dev-somfy-cc1101
|
;default_envs = esp32dev-somfy-cc1101
|
||||||
;default_envs = esp32dev-pilight-somfy-cc1101
|
;default_envs = esp32dev-pilight-somfy-cc1101
|
||||||
;default_envs = esp32dev-weatherstation
|
;default_envs = esp32dev-weatherstation
|
||||||
|
;default_envs = esp32dev-gf-sun-inverter
|
||||||
;default_envs = esp32dev-ir
|
;default_envs = esp32dev-ir
|
||||||
;default_envs = esp32dev-ble
|
;default_envs = esp32dev-ble
|
||||||
;default_envs = esp32dev-ble-cont
|
;default_envs = esp32dev-ble-cont
|
||||||
@@ -120,6 +121,8 @@ stl = https://github.com/mike-matera/ArduinoSTL.git#7411816
|
|||||||
shtc3 = https://github.com/sparkfun/SparkFun_SHTC3_Arduino_Library
|
shtc3 = https://github.com/sparkfun/SparkFun_SHTC3_Arduino_Library
|
||||||
somfy_remote=Somfy_Remote_Lib@0.2.0
|
somfy_remote=Somfy_Remote_Lib@0.2.0
|
||||||
rtl_433_ESP = https://github.com/NorthernMan54/rtl_433_ESP#38ee89a
|
rtl_433_ESP = https://github.com/NorthernMan54/rtl_433_ESP#38ee89a
|
||||||
|
emodbus = miq19/eModbus@1.0.0
|
||||||
|
gfSunInverter = https://github.com/BlackSmith/GFSunInverter.git#v1.0.1
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
framework = arduino
|
framework = arduino
|
||||||
@@ -314,6 +317,18 @@ build_flags =
|
|||||||
'-DZgatewayWeatherStation="WeatherStation"'
|
'-DZgatewayWeatherStation="WeatherStation"'
|
||||||
'-DGateway_Name="OpenMQTTGateway_ESP32_WeatherStation"'
|
'-DGateway_Name="OpenMQTTGateway_ESP32_WeatherStation"'
|
||||||
|
|
||||||
|
[env:esp32dev-gf-sun-inverter]
|
||||||
|
platform = ${com.esp32_platform}
|
||||||
|
board = esp32dev
|
||||||
|
lib_deps =
|
||||||
|
${com-esp.lib_deps}
|
||||||
|
${libraries.emodbus}
|
||||||
|
${libraries.gfSunInverter}
|
||||||
|
build_flags =
|
||||||
|
${com-esp.build_flags}
|
||||||
|
'-DZgatewayGFSunInverter="GFSunInverter"'
|
||||||
|
'-DGateway_Name="OpenMQTTGateway_ESP32_GFSunInverter"'
|
||||||
|
|
||||||
[env:esp32dev-ir]
|
[env:esp32dev-ir]
|
||||||
platform = ${com.esp32_platform}
|
platform = ${com.esp32_platform}
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
|
|||||||
Reference in new issue
Block a user