esp32 power meter for sensors with pulse output. Implements MQTT for status reporting. Accurate and easily can be integrated with Home Automation systems.
Are you sure it works properly? Looking at void IRAM_ATTR isr() function, it takes the time of the first pulse, then waits for the seconds and counts power. This part looks ok. Then after power is counted, it sets bPulseDetected to false. This means, that when third pulse comes, it doesn't count the power, only starts waiting for the fourth pulse. Looks like it should miss about half of power consumption this way.
Am I missing something?
I managed it to run it on a WT32-ETH01 Board (using Ethernet), it is sending MQTT packages as expected.
Only the readout is constantly 1800W, no matter what's happening (Hi/Lo) on Pin 18 (According to IO4 on my board).
These would be 2 pulses/second (my counter has a PULSES_KWH_RES 1).
Do you know a bug or a process, which could trigger the Interrupt exactly two times a second?
Hi. I need some help.
Want to add this meter to HomeAssistant and am having problems.
Those are impulse specs:
Pulsfrequenz: 1000 imp/kWh
Impulsdauer: 32 ms ±2 ms
Bemessungsspannung DC: 27 V max
Schaltstrom: 27 mA max
I was able to program the microcontroller and i am able to ping it.
Have changed in .ino file:
#define IN_PIN_PEM 18 /* input pin for pulse sensor /
#define IN_PIN_TMP 2 / input pin for DS18d20 temperature sensor /
#define ISR_TYPE FALLING / isr triggering mode /
#define HOUR 3600.0 / hour as constant /
#define PULSES_KWH_RES 1 / 1 KW = 1000W, power meter has 2000 (0.5) inpulses resolution /
#define SECOUND_ISR_PERIOD 0.032 / pulse period is ~90 ms (32ms), used to ignore secound interrupt arrival bug*/
#define MAX_POWER 7040 /* for a peek of 32A => 7040W, ignor higher measurements */
And I get nothing. Also have problems with HomeAssitant I can not get this MQTT working. _Have mosquito installed also devices from Tasmota are working ok. Have paste the config into .yaml and nothing.
I am using ESP32 WeMos LOLIN32 Lite. But it is the same as yours basically.