I'll start a dedicated thread for this device.
In another thread, a similar power meter is covered, but there'are mixed messages referring
both devices, causing a little bit of confusion. (https://www.elektroda.com/rtvforum/topic4016609.html)
The device I'll cover in this thread 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 module 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
By 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 with my device,
by compiling the code he wrote from 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.
- links where very complete and presumably working drivers can be found
Subsequently I wanted to try to write my own driver...
Spoiler
I wrote a lot of code, half of it, copy/pasted from the full driver source from the link above, but with no luck... the SPI still not send or receive data.
This i the link to my repo, in case someone more experienced can tell me what I'm doing wrong
https://github.com/kaleidoscopeit/OpenBK7231T_App_HLW8112
(--> To start the driver, issue "startDriver HLW8112SPI" in the command field of the log console in the Web Application)
It could be that I'm doing something crazy, like buying a logic analyzer and connect it to the SPI in order to understand what goin on when
the original 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
both devices, causing a little bit of confusion. (https://www.elektroda.com/rtvforum/topic4016609.html)
The device I'll cover in this thread is the following:
![Tuya WiFi Energy Meter PM01_A002 [CBU][BK7231N] HLW8112 SPI Power Reading Ratio 1:5? Tuya WiFi Energy Meter PM01_A002 [CBU][BK7231N] HLW8112 SPI Power Reading Ratio 1:5?](https://obrazki.elektroda.pl/7532128400_1752686016_thumb.jpg)
![Tuya WiFi Energy Meter PM01_A002 [CBU][BK7231N] HLW8112 SPI Power Reading Ratio 1:5? Tuya WiFi Energy Meter PM01_A002 [CBU][BK7231N] HLW8112 SPI Power Reading Ratio 1:5?](https://obrazki.elektroda.pl/9865751100_1752686081_thumb.jpg)
![Tuya WiFi Energy Meter PM01_A002 [CBU][BK7231N] HLW8112 SPI Power Reading Ratio 1:5? Tuya WiFi Energy Meter PM01_A002 [CBU][BK7231N] HLW8112 SPI Power Reading Ratio 1:5?](https://obrazki.elektroda.pl/1707987300_1752827411_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 module 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
By 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 with my device,
by compiling the code he wrote from 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.
- links where very complete and presumably working drivers can be found
Subsequently I wanted to try to write my own driver...
Spoiler

This i the link to my repo, in case someone more experienced can tell me what I'm doing wrong

(--> To start the driver, issue "startDriver HLW8112SPI" in the command field of the log console in the Web Application)
It could be that I'm doing something crazy, like buying a logic analyzer and connect it to the SPI in order to understand what goin on when
the original 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.