From e8056df1ad43994a6c1c6477a47753b106e2b021 Mon Sep 17 00:00:00 2001 From: Fabrizio Amodio <32312585+ZioFabry@users.noreply.github.com> Date: Fri, 3 Feb 2023 17:52:26 +0100 Subject: [PATCH] Biopdu-v1.1.1 (#17868) * Template Fix * Removed common setting, use SetOption150 instead * code cleaning * BioPDU Factory Settings * CHANGELOG update * RELEASENOTES update --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + .../tasmota_xnrg_energy/xnrg_24_biopdu.ino | 66 +++++++++++-------- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db0e80491..99b4e482f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - ESP32 command ``EnergyDisplay 1..3`` to change GUI column presentation - support for SEN5X gas and air quality sensor by Tyeth Gundry (#17736) - Berry add ``mdns`` advanced features and query +- ESP32 support for Biomine BioPDU 625x12 (#17857) ### Breaking Changed - Berry energy_ctypes changed with new energy driver diff --git a/RELEASENOTES.md b/RELEASENOTES.md index d9421ff0b..5f2183fd9 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -127,6 +127,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - ESP32 command ``EnergyDisplay 1..3`` to change GUI column presentation - ESP32 support for eigth energy phases/channels - ESP32 support for BMPxxx sensors on two I2C busses [#17643](https://github.com/arendst/Tasmota/issues/17643) +- ESP32 support for Biomine BioPDU 625x12 [#17857](https://github.com/arendst/Tasmota/issues/17857) ### Breaking Changed diff --git a/tasmota/tasmota_xnrg_energy/xnrg_24_biopdu.ino b/tasmota/tasmota_xnrg_energy/xnrg_24_biopdu.ino index 816f6569a..e4413f814 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_24_biopdu.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_24_biopdu.ino @@ -1,11 +1,12 @@ /* xnrg_24_biopdu.ino - BioPDU-625x12 (based on xnrg_05_pzem_ac.ino) Biomine 625x12 Custom Board + 6 x 25A Relays 6 x Independent PZEM-004V3 Modbus AC energy sensor 3bit serial switch Integrated MCP23008 - Template {"NAME":"Olimex ESP32-PoE-BioPDU","GPIO":[1,10081,10082,1,10016,1,0,0,5536,640,1,1,608,0,5600,0,0,0,0,5568,0,0,0,0,0,0,0,0,1,10080,1,1,10048,0,0,1],"FLAG":0,"BASE":1} + Template {"NAME":"Olimex ESP32-PoE-BioPDU","GPIO":[1,10209,10210,1,10144,1,0,0,5536,640,1,1,608,0,5600,0,0,0,0,5568,0,0,0,0,0,0,0,0,1,10208,1,1,10176,0,0,1],"FLAG":0,"BASE":1} Copyright (C) 2021 Theo Arends Copyright (C) 2022-2023 Fabrizio Amodio @@ -27,6 +28,42 @@ #if defined(USE_ENERGY_SENSOR_ESP32) && defined(USE_I2C) #ifdef USE_BIOPDU +/* + BioPDU 625x12 Factory Settings: + + Template {"NAME":"Olimex ESP32-PoE-BioPDU","GPIO":[1,10209,10210,1,10144,1,0,0,5536,640,1,1,608,0,5600,0,0,0,0,5568,0,0,0,0,0,0,0,0,1,10208,1,1,10176,0,0,1],"FLAG":0,"BASE":1} + Module 0 + EthType 0 + EthAddress 0 + EthClockMode 3 + SetOption26 1 + SetOption129 1 + SetOption150 1 + EnergyDisplay 1 + EnergyCols 6 + i2cscan + Sensor29 0,1,0 + Sensor29 1,5,2 + Sensor29 2,5,2 + Sensor29 3,5,2 + Sensor29 4,5,2 + Sensor29 5,5,2 + Sensor29 6,5,2 + Sensor29 7,1,0 + + compile with build flags: + + ${env:tasmota32.build_flags} + USE_ETHERNET + ETH_TYPE=0 + ETH_ADDRESS=0 + ETH_CLKMODE=3 + USE_MCP230xx + USE_MCP230xx_ADDR=0x20 + USE_MCP230xx_OUTPUT + USE_BIOPDU +*/ + #define XNRG_24 24 #undef ENERGY_MAX_PHASES @@ -117,22 +154,10 @@ void BioPduEvery250ms(void) Energy->frequency[BioPdu.phase] = (float)((buffer[17] << 8) + buffer[18]) / 10.0f; // 50.0 Hz Energy->power_factor[BioPdu.phase] = (float)((buffer[19] << 8) + buffer[20]) / 100.0f; // 1.00 Energy->import_active[BioPdu.phase] = (float)((buffer[15] << 24) + (buffer[16] << 16) + (buffer[13] << 8) + buffer[14]) / 1000.0f; // 4294967.295 kWh - - // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("PDU: ph=%d v=%2_f c=%4_f ap=%2_f f=%2_f pf=%3_f ia=%4_f"), - // BioPdu.phase, - // &Energy->voltage[BioPdu.phase], - // &Energy->current[BioPdu.phase], - // &Energy->active_power[BioPdu.phase], - // &Energy->frequency[BioPdu.phase], - // &Energy->power_factor[BioPdu.phase], - // &Energy->import_active[BioPdu.phase] - // ); } } } - // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("PDU: ph=%d st=%d dr=%d sr=%d"), BioPdu.phase, BioPdu.address_step, data_ready, BioPdu.send_retry); - if (0 == BioPdu.send_retry || data_ready) { if (ADDR_SEND == BioPdu.address_step) @@ -165,24 +190,12 @@ void BioPduEvery250ms(void) } break; } - else - { - // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("PDU: phase %d not read"), BioPdu.phase); - } } } } else { BioPdu.send_retry--; - if ((Energy->phase_count > 1) && (0 == BioPdu.send_retry) && (TasmotaGlobal.uptime < BIOPDU_STABILIZE)) - { - // Energy->phase_count--; // Decrement phases if no response after retry within 30 seconds after restart - // if (TasmotaGlobal.discovery_counter) - // { - // TasmotaGlobal.discovery_counter += ENERGY_WATCHDOG + 1; // Don't send Discovery yet, delay by 4s + 1s - // } - } } } @@ -210,9 +223,6 @@ void BioPduDrvInit(void) { TasmotaGlobal.energy_driver = XNRG_24; - Energy->voltage_common = false; - Energy->frequency_common = false; - AddLog(LOG_LEVEL_DEBUG, PSTR("PDU: checking pins")); for (uint8_t p = 0; p < 3; p++)