logo elektroda
logo elektroda
X
logo elektroda

Tuya WiFi Energy Meter PM01_A002 [CBU][BK7231N] HLW8112 SPI Power Reading Ratio 1:5?

kaleidoscopeit 2523 40
ADVERTISEMENT
  • #31 21733747
    feiltom
    Level 5  
    For information on mine I need to overwrite the bootloader for boot OK.
    I cannot flash it anymore, but it works!
  • ADVERTISEMENT
  • #32 21736669
    dweimena
    Level 1  
    I am using OpenBK7231N_1.18.206_hlw8112.rbl on a device like the one in the first post.
    It works very well.
    Is there a way to correct the measurements within very small limits?
    The VoltageSet command does not work.
  • ADVERTISEMENT
  • #33 21794373
    alexsahka
    Level 3  
    Interestingly, after flashing the new firmware, my device is reporting current readings exactly 5× higher than the actual values. Is there a way to recalibrate the scaling factor or apply a correction offset in the configuration? Thank you!

    Screenshot showing energy monitoring interface with measured data for channels A and B Fluke 322 clamp meter display shows 7.20 amps AC Electronic module with PCB and communication chip mounted in a white enclosure Electrical module with input labels and certification symbols Dropdown list with selectable units and electrical measurement parameters
  • #34 21794549
    p.kaczmarek2
    Moderator Smart Home
    I am not the author of HLW8112 integration, but in OBK, we have VoltageSet/CurrentSet/PowerSet commands. We may need to check the source code for HLW8112 to be sure, but calibration is a standard procedure, like with Tasmota.
    Is this the driver used?
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/src/driver/drv_hlw8112.c
    It looks like the author added some extra commands - something like HLW8112_SetResistorGain.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #35 21795249
    alexsahka
    Level 3  
    >>21794549 Thank you for the reply. I tried running some HLW8112 custom commands, but it looks like they aren't supported yet. I noticed a 'TODO' status in the code/documentation—am I interpreting that correctly?

    Also, the standard VoltageSet/CurrentSet/PowerSet commands are returning errors.

    Table with HLW8112 function names and TODO status for each entry
  • #36 21795260
    p.kaczmarek2
    Moderator Smart Home
    This does not mean that they are not supported. It means there is no docs for them yet. The author of HLW8112 SPI feature didn't fill their descriptions.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #37 21795311
    alexsahka
    Level 3  
    >>21795260 I managed to get it working. Using the command HLW8112_SetResistorGain 1 1000 1 caused the voltage readings to spike into the thousands. However, after running HLW8112_SetResistorGain 0 1000 1, the voltage returned to normal and the current readings became accurate (instead of being 5× too high).

    I also noticed a channel mismatch: my current clamp is physically connected to Channel A, but the interface displays the data on Channel B. If I plug the current clamp into Channel B, the interface shows no reading at all.

    I’m not sure who the original author of these HLW8112 drivers is. I tried reading through the forum thread, but it got a bit confusing—does anyone know who I should contact with questions?
  • #38 21795325
    p.kaczmarek2
    Moderator Smart Home
    Helpful post? Buy me a coffee.
  • #39 21795352
    alexsahka
    Level 3  
    >>21795325 As a non-coder, where is the best place to get support — here or GitHub? Thanks.
  • #40 21795356
    p.kaczmarek2
    Moderator Smart Home
    Well, usually the best place to get quick support is here (on Elektroda), but for HLW8112 the case is special, because for some question you may want to reach for PR author.

    maxters007 wrote:
    Hey @p.kaczmarek2 I have created a PR https://github.com/openshwprojects/OpenBK7231T_App/pull/1810
    driver is disabled in the code. please have a look and let me know


    @maxters007 are VoltageSet/CurrentSet/PowerSet commands working in your driver? Can you add command descriptions?
    Helpful post? Buy me a coffee.
  • #41 21795363
    alexsahka
    Level 3  
    >>21795356 Ah, I see—the manufacturer swapped the labels for Channel A and Channel B on the outer case compared to the actual circuit board.
    Internal connections of an energy metering module showing GND, IAP, IBP pins and screw terminals

Topic summary

The discussion focuses on the Tuya WiFi Energy Meter PM01_A002, specifically the CBS version with the BK7231N chip and HLW8112 power metering IC. The device, purchased from AliExpress, features a direct SPI connection between the HLW8112 and the CBU, without a TuyaMCU intermediary. The firmware is reported as unstable, with backup and restore operations causing incorrect measurements. It was discovered that power values are reported with a 1:5 ratio discrepancy. The thread aims to clarify confusion arising from mixed information about similar devices in other forums and provides detailed pinout and wiring information for the HLW8112 SPI interface on this specific model.
Summary generated by the language model.
ADVERTISEMENT