I'll start a dedicated thread for this device.
In another thread, a similar power meter is covered, but there'are mixed messages referring
to 2 different device, causing a little bit of confusion. (https://www.elektroda.com/rtvforum/topic4016609.html)
The device I'll cover is the following:
Bough from Aliexpress: https://it.aliexpress.com/item/1005007292927857.html
What are my findings:
- HLW8112 (https://redmine.laas.fr/attachments/download/3444/DS_HLW8110_HLW8112_EN_Rev1.01%20.pdf)
- Unstable firmware (at least in my device)
- Power MeterIC connected directly to CBU via SPI (NO TuyaMCU)
- Backup and restore firmware causes wrong measurement, but subsequently I discovered that all power values are reported in a ratio 1:5
Reading the posts from the other thread I concluded that there is no way to use TuyaMCU driver because the Power Meter IC
is directly connected to the Tuya module via SPI.
In fact @dicamarques made an attempt to write a driver for it (21221637#21221637), but, at least in my device,
by compiling the code in his GitHub repo, I was unable to get SPI working.
Furthermore Dicamarques and other guys posted a lot of useful informations:
- a schematc where you can see that P9 is used for "SCSN" instead of the standard P15.
- some link where, presumably, a working driver can be found
Subsequently I wanted to try to write my own driver... spoiler
->
Wrote a lot of code, half of it copy/pasted from the full driver source, but with no luck... the SPI still not send or receive data.
In the next post I'll post the link of my repo
It could be that I'm doing something crazy, like buying a logic analyzer in order to understand what goin on when
the Tuya firmware speaks with the Power Meter IC
I thank the guys who posted in the other thread and I invite everyone to continue in this one.
In another thread, a similar power meter is covered, but there'are mixed messages referring
to 2 different device, causing a little bit of confusion. (https://www.elektroda.com/rtvforum/topic4016609.html)
The device I'll cover is the following:
![Tuya WiFi Energy Meter PM01_A002 [CBS][BK7231N] HLW8112 SPI Pinout and Wiring Details Tuya WiFi Energy Meter PM01_A002 [CBS][BK7231N] HLW8112 SPI Pinout and Wiring Details](https://obrazki.elektroda.pl/7532128400_1752686016_thumb.jpg)
![Tuya WiFi Energy Meter PM01_A002 [CBS][BK7231N] HLW8112 SPI Pinout and Wiring Details Tuya WiFi Energy Meter PM01_A002 [CBS][BK7231N] HLW8112 SPI Pinout and Wiring Details](https://obrazki.elektroda.pl/9865751100_1752686081_thumb.jpg)
![Tuya WiFi Energy Meter PM01_A002 [CBS][BK7231N] HLW8112 SPI Pinout and Wiring Details Tuya WiFi Energy Meter PM01_A002 [CBS][BK7231N] HLW8112 SPI Pinout and Wiring Details](https://obrazki.elektroda.pl/9653196600_1752686083_thumb.jpg)
Bough from Aliexpress: https://it.aliexpress.com/item/1005007292927857.html
What are my findings:
- HLW8112 (https://redmine.laas.fr/attachments/download/3444/DS_HLW8110_HLW8112_EN_Rev1.01%20.pdf)
- Unstable firmware (at least in my device)
- Power MeterIC connected directly to CBU via SPI (NO TuyaMCU)
- Backup and restore firmware causes wrong measurement, but subsequently I discovered that all power values are reported in a ratio 1:5
Reading the posts from the other thread I concluded that there is no way to use TuyaMCU driver because the Power Meter IC
is directly connected to the Tuya module via SPI.
In fact @dicamarques made an attempt to write a driver for it (21221637#21221637), but, at least in my device,
by compiling the code in his GitHub repo, I was unable to get SPI working.
Furthermore Dicamarques and other guys posted a lot of useful informations:
- a schematc where you can see that P9 is used for "SCSN" instead of the standard P15.
- some link where, presumably, a working driver can be found
Subsequently I wanted to try to write my own driver... spoiler

Wrote a lot of code, half of it copy/pasted from the full driver source, but with no luck... the SPI still not send or receive data.
In the next post I'll post the link of my repo

It could be that I'm doing something crazy, like buying a logic analyzer in order to understand what goin on when
the Tuya firmware speaks with the Power Meter IC
I thank the guys who posted in the other thread and I invite everyone to continue in this one.