xoseperez / hlw8012

HLW8012 library for Arduino and ESP8266 using the Arduino Core for ESP8266.
GNU General Public License v3.0
126 stars 48 forks source link

Wrong value for VOLTAGE_RESISTOR_UPSTREAM in examples? #29

Closed mdiazfer closed 2 years ago

mdiazfer commented 2 years ago

Hi there,

I'm wonder if the definition of VOLTAGE_RESISTOR_UPSTREAM in the examples (HLW8012_Basic & HLW8012_Interrupts) is right , as it corresponds to a chain of 5 resistors, 470 Kohms each.

define VOLTAGE_RESISTOR_UPSTREAM (5 * 470000)

However, the datasheet shows a chain of 6 resistors, 470 Kohms each for the V2P pin, so as per my knowledge, the constant definition should be like this:

define VOLTAGE_RESISTOR_UPSTREAM (6 * 470000)

Am I right?

mdiazfer commented 2 years ago

I answer to myself just in case someone else has the same doubt.

In this link, the Sonoff POW is described and it states that the upstream voltage divider for the HLW8012 is configured with 5x4,7 KOhm resistors, so nothing wrong in the example codes, even though it differs from the data sheet circuit example.

Take this into account if anyone is customizing the code examples on your own.