From e54c85f83e8e584f42b29e0c69155b0a6aae101a Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 7 Jun 2020 17:59:54 +0200 Subject: [PATCH] Add full support for BL0940 Add support for BL0940 energy monitor as used in Blitzwolf BW-SHP10 (#8175) --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + tasmota/xnrg_14_bl0940.ino | 28 +++------------------------- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 5e4429dde..fdac7edde 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -75,3 +75,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Add ``FlashFrequency`` to ``status 4`` - Add support for up to two BH1750 sensors controlled by commands ``BH1750Resolution`` and ``BH1750MTime`` (#8139) - Add support for up to eight MCP9808 temperature sensors by device111 (#8594) +- Add support for BL0940 energy monitor as used in Blitzwolf BW-SHP10 (#8175) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 54e1a5f63..4f7d3132b 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -17,6 +17,7 @@ - Add ``FlashFrequency`` to ``status 4`` - Add support for up to two BH1750 sensors controlled by commands ``BH1750Resolution`` and ``BH1750MTime`` (#8139) - Add Zigbee auto-responder for common attributes +- Add support for BL0940 energy monitor as used in Blitzwolf BW-SHP10 (#8175) ### 8.3.1.1 20200518 diff --git a/tasmota/xnrg_14_bl0940.ino b/tasmota/xnrg_14_bl0940.ino index ff5d61ff2..99a738e81 100644 --- a/tasmota/xnrg_14_bl0940.ino +++ b/tasmota/xnrg_14_bl0940.ino @@ -152,31 +152,9 @@ void Bl0940EverySecond(void) { Bl0940.current = 0; Bl0940.power = 0; } else { - long cf_frequency = 0; - - if (BL0940_PULSES_NOT_INITIALIZED == Bl0940.cf_pulses_last_time) { - Bl0940.cf_pulses_last_time = Bl0940.cf_pulses; // Init after restart - } else { - if (Bl0940.cf_pulses < Bl0940.cf_pulses_last_time) { // Rolled over after 16777215 pulses - cf_frequency = (0x1000000 - Bl0940.cf_pulses_last_time) + Bl0940.cf_pulses; - } else { - cf_frequency = Bl0940.cf_pulses - Bl0940.cf_pulses_last_time; - } - if (cf_frequency && Energy.active_power[0]) { - unsigned long delta = (cf_frequency * Settings.energy_power_calibration) / 36; - // prevent invalid load delta steps even checksum is valid (issue #5789): -// if (delta <= (3680*100/36) * 10 ) { // max load for S31/Pow R2: 3.68kW - // prevent invalid load delta steps even checksum is valid but allow up to 4kW (issue #7155): - if (delta <= (4000*100/36) * 10 ) { // max load for S31/Pow R2: 4.00kW - Bl0940.cf_pulses_last_time = Bl0940.cf_pulses; - Energy.kWhtoday_delta += delta; - } - else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: Load overflow")); - Bl0940.cf_pulses_last_time = BL0940_PULSES_NOT_INITIALIZED; - } - EnergyUpdateToday(); - } + if (Energy.active_power[0]) { + Energy.kWhtoday_delta += (Energy.active_power[0] * 1000) / 36; + EnergyUpdateToday(); } }