Continuous measurement of time between pulses may be a a heavy demand on an ESP8266 firmware, and I doubt the accuracy ...........
It is not difficult to get Watts (W) if you have WattHours (Wh):
see
https://www.rapidtables.com/convert/ele ... -watt.html
It only requires a certain mindset & accuracy to arrive at a practical solution, although always a compromise, as explained below.
Your energy-meter calculates the energy by multiplication of Power and Time => Wh
Your S0-interface (at 1000 pulses/kWh = 1 pulse/Wh) reports each passing Wh as a pulse.
If you count pulses for a certain time t, the result of the multiplication is the Energy E produced in that time t, with E expressed in amount of Wh.
Calculating backwards, then you can deduct the
average Power (in W) produced during that time t, because P,avg = E/t.
For correct results, you have to be careful to have the 'magnitudes' correct: see the quoted URL!
The 'compromise' is caused by the following aspect:
- if you take time t long, then you usually have plenty of pulses within interval t, giving a stable calculation, but you miss the real, instantaneous actual power due to the averaging process.
- if you take time t very short, then you get closer to actual power, but the division E/t may produce strange results due to the small number of pulses divided by a short time-value.
Pragmatic, simple solution: take time t = 6 minutes.
Not too slow and also practical, because it is 10% of an hour, and therefore
relatively easy to check whether your calculation is correct.