Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart plugs with a BL0942 power metering chip (and probably also BL0939 and BL0940) only processes messages from the BL0942 chip alternately. #14829

Closed
12 of 14 tasks
Dam5 opened this issue Feb 13, 2022 · 22 comments
Assignees
Labels
bug Type - Confirmated Bug fixed Result - The work on the issue has ended
Milestone

Comments

@Dam5
Copy link

Dam5 commented Feb 13, 2022

PROBLEM DESCRIPTION

In my Elivco smart plugs I replaced the Tuya CB2S module with a drop-in ESP-2S module, and flashed them with Tasmota 10.1.0 and calibrated them.

I observed 2 problems:

  1. regularly checksum errors
  2. ca 0.8 kWh daily energy consumption, relay ON, while no load is attached

(Third problem is that calibrating the current for a BL0942 is in Amps, and the calibrating should be in mAmps, or visa versa, but that's a minor problem)

While investigation this strange energy consumption behaviour of my smartplugs with BL0942 chip, I discovered that half of the messages received from the BL0942 chip are disgarded.

It boils down to reading 24 bytes from the BL0942 chip before processing, while the packet is only 23 bytes long.
This 24th byte is the packet-header of the next (23 byte) packet, but is not saved and never handled, so the complete next packet is disgarded waiting for the subsequent BL09XX_PACKET_HEADER byte.

Unless there's a BL09XX_PACKET_HEADER byte (0x55) in the actual data of the (otherwise disgarded) packet, in which case the receive-buffer is filled with 24 bytes from that point on.
In that case, most of the time, this results in a checksum error.
But sometimes (once every few minutes) the (simple) checksum turns out to be correct, and the (shifted) bytes lead to processing of incorrect data.
For example resulting in huge (1 second) power spikes which adds up to the daily total energy.
This is the source of the power consumption I was observing.
These power spikes are so short that they are not displayed (as Watts) in the main webpage of the device (I've never observed one), and are not logged in the sensor-data via MQTT.
So the power is always 0 Watt, and the energy is slowly adding up.
(Btw, 0.8 kWh daily corresponds to ca 30 Watt continuously)

In Tasmota every second a poll request is sent out to the BL0942, and there's no synchronisation between sending and receiving data (which in this case is good, the communication is not blocked waiting for eachother)

Enabling debugging (DEBUG_BL09XX) reveals that indeed the data is processed only once per two seconds, while the poll is send out every second.
Another symptom: In a device like this, with ultra short communication lines, there shouldn't be checksum errors.
Third symptom: The time between the (2nd) poll and the processing of the received message (10 ms) is way too fast for 23 bytes at 4800 baud (should be ca 48 ms)

The bug seems a classic index/byte-count error.

I also expect memory corruption (store 24 bytes in a 23 byte malloced buffer), but I've not looked into that.

IMO the cullpit is in line 221 of xnrg_14_bl09xx.ino

211  void Bl09XXSerialInput(void) {
212    while (Bl09XXSerial->available()) {
213      yield();
214      uint8_t serial_in_byte = Bl09XXSerial->read();
215      if (!Bl09XX.received && (BL09XX_PACKET_HEADER == serial_in_byte)) {
216        Bl09XX.received = true;
217        Bl09XX.byte_counter = 0;
218      }
219      if (Bl09XX.received) {
220        Bl09XX.rx_buffer[Bl09XX.byte_counter++] = serial_in_byte;    //  Possible memory corruption
221        if (Bl09XX.buffer_size == Bl09XX.byte_counter -1) {      //   byte_counter is 24, while buffer_size is 23

replacing line 221 with

221      if (Bl09XX.buffer_size == Bl09XX.byte_counter) {

solves the alternating problem.(and memory corruption, and checksum errors, and energy creep)

I also checked the datasheets of the BL0939 and the BL0940 chips and I expect these have the same problem (packet is 35 bytes, while 36 bytes are read before processing).
(https://www.belling.com.cn/media/file_object/bel_product/BL0939/datasheet/BL0939_V1.2_cn.pdf, https://www.belling.com.cn/media/file_object/bel_product/BL0940/datasheet/BL0940_V1.1_en.pdf)
The chinese one was the only I could find.

Am I the only one observing this behaviour, or am I barking at the wrong tree (and making a fool of myself)?

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

  • Read the Contributing Guide and Policy and the Code of Conduct
  • Searched the problem in issues
  • Searched the problem in discussions
  • Searched the problem in the docs
  • Searched the problem in the chat
  • Device used (e.g., Sonoff Basic): Elivco Smart Plug with energy monitoring
  • Tasmota binary firmware version number used: 10.1.0
    • Pre-compiled
    • Self-compiled
  • Flashing tools used: WebUI firmware update
  • Provide the output of command: Backlog Template; Module; GPIO 255:
19:23:22.213 CMD: Grp 0, Cmnd 'TEMPLATE', Idx 1, Len 0, Data ''
19:23:22.220 MQT: ESP20/SmartPlug05/stat/RESULT = {"NAME":"Power Monitoring Plug (BL0942)","GPIO":[0,3200,0,7520,0,32,0,0,0,544,224,0,0,0],"FLAG":0,"BASE":18}
19:23:22.427 SRC: Backlog
19:23:22.429 CMD: Grp 0, Cmnd 'MODULE', Idx 1, Len 0, Data ''
19:23:22.435 MQT: ESP20/SmartPlug05/stat/RESULT = {"Module":{"0":"Power Monitoring Plug (BL0942)"}}
19:23:22.643 SRC: Backlog
19:23:22.646 CMD: Grp 0, Cmnd 'GPIO', Idx 1, Len 3, Data '255'
19:23:22.656 MQT: ESP20/SmartPlug05/stat/RESULT = {"GPIO0":{"0":"None"},"GPIO1":{"3200":"Serial Tx"},"GPIO2":{"0":"None"},"GPIO3":{"7520":"BL0942 Rx"},"GPIO4":{"0":"None"},"GPIO5":{"32":"Button1"},"GPIO9":{"0":"None"},"GPIO10":{"0":"None"},"GPIO12":{"0":"None"},"GPIO13":{"544":"LedLink"},"GPIO14":{"224":"Relay1"},"GPIO15":{"0":"None"},"GPIO16":{"0":"None"},"GPIO17":{"0":"None"}}
  • If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:

  • Provide the output of this command: Status 0:
19:24:08.050 CMD: Grp 0, Cmnd 'STATUS', Idx 1, Len 1, Data '0'
19:24:08.057 MQT: ESP20/SmartPlug05/stat/STATUS = {"Status":{"Module":0,"DeviceName":"SmartPlug05","FriendlyName":["SmartPlug05"],"Topic":"SmartPlug05","ButtonTopic":"0","Power":1,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0}}
19:24:08.067 MQT: ESP20/SmartPlug05/stat/STATUS1 = {"StatusPRM":{"Baudrate":4800,"SerialConfig":"8N1","GroupTopic":"group5","OtaUrl":"http://ota.tasmota.com/tasmota/release/tasmota.bin.gz","RestartReason":"Software/System restart","Uptime":"0T00:41:48","StartupUTC":"2022-02-13T17:42:20","Sleep":50,"CfgHolder":4617,"BootCount":31,"BCResetTime":"2022-01-19T13:37:17","SaveCount":125,"SaveAddress":"F8000"}}
19:24:08.078 MQT: ESP20/SmartPlug05/stat/STATUS2 = {"StatusFWR":{"Version":"10.1.0(tasmota)","BuildDateTime":"2022-02-13T18:39:47","Boot":31,"Core":"2_7_4_9","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8285","CR":"376/699"}}
19:24:08.086 MQT: ESP20/SmartPlug05/stat/STATUS3 = {"StatusLOG":{"SerialLog":0,"WebLog":3,"MqttLog":3,"SysLog":4,"LogHost":"Pluto","LogPort":514,"SSId":["xxxxxxxxxxx",""],"TelePeriod":300,"Resolution":"559180C0","SetOption":["00008009","2805C80001000600003C5A0A000000000000","00000080","00006000","00004000"]}}
19:24:08.100 MQT: ESP20/SmartPlug05/stat/STATUS4 = {"StatusMEM":{"ProgramSize":616,"Free":384,"Heap":25,"ProgramFlashSize":1024,"FlashSize":1024,"FlashChipId":"144051","FlashFrequency":40,"FlashMode":3,"Features":["00000809","8FDAC787","04368001","000000CF","010013C0","C000F981","00004004","00001000","00000020"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,16,18,19,20,21,22,24,26,27,29,30,35,37,45","Sensors":"1,2,3,4,5,6"}}
19:24:08.110 MQT: ESP20/SmartPlug05/stat/STATUS5 = {"StatusNET":{"Hostname":"ESP20","IPAddress":"192.168.10.220","Gateway":"192.168.10.254","Subnetmask":"255.255.255.0","DNSServer1":"192.168.10.1","DNSServer2":"0.0.0.0","Mac":"7C:87:XX:XX:XX:XX","Webserver":2,"HTTP_API":1,"WifiConfig":4,"WifiPower":17.0}}
19:24:08.118 MQT: ESP20/SmartPlug05/stat/STATUS6 = {"StatusMQT":{"MqttHost":"Pluto","MqttPort":1883,"MqttClientMask":"ESP20","MqttClient":"ESP20","MqttUser":"DVES_USER","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4}}
19:24:08.127 MQT: ESP20/SmartPlug05/stat/STATUS7 = {"StatusTIM":{"UTC":"2022-02-13T18:24:08","Local":"2022-02-13T19:24:08","StartDST":"2022-03-27T02:00:00","EndDST":"2022-10-30T03:00:00","Timezone":99,"Sunrise":"07:56","Sunset":"17:46"}}
19:24:08.134 MQT: ESP20/SmartPlug05/stat/STATUS9 = {"StatusPTH":{"PowerDelta":[0,0,0],"PowerLow":0,"PowerHigh":0,"VoltageLow":0,"VoltageHigh":0,"CurrentLow":0,"CurrentHigh":0}}
19:24:08.147 MQT: ESP20/SmartPlug05/stat/STATUS10 = {"StatusSNS":{"Time":"2022-02-13T19:24:08","ENERGY":{"TotalStartTime":"2022-01-19T13:37:17","Total":3.920,"Yesterday":0.005,"Today":0.010,"Power":0.00,"ApparentPower":0.00,"ReactivePower":0.00,"Factor":0.00,"Voltage":232,"Current":0.000}}}
19:24:08.156 MQT: ESP20/SmartPlug05/stat/STATUS11 = {"StatusSTS":{"Time":"2022-02-13T19:24:08","Uptime":"0T00:41:48","UptimeSec":2508,"Heap":25,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"ON","Wifi":{"AP":1,"SSId":"Heuvelrug","BSSId":"D4:63:FE:DC:B3:92","Channel":11,"Mode":"11n","RSSI":66,"Signal":-67,"LinkCount":1,"Downtime":"0T00:00:03"}}}
  • Set weblog to 4 and then, when you experience your issue, provide the output of the Console log:
18:51:40.412 BL9: Poll
18:51:40.423 DMP: 55 00 00 00 9C CA 37 37 43 00 00 00 00 A2 01 00 5E 4E 00 22 01 00 C9
18:51:40.426 BL9: U 3656348, I 0, P 0
18:51:40.428 BL9: Chan[0] I zero, P zero
18:51:41.459 BL9: Poll
18:51:42.439 BL9: Poll
18:51:42.450 DMP: 55 19 00 00 2A CF 37 0C 44 00 02 00 00 A2 01 00 5E 4E 00 22 01 00 45
18:51:42.453 BL9: U 3657514, I 25, P 2
18:51:42.455 BL9: Chan[0] I zero, P zero
18:51:43.425 BL9: Poll
18:51:43.533 WIF: Checking connection...
18:51:44.440 BL9: Poll
18:51:44.451 DMP: 55 00 00 00 8F CE 37 A5 42 00 00 00 00 A2 01 00 5E 4E 00 02 01 00 85
18:51:44.453 BL9: U 3657359, I 0, P 0
18:51:44.455 BL9: Chan[0] I zero, P zero
18:51:45.429 BL9: Poll
18:51:46.410 BL9: Poll
18:51:46.422 DMP: 55 00 00 00 69 D8 37 41 44 00 00 00 00 A2 01 00 5E 4E 00 02 01 00 03
18:51:46.424 BL9: U 3659881, I 0, P 0
18:51:46.426 BL9: Chan[0] I zero, P zero
18:51:47.454 BL9: Poll
18:51:48.429 BL9: Poll
18:51:48.441 DMP: 55 00 00 00 04 D0 37 44 44 00 00 00 00 A2 01 00 5E 4E 00 22 01 00 4D
18:51:48.443 BL9: U 3657732, I 0, P 0
18:51:48.445 BL9: Chan[0] I zero, P zero
18:51:49.447 BL9: Poll
18:51:50.434 BL9: Poll
18:51:50.446 DMP: 55 00 00 00 F7 D9 37 04 41 00 00 00 00 A2 01 00 5E 4E 00 02 01 00 B4
18:51:50.448 BL9: U 3660279, I 0, P 0
18:51:50.450 BL9: Chan[0] I zero, P zero
18:51:51.422 BL9: Poll
18:51:52.410 BL9: Poll
18:51:52.422 DMP: 55 00 00 00 DC D4 37 01 42 00 00 00 00 A2 01 00 5E 4E 00 02 01 00 D6
18:51:52.424 BL9: U 3658972, I 0, P 0
18:51:52.426 BL9: Chan[0] I zero, P zero
18:51:53.452 BL9: Poll
18:51:54.481 BL9: Poll
18:51:54.492 DMP: 55 00 00 00 BA D9 37 BA 43 00 00 00 00 A2 01 00 56 4E 00 02 01 00 41
18:51:54.494 BL9: U 3660218, I 0, P 0
18:51:54.496 BL9: Voltage , Temp 
18:51:54.498 BL9: Chan[0] I zero, P zero
18:51:55.524 BL9: Poll
18:51:56.436 BL9: Poll
18:51:56.448 DMP: 55 00 00 00 D7 D0 37 5C 40 00 00 00 00 A2 01 00 56 4E 00 02 01 00 8E
18:51:56.451 BL9: U 3657943, I 0, P 0
18:51:56.452 BL9: Chan[0] I zero, P zero
18:51:57.429 BL9: Poll
18:51:58.452 BL9: Poll
18:51:58.464 DMP: 55 00 00 00 C4 CD 37 5B 42 00 00 00 00 A2 01 00 5E 4E 00 02 01 00 9B
18:51:58.467 BL9: U 3657156, I 0, P 0
18:51:58.469 BL9: Chan[0] I zero, P zero
18:51:59.443 BL9: Poll
18:52:00.419 BL9: Poll
18:52:00.430 DMP: 55 00 00 00 95 D2 37 14 43 00 00 00 00 A2 01 00 56 4E 00 02 01 00 13
18:52:00.432 BL9: U 3658389, I 0, P 0
18:52:00.434 BL9: Chan[0] I zero, P zero
18:52:01.436 BL9: Poll
18:52:02.410 BL9: Poll
18:52:02.422 DMP: 55 00 00 00 7D DF 37 81 41 00 00 00 00 A2 01 00 5E 4E 00 22 01 00 8B
18:52:02.424 BL9: U 3661693, I 0, P 0
18:52:02.426 BL9: Chan[0] I zero, P zero
18:52:03.449 BL9: Poll
18:52:03.462 DMP: 55 00 00 B0 E1 37 8B 41 00 07 00 00 A2 01 00 56 4E 00 02 01 00 18 55
18:52:03.464 BL9: U 9123809, I 11534336, P 6160384  <- incorrect data leading to unrealistic high current and power values (for 2 seconds)
18:52:03.466 BL9: Chan[0] I , P                <- AddLog("%f") is not resolved. powercal = 703 , so Power = 8763 Watt
18:52:03.486 WIF: Checking connection...
18:52:04.448 BL9: Poll
18:52:05.438 BL9: Poll
18:52:05.450 DMP: 55 00 00 00 2A D3 37 9E 41 00 00 00 00 A2 01 00 5E 4E 00 02 01 00 ED
18:52:05.452 BL9: U 3658538, I 0, P 0
18:52:05.454 BL9: Chan[0] I zero, P zero
18:52:06.456 BL9: Poll
18:52:07.441 BL9: Poll
18:52:07.453 DMP: 55 00 00 00 4B D1 37 0C 42 00 00 00 00 A2 01 00 5E 4E 00 22 01 00 3F
18:52:07.455 BL9: U 3658059, I 0, P 0
18:52:07.457 BL9: Chan[0] I zero, P zero
18:52:08.428 BL9: Poll
18:52:09.417 BL9: Poll
18:52:09.428 DMP: 55 00 00 00 63 D0 37 E8 40 00 00 00 00 A2 01 00 56 4E 00 02 01 00 76
18:52:09.430 BL9: U 3657827, I 0, P 0
18:52:09.432 BL9: Chan[0] I zero, P zero
18:52:10.456 BL9: Poll
18:52:11.417 BL9: Poll
18:52:11.429 DMP: 55 00 00 00 E4 CE 37 2C 44 00 00 00 00 A2 01 00 5E 4E 00 22 01 00 87
18:52:11.431 BL9: U 3657444, I 0, P 0
18:52:11.433 BL9: Chan[0] I zero, P zero
18:52:12.448 BL9: Poll

BTW a number of AddLog()'s are in print-float format "%f" which are not by default resolved when building.

In my debugging I have replaced these with dtostrf() calls, but in the above output the stock "%f"'s are not resolved, resulting is empty strings for Voltage en Temp, or skipping these Voltage-strings alltogether.

TO REPRODUCE

  • Relay On
  • No load plugged in
  • Wait a couple of hours
  • Watch the energy consumption rising slowly

It greatly depends if 0x55 is part of the actual data. In my case it is.

EXPECTED BEHAVIOUR

  • No energy creep when no load is attached.
  • No checksum errors

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

@barbudor
Copy link
Contributor

Thanks for the analysis
I will check that later tonight

@barbudor
Copy link
Contributor

barbudor commented Feb 13, 2022

@Dam5
(EDIT: The 2nd problem is not, it is correct)

I do agree and see 2 the same problem

  • The comparison you pointed is wrong so the received checksum is never stored
  • The loop for calculating the checksum should be from 0 to buffer_size-2 because rx_buffer[buffer_size-1] is the incoming checksum

Do you want to make the change and test, then PR ?
I could make the change and PR but I have not device to test.

Should be:

  if (Bl09XX.received) {
      Bl09XX.rx_buffer[Bl09XX.byte_counter++] = serial_in_byte;
      if (Bl09XX.buffer_size == Bl09XX.byte_counter) {

@Dam5
Copy link
Author

Dam5 commented Feb 13, 2022

@barbudor
The only problem is the comparison in line 221.

The checksum calculation is (and was) correct.
First the complete message is received and stored, including checksum in rx_buffer[buffer_size-1].
Your proposal for changing the for-loop is IMHO incorrect.
Calculate checksum for index 0 to 21, compare with index 22 (= checksum-byte).
In your solution the for-loop is one byte short.
I've tested your solution, and it accidentally works, but only because the last data-byte is (always) 0x00, so it has no impact in the checksum calculation.

I've run my solution for the last 2 days and seemed OK.
But I might be wrong.

(EDIT: typo's)

@barbudor
Copy link
Contributor

Yes, I change my original message
The loop is correct as it is

Will you PR ?

@arendst
Copy link
Owner

arendst commented Feb 13, 2022

Let me do it. I need to do some checks first.

@Dam5
Copy link
Author

Dam5 commented Feb 13, 2022

@arendst
Thanks

@arendst arendst self-assigned this Feb 13, 2022
@PVerburg
Copy link

Hi, I have 2 device here with similar problems no code expert but can assist with testing ?

@ascillato2 ascillato2 added the bug Type - Confirmated Bug label Feb 14, 2022
@Dam5
Copy link
Author

Dam5 commented Feb 14, 2022

Probably superfluous, but just to be clear.
These incorrect data-packets (as a result of wrong counting bytes) are always possible, also when load is attached.
But then they're not so obvious.
I've smart plugs with constant load where the energy-totals didn't match with the power.
(Which triggered the investigation)

@arendst
Copy link
Owner

arendst commented Feb 14, 2022

Started working on it and first impressions are you're right regarding the buffer size checks.

I was also surprised to find %f as we never supported this due to code size increase of several ks. Searching the code for %f revealed more inconsistencies in the BLE drivers. I will need to change this as we support %*_f.

Will continue now first with the BL09xx driver.

arendst added a commit that referenced this issue Feb 14, 2022
Fix BL0939, BL0940 and BL0942 energy monitoring buffer miscompares resulting in wrong daily energy values regression from v9.5.0.8 (#14829)
@arendst arendst added the fixed Result - The work on the issue has ended label Feb 14, 2022
@arendst
Copy link
Owner

arendst commented Feb 14, 2022

Thx for the thorough investigation.

The suspected buffer overflow did not occur as the byte_counter is incremented AFTER it was used as index into the buffer.

Anyway, I noticed my BL0940 device also skipped a beat and I was also wondering how come the daily result was offtrack too.

Again. Keep em coming this way as it always reveals nice black spots.

@arendst arendst added this to the v11.1 milestone Feb 14, 2022
@Dam5
Copy link
Author

Dam5 commented Feb 14, 2022

I have to disagree.
I know boundery checks and indexing are tricky so I should be carefull.

Indeed byte_counter is incremented after used as an index, but byte_counter is at that point already out-of-bounds.

buffer_size = 23; rx_buffer[0..22] ; But byte_counter = 23, incrementing to 24.
rx_buffer[23] is out-of-bounds.

But never mind: Love your project.

(EDIT: Sorry, sounds pedantic, not intended)

@arendst arendst closed this as completed Feb 15, 2022
@ferbulous
Copy link

hi @Dam5
do you mind sharing your templates for your power plug with BL0942?

@Dam5
Copy link
Author

Dam5 commented Mar 21, 2022

@ferbulous
no problem, it's also in the OP, but there it is somewhat obfuscated.
Template: {"NAME":"Power Monitoring Plug (BL0942)","GPIO":[0,3200,0,7520,0,32,0,0,0,544,224,0,0,0],"FLAG":0,"BASE":18}

@ferbulous
Copy link

@Dam5 Thanks! Just another question, how can I determine the corrent gpio pin is for HLWBL CF1/HLWBL SELi? I tried googling around but I can't find clear answer on this

@Dam5
Copy link
Author

Dam5 commented Mar 21, 2022

@ferbulous
I'm not sure what you mean.

The BL0942-based power plug uses a serial (4800 baud) protocol (to communicate whith the BL0942 chip).
Tasmota template config: Transmit is default TX (there is no BL0942-TX), Receive is BL0942-RX.
HLWBL CF1and HLWBL SELi, which are pulse-based protocols, are not used.

HLWBL CF1and HLWBL SELi (among others) are used in e.g. BL0937-based power plugs.

Are you sure you're dealing whith a BL0942-based power plug?

Beware that there are a lot of different, almost identically looking, smart plugs for sale.
(Most of them don't use ESP8266 anymore, but use TUYA-based modules, which are not Tasmota compatible)
I had to reverse engineer mine, to track down the pin/gpio numbers (and replace the module with a ESP-02S or simular)
Yours could use different GPIO-numbers.

See attached images for a BL0937-based power plug (OctoPlug) and a BL0942-based power plug (Smartplug05) that I keep for reference.

SmartPlug Internal Pinout (c) OctoPlug  (Athom)  (ESP12  GPIO's)
IMG_5190 Pin-bezetting

@ferbulous
Copy link

ferbulous commented Mar 21, 2022

@Dam5
Thanks for clearing that up,
I'm just starting to delve into power monitoring plugs so I'm not too familiar with all the technical details yet. Currently I'm looking at other existing power monitoring templates, so I assumed HLWBL CF1 and HLWBL SELi are required.
The one I recently bought is this which I plan to swap the CB2S tuya module with ESP-02.

Plugs-4
Plugs-3

@Dam5
Copy link
Author

Dam5 commented Mar 21, 2022

@ferbulous
Alltough your PCB is very different, the pin-layout is probably simular to mine.
The BL0942 traces (upper-left 2 of the BL0942 chip) are going to the same 2 pins on the Tuya-module as mine.
The Tuya-module looks very simular too, so when you use a ESP-02S drop-in replacement, the 3.3V, GND, TX and BL0942-RX are most likely the same.

For Relay (probably the same, P26 on the Tuya), Pushbutton (trace is not visible) and blue LED (trace not visible) you have to trace the PCB.
(The red LED is hard-wired, and is not addressable/controlable)

@PVerburg
Copy link

PVerburg commented Mar 22, 2022

That looks like the same board I have modified (AU) works well now they fixed a small bug in the driver. :-)

@ferbulous
Copy link

ferbulous commented Mar 22, 2022

@Dam5 Hi, just swapped with ESP-02S and your template matches the exact pin with my power plug. I'll proceed with power calibration as per the tasmota guideline page which I've never done before so hopefully I'll get it right
As for the red led hardwired, it because it's not tied to any gpio for that specific led red color?
With power monitoring feature, could we add some tasmota rules say if low current/power within 15-20 minutes, then turn off the plug?

@PVerburg do you by any chance got it from aliexpress?

@Dam5
Copy link
Author

Dam5 commented Mar 22, 2022

@ferbulous
The red LED is hard-wired to (the state of) the relay.
I 've never used (Tasmota) rules, so I can't help you with that.
Beware that the BL0942 bug-fix, discribed in this issue, is scheduled for Tasmota 11.1, which is not released yet.

@PVerburg
Copy link

@Dam5 yep did get it from ali.
And yes you could make a rule you must be more precise as your needs and maybe use discord so more people can benefit and assist?

@myfingerhurt
Copy link

I have a gosund wf6-2, it is a BL0937-based power plugs, and the pin configuration is same as OctoPlug that @Dam5 has posted.
I have successfully downloaded tasmota 12.1.1 into gosund wf6-2.
Thanks to @Dam5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type - Confirmated Bug fixed Result - The work on the issue has ended
Projects
None yet
Development

No branches or pull requests

7 participants