Change ADE7953 energy update code and add debug information

Change ADE7953 energy update code and add debug information (#5968)
This commit is contained in:
Theo Arends 2019-06-21 14:31:08 +02:00
parent 46210bc9f0
commit bcaafd7413
3 changed files with 12 additions and 7 deletions

View File

@ -265,8 +265,8 @@
// -- MQTT - TLS - AWS IoT ------------------------ // -- MQTT - TLS - AWS IoT ------------------------
// Using TLS starting with version v6.5.0.16 compilation will only work using Core 2.4.2 and 2.5.2. No longer supported: 2.3.0 // Using TLS starting with version v6.5.0.16 compilation will only work using Core 2.4.2 and 2.5.2. No longer supported: 2.3.0
//#define USE_MQTT_TLS // Use TLS for MQTT connection (+34.5k code, +7.0k mem and +4.8k additional during connection handshake) //#define USE_MQTT_TLS // Use TLS for MQTT connection (+34.5k code, +7.0k mem and +4.8k additional during connection handshake)
//#define USE_MQTT_TLS_CA_CERT // Force full CA validation instead of fingerprints, slower, but simpler to use (+2.2k code, +1.9k mem during connection handshake) // #define USE_MQTT_TLS_CA_CERT // Force full CA validation instead of fingerprints, slower, but simpler to use (+2.2k code, +1.9k mem during connection handshake)
//#define USE_MQTT_AWS_IOT // Enable MQTT for AWS IoT - requires a private key (+11.4k code, +0.4k mem) // #define USE_MQTT_AWS_IOT // Enable MQTT for AWS IoT - requires a private key (+11.4k code, +0.4k mem)
// Note: you need to generate a private key + certificate per device and update 'sonoff/sonoff_aws_iot.cpp' // Note: you need to generate a private key + certificate per device and update 'sonoff/sonoff_aws_iot.cpp'
// Full documentation here: https://github.com/arendst/Sonoff-Tasmota/wiki/AWS-IoT // Full documentation here: https://github.com/arendst/Sonoff-Tasmota/wiki/AWS-IoT

View File

@ -96,6 +96,7 @@ uint8_t ButtonSerial(uint8_t serial_in_byte)
* SetOption11 (0) - If set perform single press action on double press and reverse * SetOption11 (0) - If set perform single press action on double press and reverse
* SetOption13 (0) - If set act on single press only * SetOption13 (0) - If set act on single press only
* SetOption32 (40) - Max button hold time in Seconds * SetOption32 (40) - Max button hold time in Seconds
* SetOption40 (0) - Number of 0.1 seconds until hold is discarded if SetOption1 1 and SetOption13 0
\*********************************************************************************************/ \*********************************************************************************************/
void ButtonHandler(void) void ButtonHandler(void)
@ -198,6 +199,7 @@ void ButtonHandler(void)
if (holdbutton[button_index] > loops_per_second * Settings.param[P_HOLD_IGNORE] / 10) { if (holdbutton[button_index] > loops_per_second * Settings.param[P_HOLD_IGNORE] / 10) {
holdbutton[button_index] = 0; // Reset button hold counter to stay below hold trigger holdbutton[button_index] = 0; // Reset button hold counter to stay below hold trigger
multipress[button_index] = 0; // Discard button press to disable functionality multipress[button_index] = 0; // Discard button press to disable functionality
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d cancel by " D_CMND_SETOPTION "40 %d"), button_index +1, Settings.param[P_HOLD_IGNORE]);
} }
} }
if (holdbutton[button_index] == loops_per_second * Settings.param[P_HOLD_TIME] / 10) { // SetOption32 (40) - Button hold if (holdbutton[button_index] == loops_per_second * Settings.param[P_HOLD_TIME] / 10) { // SetOption32 (40) - Button hold

View File

@ -126,6 +126,9 @@ void Ade7953GetData(void)
ade7953_current_rms = ade7953_current_rms1 + ade7953_current_rms2; ade7953_current_rms = ade7953_current_rms1 + ade7953_current_rms2;
ade7953_active_power = ade7953_active_power1 + ade7953_active_power2; ade7953_active_power = ade7953_active_power1 + ade7953_active_power2;
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ADE: U %d, I %d + %d = %d, P %d + %d = %d"),
ade7953_voltage_rms, ade7953_current_rms1, ade7953_current_rms2, ade7953_current_rms, ade7953_active_power1, ade7953_active_power2, ade7953_active_power);
if (energy_power_on) { // Powered on if (energy_power_on) { // Powered on
energy_voltage = (float)ade7953_voltage_rms / Settings.energy_voltage_calibration; energy_voltage = (float)ade7953_voltage_rms / Settings.energy_voltage_calibration;
energy_active_power = (float)ade7953_active_power / (Settings.energy_power_calibration / 10); energy_active_power = (float)ade7953_active_power / (Settings.energy_power_calibration / 10);
@ -139,21 +142,21 @@ void Ade7953GetData(void)
energy_active_power = 0; energy_active_power = 0;
energy_current = 0; energy_current = 0;
} }
}
void Ade7953EnergyEverySecond()
{
if (ade7953_active_power) { if (ade7953_active_power) {
energy_kWhtoday_delta += ((ade7953_active_power * (100000 / (Settings.energy_power_calibration / 10))) / 3600); energy_kWhtoday_delta += ((ade7953_active_power * (100000 / (Settings.energy_power_calibration / 10))) / 3600);
EnergyUpdateToday(); EnergyUpdateToday();
} }
}
void Ade7953EnergyEverySecond()
{
if (ade7953_init) { if (ade7953_init) {
if (1 == ade7953_init) { if (1 == ade7953_init) {
Ade7953Init(); Ade7953Init();
} }
ade7953_init--; ade7953_init--;
} } else {
else {
Ade7953GetData(); Ade7953GetData();
} }
} }