Skip to content

Commit

Permalink
Merge pull request #254 from grindylow/development03
Browse files Browse the repository at this point in the history
short-term release update due to bugs
  • Loading branch information
aschiffler authored Sep 6, 2022
2 parents 2c1b12e + fcc394c commit 5402e9b
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compile_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
ref: development02
ref: development03
- uses: benjlevesque/short-sha@v1.2
id: short-sha
with:
Expand Down
91 changes: 5 additions & 86 deletions tools/esp8266/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,7 @@
# Changelog

- v0.5.16
* Add alarm messages dictonary in the hminverter class
* show last alarm message in the overview after receiving the message id from the AlarmData command
* Added No-PowerLimit function/setting (thx @lumapu)
* Bug fix #195 trailing and leading spaces in setup parameters (thx @lumapu)
* Added parametric CAD model for a case (thx @cubinet-code)
* Code styling improvements (eg. dynamic creation of html code) (thx @stefan123t, @lumapu)
* Mqtt publish action is now after successful parse a payload, no own ticker
* Fixes/improvements #183, #184, #216, #213, #196, #176, #171
- v0.5.15
* Bug fix: mqtt payload handling (thx @klahus1, silverserver)
* Bug fix: eeprom alignment fixed (thx @klahus1)
* mqtt reconnect improvements (thx @tastendruecker123 , @HorstG-57 )
* simple command scheduler (one place fifo)
* InverterDevInform_All Command parser and output to mqtt
* New workflow to build github release
* Introduction of a command queue (like OpenDTU)
* Feedback from inverter for actual power limit via InfoCmd -> SystemConfigPara (0x05) placed in visualization
* REST API will enqueue a new info command (all commands supported)
* Change in power limit will (Setup, MQTT or REST API) enqueues a new infocmd request to get actual power limit
* Actual power limit is available under MQTT topic <TOPIC>/<INVERTER-NAME>/ch0/PowerLimit ALWAYS in percent
* Firmware information will be requested automatically up on start of dtu
* Added User_Manual.md

- v0.5.14
- v0.5.13
- v0.5.12
- v0.5.11
- v0.5.10
- v0.5.9 *fix PowerLimit PowerPFDev.Desc=0x0001 for permanent
- v0.5.8 *fix #146 device name in setup
- v0.5.7 *add collapsible setup
- v0.5.6 *fix only MQTT sub after the first loop in a conenction
- v0.5.5 *fixed MQTT sub only after connection is established (HorstG-57)
+ added in app.cpp some compiler if statements
*fix: compile possible for non repository versions (if project was download as zip - lumapu)
*fix README.md - Update line 69 (`RF24` 1.4.2 -> 1.4.5) (DanielR92)
*Update hmRadio.h (lumapu)
- v0.5.4 + added Github report text with a URL (aschiffler)
+ added auto_firmware_version.py for GIT_HASH
+ added switch case AlarmData/AlarmUpdate
- v0.5.3 #Bugfix #125 PowerLimit
+ prototype webapi to get info, improved pwr limit (aschiffler)
+ Merge remote-tracking branch 'upstream/main' into pwrlimit
- v0.5.2 add #114 ntp_server_name and port to eeprom
+ stefan123t added some functions (devcontrol/cbMqtt/...)
- v0.5.1 *Merge branch 'upstream/HEAD' into control
*update revision (0.4.26 -> 0.5.1)
- v0.4.26 first poc for power set via mqtt
- v0.4.25 added default SERIAL/MQTT/SEND_INTERVAL #100, fixed env:node_mcu_v2 build #101
- v0.4.24 added fixes for #63, #88, #93. revert #36 (*) EEPROM changes
- v0.4.23 added workflow, fix index.html to load inverter info immediately, changed timestamp to 1 for stand alone ESP #90, Implement MQTT discovery for Home Assistant
- v0.4.22 compiles with PlatformIO
- v0.4.21 reduced warnings
- v0.4.20 improved setup (if no data is in EEprom), improved NRF24 Pinout regarding to #36, Standard Pinout should be now: #36 (comment), add JSON output, fix favicon, improve eeprom default settings (*) EEPROM changes
- v0.4.19 updated debug messages: now 5 different levels are available, fixed CRC loop issue, add fritzing/schematics for Arduino, Raspberry Pi and NodeMCU
- v0.4.18 Creative Commons NC-SA-BY v3.0 license included, tried to increase stability, fix NRF24 CRClength, add debug & documentation links, added variable error messages using #pragma error
- v0.4.17 add printed circuit board layout, more debug output (#retransmits), improved loop counters (*) EEPROM changes
- v0.4.16 request only one inverter per loop (#53 (comment)), mqtt loop interval calculated by # of inverters and inverter request interval, limit maximum number of retries, added feature request #62 (readable names for channels), improved setup page, added javascript to hide / show channel fields (*) EEPROM changes
- v0.4.15 reduced debug messages, fixes after merge
- v0.4.14 added RX channel 40, improved RF24 ISR, reduced AP active time to 60s (will be increase once a client is connected), added `yield` without success -> random reboot (cause 4) (*) EEPROM changes
- v0.4.13 rename to AHOY-DTU, add RX channel 40, update stats on index based on mSendInterval, MQTT Interval, EEPROM CRC settings, fix #56 v0.4.10 ESP8266 stuck in boot loop
- v0.4.12 version skipped ?
- v0.4.11 inverter dependent mqtt (is avail), implemented heap stats #58, inserted 'break' in ISR while loop
- v0.4.10 reduced heap size (>50%) by using 'F()' for (nearly) all static strings, added Wemos D1 case STL files
- v0.4.9 try to fix mqtt and wifi loss issue #52, document libraries (*) EEPROM changes
- v0.4.8 moved mqtt loop out of checkTicker as mentioned in #49, added irritation and efficiency calculations, improved style (*) EEPROM changes
- v0.4.7 version skipped ?
- v0.4.6 version skipped ?
- v0.4.5 fix #38 4-channel inverter current assignment, added last received timestamp in /hoymiles livedata web page #47, improved style.css, improved NTP as described in #46
- v0.4.4 added free heap, mentioned in #24 (added in serial print, status on index and mqtt), fixed #45, AC current by factor 10 too high, fixed failed payload counter
- v0.4.3 fixed #41 HM800 Yield total and Yield day were mixed around. Found issue while comparing to Python version, fixed #43 HM350 channel 2 is displayed in Live-View, added #42 YieldTotal and YieldTotal Day for HM600 - HM800 inverters
- v0.4.2 fix #39 Assignment 2-Channel inverters (HM-600, HM-700, HM-800)
- v0.4.1 multi inverter support, full re transmit included
- v0.4.0 complete payload processed (and crc checked), inverter type is defined by serial number, serial debug can be switched live (using setup), Note: only one inverter is supported for now!
- v0.3.9 fix #26 ticker / interval in app.cpp
- v0.3.8 improved stability (in comparison to 0.3.7), reset wifi AP timout once a client is detected, fix #26 wrong variable reset
- v0.3.7 added rx channel switching, switched to crc8 check for valid packet-payload
- v0.3.6 improved tickers, only one ticker is active, added feature to use the ESP as access point for all the time, added serial features to setup
- v0.3.5 fixed erase settings, fixed behavior if no MQTT IP is set (the system was nearly unusable because of delayed responses), fixed Station / AP WiFi on startup -> more information will be printed to the serial console, added new ticker for serial value dump
- v0.3.4 added config.h for general configuration, added option to compile WiFi SSID + PWD to firmware, added option to configure WiFi access point name and password, added feature to retry connect to station WiFi (configurable timeouts), updated index.html, added option for factory reset, added info about project on index.html, moved "update" and "home" to footer, fixed #23 HM1200 yield day unit, fixed DNS name of ESP after setup (some commits before)
- v0.3.3 converted to "poor-man-ticker" using millis() for uptime, send and mqtt, added inverter overview, added send count to statistics
- v0.3.2 compile of merge, binary published on https://www.mikrocontroller.net/topic/525778?goto=7051413#7051413
- v0.3.1 fix: doCalculations was not called
- v0.3.0 version 0.3.0, added unit test
(*) EEPROM changes require settings to be changed, your settings will be overwritten and need to be set again!
- v0.5.17
* Bug fix for 1 channel inverters (HM300, HM400) see #246
* Bug fix for read back the active power limit from inverter #243 (before version 0.5.16 the reported limit was just a copy of the user set point, now it is the actual value which the inverter uses)
* Update the [user manual](https://github.com/grindylow/ahoy/blob/main/tools/esp8266/User_Manual.md); added section aobut the published data on mqtt; section about zero export control; added section about code implementation command queue
* Added tx-Id number to packet payload struct. (eg. can be 0x95 or 0xD1) --> less messages fails and faster handling of changing power limit
68 changes: 67 additions & 1 deletion tools/esp8266/User_Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,42 @@ In the initial case or after click "erase settings" the fields for the inverter

Set at least the serial number and a name for each inverter, check the "reboot after save" and click the "Save" button.

## MQTT Output
The ahoy dtu will publish on the following topics
``<CHOOSEN_TOPIC_FROM_SETUP>/<INVERTER_NAME_FROM_SETUP>/ch0/#``
| Topic | Example Value | Remarks |
|---|---|---|
|U_AC | 233.300|actual AC Voltage in Volt|
|I_AC | 0.300 | actual AC Current in Ampere|
|P_AC | 71.000| actual AC Power in Watt|
|P_ACr | 21.200| actual AC reactive power in VAr|
|Freq | 49.990|actual AC Frequency in 1/s|
|Pct | 95.800|actual AC Power factor in %|
|Temp | 19.800|Temperature of inverter in Celsius|
|LARM_MES_ID | 9.000|Last Alarm Message Id|
|YieldDay | 51.000|Energy converted to AC per day in Watt hours (measured on DC)|
|YieldTotal | 465.294|Energy converted to AC since reset Watt hours (measured on DC)|
|P_DC | 74.600|actual DC Power in Watt|
|Efficiency | 95.174|actual ration AC Power over DC Power in percent|
|FWVersion | 10012.000| Firmware version eg. 1.00.12|
|FWBuildYear | 2020.000| Firmware build date|
|FWBuildMonthDay | 624.000| Firmware build month and day eg. 24th of june|
|HWPartId | 100.000| Hardware Id|
|PowerLimit | 80.000|actual set point for power limit control AC active power in percent|
|LastAlarmCode | 1.000| Last Alarm Code eg. "inverter start"|

``<CHOOSEN_TOPIC_FROM_SETUP>/<INVERTER_NAME_FROM_SETUP>/ch<CHANNEL_NUMBER>/#``

``<CHANNEL_NUMBER>`` is in the range 1 to 4 depending on the inverter type
| Topic | Example Value | Remarks |
|---|---|---|
|U_DC | 38.900| actual DC Voltage in Volt|
|I_DC | 0.640 | actual DC current in Ampere|
|P_DC | 25.000 | actual DC power in Watt|
|YieldDay | 17.000 | Energy converted to AC per day Watt hours per module/channel (measured on DC) |
|YieldTotal | 110.819 | Energy converted to AC since reset Watt hours per module/channel (measured on DC) |
|Irradiation |5.65 | ratio DC Power over set maximum power per module/channel in percent |

## Active Power Limit via Setup Page
If you leave the field "Active Power Limit" empty during the setup and reboot the ahoy-dtu will set a value of 65535 in the setup.
That is the value you have to fill in case you want to operate the inverter without a active power limit.
Expand Down Expand Up @@ -39,6 +75,12 @@ To set the active power limit (controled value is the AC Power of the inverter)
| <CHOOSEN_TOPIC_FROM_SETUP>/devcontrol/<INVERTER_ID>/11/1 | [2...100] | % | not persistent
| <CHOOSEN_TOPIC_FROM_SETUP>/devcontrol/<INVERTER_ID>/11/257 | [2...100] | % | persistent

👆 ``<INVERTER_ID>`` is the number of the specific inverter in the setup page.

* First inverter --> ``<INVERTER_ID>`` = 0
* Second inverter --> ``<INVERTER_ID>`` = 1
* ...

### Developer Information MQTT Interface
``<CHOOSEN_TOPIC_FROM_SETUP>/devcontrol/<INVERTER_ID>/<DevControlCmdType>/<DATA2>``

Expand Down Expand Up @@ -143,6 +185,10 @@ In the same approach as for MQTT any other SubCmd and also MainCmd can be applie
}
```

## Zero Export Control
* You can use the mqtt topic ``<CHOOSEN_TOPIC_FROM_SETUP>/devcontrol/<INVERTER_ID>/11`` with a number as payload (eg. 300 -> 300 Watt) to set the power limit to the published number in Watt. (In regular cases the inverter will use the new set point within one intervall period; to verify this see next bullet)
* You can check the inverter set point for the power limit control on the topic ``<CHOOSEN_TOPIC_FROM_SETUP>/<INVERTER_NAME_FROM_SETUP>/ch0/PowerLimit`` 👆 This value is ALWAYS in percent of the maximum power limit of the inverter. In regular cases this value will be updated within approx. 15 seconds. (depends on request intervall)
* You can monitor the actual AC power by subscribing to the topic ``<CHOOSEN_TOPIC_FROM_SETUP>/<INVERTER_NAME_FROM_SETUP>/ch0/P_AC`` 👆 This value is ALWAYS in Watt

## Issues and Debuging for active power limit settings
Turn on the serial debugging in the setup. Try to have find out if the behavior is deterministic. That means can you reproduce the behavior. Be patient and wait on inverter reactions at least some minutes and beware that the DC-Power is sufficient.
Expand All @@ -154,7 +200,9 @@ In case of issues please report:


**Developer Information General for Active Power Limit**
⚡Was verified by field tests and feedback from three users

⚡The following was verified by field tests and feedback from users

Internally this values will be set for the second two bytes for MainCmd: 0x51 SubCmd: 0x0b --> DevControl set ActivePowerLimit
```C
typedef enum {
Expand All @@ -180,3 +228,21 @@ Gather user inverter information here to understand what differs between some in
| tfhcm | TSUN-350 | | 1.0.14 | 2021 | 12-09 | 102 | | |
| Groobi | TSOL-M400 | | 1.0.14 | 2021 | 12-09 | 102 | | |
| setje | HM-600 | | 1.0.08 | 2020 | 07-10 | 104 | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |

## Developer Information about Command Queue
After reboot or startup the ahoy firmware it will enque three commands in the following sequence:
1. Get active power limit in percent ( ```SystemConfigPara = 5 // 0x05```)
2. Get firmware version (```InverterDevInform_All = 1 // 0x01```)
3. Get data (```RealTimeRunData_Debug = 11 // 0x0b```)

With the command get data (```RealTimeRunData_Debug = 11 // 0x0b```) the alarm message counter will be updated. In the initial case then aonther command is queued to get the alarm code (``` AlarmData = 17 // 0x11```).

This command (``` AlarmData = 17 // 0x11```) will enqued in any operation phase if alarm message counter is raised by one or greater compared to the last request with command get data (```RealTimeRunData_Debug = 11 // 0x0b```)

In case all commands are processed (```_commandQueue.empty() == true```) then as a default command the get data (```RealTimeRunData_Debug = 11 // 0x0b```) will be enqueued.

In case a Device Control command (Power Limit, Off, On) is requested via MQTT or REST API this request will be send before any other enqueued command.
In case of a accepted change in power limit the command get active power limit in percent ( ```SystemConfigPara = 5 // 0x05```) will be enqueued. The acceptance is checked by the reponse packets on the devive control commands (tx id 0x51 --> rx id 0xD1) if in byte 12 the requested sub-command (eg. power limit) is present.
9 changes: 8 additions & 1 deletion tools/esp8266/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void app::loop(void) {
if(0 != len) {
Inverter<> *iv = mSys->findInverter(&p->packet[1]);
if(NULL != iv && p->packet[0] == (TX_REQ_INFO + 0x80)) { // response from get information command
mPayload[iv->id].txId = p->packet[0];
DPRINTLN(DBG_DEBUG, F("Response from info request received"));
uint8_t *pid = &p->packet[9];
if (*pid == 0x00)
Expand All @@ -115,6 +116,7 @@ void app::loop(void) {
}
}
if(NULL != iv && p->packet[0] == (TX_REQ_DEVCONTROL + 0x80)) { // response from dev control command
mPayload[iv->id].txId = p->packet[0];
DPRINTLN(DBG_DEBUG, F("Response from devcontrol request received"));
iv->devControlRequest = false;
switch (p->packet[12]) {
Expand Down Expand Up @@ -248,6 +250,7 @@ void app::loop(void) {
if(mConfig.serialDebug)
DPRINTLN(DBG_INFO, F("Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0]));
mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd ,iv->powerLimit);
iv->clearCmdQueue();
iv->enqueCommand<InfoCommand>(SystemConfigPara);
} else {
mSys->Radio.sendTimePacket(iv->radioId.u64,iv->getQueuedCmd(), mPayload[iv->id].ts,iv->alarmMesIndex);
Expand Down Expand Up @@ -306,7 +309,11 @@ void app::processPayload(bool retransmit) {
for(uint8_t id = 0; id < mSys->getNumInverters(); id++) {
Inverter<> *iv = mSys->getInverterByPos(id);
if(NULL != iv) {
if(!mPayload[iv->id].complete) {
if(mPayload[iv->id].txId != (TX_REQ_INFO + 0x80)) {
// no processing needed if txId is not 0x95
mPayload[iv->id].complete = true;
}
if(!mPayload[iv->id].complete ) {
if(!buildPayload(iv->id)) {
if(mPayload[iv->id].requested) {
if(retransmit) {
Expand Down
1 change: 1 addition & 0 deletions tools/esp8266/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const char* const pinArgNames[] = {"pinCs", "pinCe", "pinIrq"};


typedef struct {
uint8_t txId;
uint8_t invId;
uint32_t ts;
uint8_t data[MAX_PAYLOAD_ENTRIES][MAX_RF_PAYLOAD_SIZE];
Expand Down
19 changes: 14 additions & 5 deletions tools/esp8266/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__

// fallback WiFi info

//-------------------------------------
// WIFI CONFIGURATION
//-------------------------------------

// Fallback WiFi Info
#define FB_WIFI_SSID "YOUR_WIFI_SSID"
#define FB_WIFI_PWD "YOUR_WIFI_PWD"


// access point info
// Access Point Info
// In case there is no WiFi Network or Ahoy can not connect to it, it will act as an Access Point

#define WIFI_AP_SSID "AHOY-DTU"
#define WIFI_AP_PWD "esp_8266"
// stay in access point mode all the time

// If the next line is uncommented, Ahoy will stay in access point mode all the time
//#define AP_ONLY


//-------------------------------------
// CONFIGURATION - COMPILE TIME
//-------------------------------------

// time in seconds how long the station info (ssid + pwd) will be tried
#define WIFI_TRY_CONNECT_TIME 30

Expand All @@ -31,7 +40,7 @@
// default device name
#define DEF_DEVICE_NAME "AHOY-DTU"

// default pinout
// default pinout (GPIO Number)
#define DEF_RF24_CS_PIN 15
#define DEF_RF24_CE_PIN 2
#define DEF_RF24_IRQ_PIN 0
Expand Down Expand Up @@ -76,7 +85,7 @@
#define DEF_NTP_SERVER_NAME "pool.ntp.org"

// default NTP server port
#define DEF_NTP_PORT 8888
#define DEF_NTP_PORT 123

// NTP refresh interval in ms (default 12h)
#define NTP_REFRESH_INTERVAL 12 * 3600 * 1000
Expand Down
2 changes: 1 addition & 1 deletion tools/esp8266/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 5
#define VERSION_PATCH 16
#define VERSION_PATCH 17


//-------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion tools/esp8266/hmDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ const byteAssign_t hm1chAssignment[] = {
{ FLD_PRA, UNIT_VA, CH0, 20, 2, 10 },
{ FLD_F, UNIT_HZ, CH0, 16, 2, 100 },
{ FLD_T, UNIT_C, CH0, 26, 2, 10 },
{ FLD_ALARM_MES_ID, UNIT_NONE, CH0, 28, 2, 1 },
{ FLD_ALARM_MES_ID, UNIT_NONE, CH0, 24, 2, 1 },
{ FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC },
{ FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC },
{ FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC },
{ FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC }
};
Expand Down
Loading

0 comments on commit 5402e9b

Please sign in to comment.