pkarun / Blynk-PZEM-004T-v3.0-Multiple-device

Blynk ESP8266 (NodeMCU) Program to connect multiple PZEM 004T v3.0 Power Meter.
9 stars 4 forks source link

Half reading 32 bit register #2

Closed sandroxGH closed 3 years ago

sandroxGH commented 3 years ago

The current power and energy have 32 bit register with "nodeX.getResponseBuffer(0xXX)" can read only 16 bit is correct? I think it looking the energy counter some time restart from 0 after have count 66.

Renato-REDS commented 3 years ago

Olá @sandroxGH,

você está certo, eu também tive o mesmo problema. Para você ter a leitura completa dos valores de potência, energia e corrente em 16 bits, troque as linhas:

current_usage_1 = (node2.getResponseBuffer(0x01) / 1000.000f); active_power_1 = (node2.getResponseBuffer(0x03) / 10.0f); active_energy_1 = (node2.getResponseBuffer(0x05) / 1000.0);

para: current_usage_2 = (node2.getResponseBuffer(0x01) | (node1.getResponseBuffer(0x02)) << 16) / 1000.000f; active_power_2 = (node2.getResponseBuffer(0x03) | (node1.getResponseBuffer(0x04)) << 16) / 10.0f; active_energy_2 = (node2.getResponseBuffer(0x05) | (node1.getResponseBuffer(0x06)) << 16) / 1000.0f;

assim quando os valores forem maiores, você irá conseguir ler sem problema. (sem o falso 0).

Espero ter ajudado.

sandroxGH commented 3 years ago

Sí, lo resolví a tu manera. Gracias por el apoyo, espero que también ayude a otros.

Il giorno lun 27 lug 2020 alle ore 20:39 Renato-REDS < notifications@github.com> ha scritto:

Olá @sandroxGH https://github.com/sandroxGH,

você está certo, tive o mesmo problema. Para você ter a leitura completa dos valores de potência, energia e corrente em 16 bits, troque as linhas:

current_usage_1 = (node2.getResponseBuffer(0x01) / 1000.000f); active_power_1 = (node2.getResponseBuffer(0x03) / 10.0f); active_energy_1 = (node2.getResponseBuffer(0x05) / 1000.0);

para: current_usage_2 = (node2.getResponseBuffer(0x01) | (node1.getResponseBuffer(0x02)) << 16) / 1000.000f; active_power_2 = (node2.getResponseBuffer(0x03) | (node1.getResponseBuffer(0x04)) << 16) / 10.0f; active_energy_2 = (node2.getResponseBuffer(0x05) | (node1.getResponseBuffer(0x06)) << 16) / 1000.0f;

assim quando os valores forem maiores, você irá conseguir ler sem problema. (sem o falso 0).

Espero ter ajudado.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pkarun/Blynk-PZEM-004T-v3.0-Multiple-device/issues/2#issuecomment-664569543, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3P44XNPCC2XXMYZAHEABDR5XCXFANCNFSM4PHPM36A .