For power measurments :
You will need to Claculate VRMS, IRMS ,Power factor & Power
Power (real power ) =VRMS * IRMS * PF
Lets start with current :
There's 3 methods for current sensing
"Shunt resistance , Rogowski coil & hall effect "
to know which one to choose see this question Shunt Vs Rogowski
Also for shunt resistance connection & circuitry check this Shunt structure
,any way whether you used shunt or Rogowski , you will take the output of this sensor into
an ADC , the ADC will give you samples , in your MCU you will make an equation that transform the ADC reading into a real signal , i.e if the reading was X=0.5 then it will match a Y= 7 Ampere at the real signal
Then for finding the IRMS , you will collect those reading in a buffer say buffer length [64] sample , after the buffer is full
sum (sample * sample) "Square & sum them" , then divide them by their number (64) , later take the root mean square
So
IRMS= Sqrt(Sum(Sample*Sample)/No of samples)
The more samples you take the more accurate result you will obtain,
Also this topic will explain another method for it "Ac measurements "
Now lets move to voltage:
For voltage measuring , you will need a simple voltage divider
& then take the ouput signal to a ADC , do the same calculations you as you did in IRMS
to find the VRMS
So
VRMS= Sqrt(Sum(Sample*Sample)/No of samples)
After you done now you have VRMS & IRMS .
SO we need to find P(average power = real power )
P= VRMS * IRMS * PF
, so we need the power factor
For power factor you will have to detect the zero crossing of current or voltage , then after you detect it , use a timer in the MCU to count how many "usec" between the voltage & current zero crossing ,
Now you have the difference between them , use math & you will have PF
So , finally you can calculate Power ,
For power :-
You will accumulate them & divide by number to get KWH & so on .
It happened I've been building a system like this & asked a lot here in stack , so this what I got till now .
The reason why I didn't mention Hall effect sensor that it is expensive .
A simple algorithm to find VRMS or IRMS :-
1-X = function(ADC_Reading) ; // Equation to take back the reading to original
2-Sum+=X*X;
3-Is this sample number (64,128...) if yes go to 4, if not go to 1
4-Y=sum/(64,128,...)
5-IRMS or VRMS= sqrt(Y)
6-Reset All & repeat
Further step in your system , you will have to make a calibration because you want less error in reading & so on to achieve a better accuracy , it happened I asked for this on stack to
Calibration