From 860e12b88a9118a2c14e0a72ea8871b8ae5a4218 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 13 Sep 2023 15:49:14 +0200 Subject: [PATCH] Add frequency to BL0942 --- tasmota/tasmota_xnrg_energy/xnrg_14_bl09xx.ino | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tasmota/tasmota_xnrg_energy/xnrg_14_bl09xx.ino b/tasmota/tasmota_xnrg_energy/xnrg_14_bl09xx.ino index 6cd5a4e8018e..343210e71ab6 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_14_bl09xx.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_14_bl09xx.ino @@ -25,6 +25,11 @@ /*********************************************************************************************\ * Support the following Shangai Belling energy sensors: * + * BL0942 - Energy (as in Shelly Plus1PMMini) + * Template {"NAME":"Shelly Plus1PMMini","GPIO":[576,32,0,4736,0,224,3200,8161,0,0,192,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1,"CMND":"AdcParam1 2,5600,4700,3350} + * Template {"NAME":"Shelly PlusPMMini","GPIO":[576,32,0,4736,0,0,3200,8161,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1,"CMND":"AdcParam1 2,5600,4700,3350} + * Based on datasheet from https://datasheet.lcsc.com/lcsc/2110191830_BL-Shanghai-Belling-BL0942_C2909509.pdf + * * BL0940 - Energy (as in Blitzwolf SHP10) * Template {"NAME":"BW-SHP10","GPIO":[0,148,0,207,158,21,0,0,0,17,0,0,0],"FLAG":0,"BASE":18} * Based on datasheet from http://www.belling.com.cn/media/file_object/bel_product/BL09XX/datasheet/BL09XX_V1.1_en.pdf @@ -85,6 +90,7 @@ const uint8_t bl09xx_init[5][4] = { struct BL09XX { uint32_t voltage = 0; + uint32_t frequency = 0; uint32_t current[2] = { 0, }; int32_t power[2] = { 0, }; float temperature; @@ -165,11 +171,19 @@ bool Bl09XXDecode42(void) { // U 3560882, I 47550, P 26409, C 153 // All above from a single test with a 40W buld on 230V + // Shelly Plus1PMMini + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 + // Hd Current- Voltage- IFRms--- Power--- CF------ Freq- 00 St 00 00 Ck + // 55 20 16 01 D2 A4 33 9B 63 00 9E 92 00 33 00 00 26 4E 00 20 01 00 7C + // 55 07 15 01 6A A7 33 C0 62 00 0E 92 00 34 00 00 26 4E 00 20 01 00 66 + // 55 F0 15 01 E3 9C 33 4B 63 00 6E 92 00 34 00 00 26 4E 00 20 01 00 23 + if (Bl09XX.rx_buffer[0] != BL09XX_PACKET_HEADER) { AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("BL9: Invalid data hd=%02X"), Bl09XX.rx_buffer[0]); return false; } + Bl09XX.frequency = Bl09XX.rx_buffer[17] << 8 | Bl09XX.rx_buffer[16]; // FREQ Bl09XX.voltage = Bl09XX.rx_buffer[6] << 16 | Bl09XX.rx_buffer[5] << 8 | Bl09XX.rx_buffer[4]; // V_RMS unsigned Bl09XX.current[0] = Bl09XX.rx_buffer[3] << 16 | Bl09XX.rx_buffer[2] << 8 | Bl09XX.rx_buffer[1]; // IA_RMS unsigned @@ -189,6 +203,9 @@ bool Bl09XXDecode42(void) { void Bl09XXUpdateEnergy() { if (Energy->power_on) { // Powered on + if (BL0942_MODEL == Bl09XX.model) { + Energy->frequency[0] = (float)1000000.0 / Bl09XX.frequency; // Datasheet page 19 (v1.04) + } Energy->voltage[0] = (float)Bl09XX.voltage / EnergyGetCalibration(ENERGY_VOLTAGE_CALIBRATION); Energy->voltage[1] = Energy->voltage[0]; #ifdef DEBUG_BL09XX