xoseperez / espurna

Home automation firmware for ESP8266-based devices
http://tinkerman.cat
GNU General Public License v3.0
3k stars 638 forks source link

Adaptation of a new socket (Girier JR-ZPM01) #2545

Open GitJa21 opened 2 years ago

GitJa21 commented 2 years ago

Device

Girier JR-ZPM01

Version

1.14

Question

Hello! Once I bought a Girier JR-ZPM01 smart socket. It contained an unsupported and non-flashable module from TUYA CB2S. After doing some research, I came to the conclusion that the module can be replaced with ESP-01M with espurna from SonOff Pow R1. In general, it worked great. The only thing that did not work is the measurement of power consumption. Surely, the values of the resistors did not match. Is there some way to tune in measurement? The measuring chip is BL0937.

Table of matching pins: Pins Approximate scheme: MySocket Old WiFi module: OldModule (CB2S) Web interface (400W heater) WebInterface Appearance of the socket (With my mod): 1 2 3

P.S. Due to some bugs in version 1.15, I'm use version 1.14 I wanted to download and edit the source code by myself but nothing succeeded. There are a lot of compilation errors due to the lack and mismatch of libraries. :(

mcspr commented 2 years ago

Build options are prefixed with HLW8012_..., see sensor .h; both resistance it ratio should be there. hardware .h includes overrides, so you could check out the values used on Blitzwolf devices. Usually, default resistance is used to generate the ratio value which we later adjust. I think WebUI has 'expected' current / voltage / power form somewhere on the SENSOR page?

(just note that 1.14.1 settings may cause everything to read zeroes if ratios accidentally switch to 0 when settings reload)

For older version specific settings are - pwrRatioC (current), pwrRatioV (voltage) and pwrRatioP (power) control ratio. A more recent version switches to currRatio0, voltRatio0 and pwrPRatio0.

I wanted to download and edit the source code by myself but nothing succeeded. There are a lot of compilation errors due to the lack and mismatch of libraries.

If you are building with PlatformIO, there should be no library mismatch. Also note you don't have to get VSCode and / or extension, just have a Python installed and do a pip install platformio. After that, just use pio / platformio cli command.

Arduino IDE is technically supported, but it may break from time to time since it does not have a way to store library info for IDE to use besides storing .zip as-is in the repo (which sort-of works for PIO side, with yet another set of quirks)