Connected power meter

A few weeks ago a user came with a request to add support in ESPurna to a power meter that had been hacked by Karl Hagström. It is a very cheap chinese power meter with plenty of room on the inside, enough to house an ESP8266 module and a DC/DC power supply and the main IC protocol had been reverse engeneered. There even was a repository by the Harringay Maker Space with sample code for an arduino compatible platform.

I found it really interesting so I jumped in and ordered two of them (for 25,20 euros in total). Unfortunately the seller I bought it from has ran out of them. But you can still find them on the usual market places, like these ones [Ebay] or (also with non-EU variants) these ones [Aliexpress].

When I received them I quicky unscrewed the enclosure of one of them and… wow, it looked slightly different than that on Karl’s post but also different from the one the people at Harringay Maker Space had worked with.

p1240281s p1240279s

I went back and forth and I noticed the hack was almost 2 years old and the board was clearly different: different version (unlabelled on Karl’s pictures, version 2014-04-28 on Harringay’s power meter and 2016-12-18 on mine), different board layout with a different connector between the power meter board and the display (7 wires on theirs, 6 on mine). But the most important difference was the main power meter IC. Karl had reverse engineered the ECH1560 on his power meter, a 24pin SOP package (on the back on his device, on the front in Herringay’s power meter). Mine was only 16pin…

p1240274sI had to decipher the IC mark using parts from both devices since the manufacturer had crossed out the marks (they don’t want us to hack it or what?). Finally my best guess was V9261F. I quicky googled it and… bingo!

You will (almost) never be the first one

The Domoticz community is quite active. And they were already working on supporting this device. Actually the datasheet for the Vango V9261F [datasheet, PDF] is public (contrary to that on the ECH1560). So I just had to “borrow” the work from two of the domoticz community members (kudos to Kapee and Rolo)  and continue from there.

The hack, like with Karl’s method, is based on sniffing the traffic between the power board (where the V9261F sits) and the display board. On this new version there are 6 cables labelled (RX, TX, FREQ, VDD and GND, the sixth is unlabelled). So it strongly looked like being a serial interface. All they had to do was to wire the TX pin to a GPIO in the ESP8266 module and use a software serial library to receive the messages.

The messages looked something like this:

FE 11 01 04 00 00 01 1D 
FE 11 04 6B E5 FF FF 74 BF FF FF 70 5C E2 3A 00 30 02 00 86

There are two messages there, both are responses to a read operation. The first one returns 1 register (each register in the V9261F has 4 bytes) and thus has 3 bytes for the header, 4 bytes for the register and 1 more byte for the checksum, totalling 8 bytes. The other response contains 4 registers and has (3+4*4+1) 20 bytes. The key here was knowing what registers where those. Unfortunatelly the response does not specifiy the register address, only the contents. But as easy as sniffing the TX line, one can sniff the RX line. This is what the microcontroller in the display board requests to the V96261F:

FE 11 80 01 00 00 00 A2
FE 11 19 04 00 00 00 06

Great, so it first requests the SysCtrl register (0x0180, not very useful for us) and then 4 registers starting with 0x0119. What registers are those? Let’s check the datasheet:

  • 0x0119: Average total active power
  • 0x011A: Average total reactive power
  • 0x011B: Average total voltage RMS
  • 0x011C: Average total current RMS

So good 🙂

Wire it

Rolo, at the Domoticz forum has shared a schematic to isolate the TX pin from the ESP8266 module using a PC817 optocoupler [Ebay]. I thought it was a good oportunity to use those “old” ESP01 modules I never use so I prepared a stripboard using his schematic as starting point.

The ESP01 module is supposed to be connected with the antenna to the right, over the PC817 optocoupler

The ESP01 module is supposed to be connected with the antenna to the right, over the PC817 optocoupler

The schematic assumes you power it with a 3V3 source. In the first term I used a 5V source so I had to add a AMS1117-3V3 to the power input. Anything capable of supplying 400mA peak should be enough.



The power source and the ESP01 module and “carrier” board. The blue cable is soldered to the TX pin in the power meter board.


For the second powermeter I used a wemos board, which simplifies the connections. Basically you just need the optocoupler and the input resistor.




You might have noticed I also used two different power sources. Again, you will need 400mA output to be safe. HLK-PM01 [Aliexpress] modules are great for that, but cheaper “open” AC/DC 5V 700mA power supply modules [Aliexpress] will also work.

It is very important that you double check the connections and the weldings. Also, once you have tested it and you want to close the box, hot glue everything so they stay in place. Trust me. You don’t want a wire going loose there.

Support in ESPurna

The ESPurna firmware is released as free open software and can be checked out at my Espurna repository on GitHub.

Final step was to integrate the code in ESPurna, so it will benefit from other “goodies” in the firmware (MQTT, REST API, Home Assistant and Domoticz support, WebUI, WiFi configuration, etc). The firmware reports “real time” values (every 6 seconds) to the web client and aggregated (and filtered) values via MQTT to other services.


But one bonus that comes with ESPurna is the calibration feature. Because there are some calculations involved in getting the power value from the number the V9261F provides. Same for current or voltage. And there are some “magic numbers” on those calculations. I have not been able to find out what those numbers should be. In section 5.13 of the datasheet talks about calibration registers and formulae but I can’t figure the numbers out…

So instead you can use the power section in the Web UI to calibrate the values you are getting. You are not supposed to write there those “magic numbers”. Instead, you have to write the values the power meter is displaying on the screen and the firmware will do the maths for you.


The power calibration tab allows you to introduce the “expected” values for power, current and voltage.

But, what about the ECH1560?

Yeah! That was the first idea. I decided to add support for the ECH1560 in ESPurna too. But this is completely untested and it will almost certainly have bugs. So if you want to give it a try, be ready to debug.

You will have to wire two cables now, instead of one. One for the CLK pin and the other for the MISO line. Use optocouplers too, you’ll stay safer. There is already a device in ESPurna for the ECH1560 (called GENERIC_ECH1560) that assumes the CLK pin is on GPIO4 and MISO on GPIO5. If your setup is different you might want to change the definitions in the hardware.h file:

// -----------------------------------------------------------------------------
// ECH1560
// -----------------------------------------------------------------------------

#elif defined(GENERIC_ECH1560)

    // Info
    #define MANUFACTURER        "GENERIC"
    #define DEVICE              "ECH1560"

    // ECH1560
    #define ECH1560_CLK_PIN     4
    #define ECH1560_MISO_PIN    5
    #define ECH1560_INVERTED    0

Also, some people has reported their power values are inverted. If you are getting weird power values try changing the ECH1560_INVERTED setting to 1.

Good luck and report back!

CC BY-SA 4.0 Connected power meter by Tinkerman is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

12 thoughts on “Connected power meter

  1. Pingback: ESPurna Firmware Now Supports Power Meters “Augmented” with ESP8266 Modules/Boards

  2. David

    Hi Xose,
    Very interesting post!
    i’m not someone with much knowledge in electronics, but i would like to know why have you used an optocoupler ?
    Best Regards

    1. Xose Pérez Post author

      The optocoupler is used to isolate both cirucuits (the powermeter board and the ESP8266 circuitry). This way you can still communicate info from the V9261F to the ESP8266 without a physical wire connecting them. Since you are working with mains it’s a nice safety option.

    1. Xose Pérez Post author

      I have just uploaded it: espurna-1.9.4-wemos-v9261f.bin. It expects the TX pin in the power meter board to be connected to GPIO2 (that’s D4 for the Wemos D1 mini). I do recommend to use the optocoupler in between.

      1. Richard

        thnx. So only wemos d1 mini is required an resistor 680ohm and the optocoupler.

        I just ordered so parts. I let you know if its working

        1. Xose Pérez Post author

          It will work without the opto and the resistor but I strongly recommend to isolate both circuits. But yes, for the Wemos that’s all you need to monitor the TX line.

          1. Richard

            Hi I received the components and the power meter , and it is a ECH1560 .

            I want to test it but I need the images for de wemos. Can you also place the image for the wemos d1 mini for the ECH1560?

            As I read, I must CLK pin to GPIO4 and MISO to GPIO5 and gnd to gnd wemos

            Must I also put the resistor and optocoupler between? And where to put it?

          2. Xose Pérez Post author

            Beware that the code for the ECH1560 is based on the work of different people and untested. I’ve placed the image for the wemos with ECH1560 in the downloads section of the repo. Using the optocoupler is safer, but not necessary. You will need two of them (some IC have dual optos).

  3. Pingback: #Hack : Sonoff 4CH Pro avec le firmware MQTT Espurna, inclusion dans Domoticz (Partie 1 : installation d'une image pré-compilée) - Projets DIY - Domotique et objets connectés à faire soi-même

    1. Xose Pérez Post author

      You can find the code in GitHub, it’s linked in the post. If you only want the binary browse to the “releases” section in the repo.


Leave a Reply (all comments are moderated, be patient)

This site uses Akismet to reduce spam. Learn how your comment data is processed.