# How do I measure Apparent and Reactive power with an EmonPi?

I’m looking to get Reactive power from the Emonpi I have set up. Is there a simple way of calculating it or could I calculate Apparent power subtract real power and multiply by the power factor?

I have just noticed this post so would I be able to do similar for reactive power ?Power factor on Emoncms from emonPi - #2 by Robert.Wall

Any help would be great thanks,

J

emonLib, which is what the emonPi uses for the power measurement and calculations, doesn’t attempt to measure the reactive component. It only computes the average real power, rms voltage and rms current; and it’s from the latter pair that apparent power is calculated. All those values are available, but as you read, only rms voltage and real power are used.

Provided that the power factor remains close to unity, you could use Pythagoras’ Theorem on real and apparent power, but as the power factor gets lower, the errors will increase very rapidly, and in any case you have no way of knowing the sign (capacitive or inductive) of the reactive power.

This emonTx sketch (?) might help. Porting it to the emonPi might be feasible, but there’s every indication that maintaining all the other things that the Atmel 328P does at the same time - particularly handling the r.f. traffic - could well prove to be an insoluble problem.

Thanks for the reply, I’ve written in the code to get apparent power and the power factor but I don’t know how to compile it?

I was originally going to use the Arduino IDE but thought it might be easier just to write it straight in using the nano function.

J

You still need to compile it, even if you edit the source file in situ, and then upload it to the Atmel '328P

My crib notes have a link to the full procedure to edit the emonPi sketch & reload:
Power factor on Emoncms from emonPi - #2 by Robert.Wall

That was for somebody who wanted to extract Power Factor - that’s close enough to what you want to do for you to be able to follow.

There have been recent changes to emonCMS, so I’m not certain that this is still totally accurate - that depends somewhat on how up-to-date your emonCMS is.

Hi Robert,

I have compiled it using the Arduino IDE and when I try to upload the hex file it fails for some reason. I may be doing something simple wrong.

“\$ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:sketch_name.hex”

I’m using this code but my sketch name is “src.ino.hex” would that be a problem? and I’m also doing it over a SSH so I dont know if that is effecting it.

This is the output I’m getting.

Reading | ################################################## | 100% 0.00s

avrdude-original: Device signature = 0x1e950f (probably m328p)
avrdude-original: safemode: lfuse reads as 0
avrdude-original: safemode: hfuse reads as 0
avrdude-original: safemode: efuse reads as 0
avrdude-original: NOTE: “flash” memory has been specified, an erase cycle will be performed
** To disable this feature, specify the -D option.**
avrdude-original: erasing chip
avrdude-original: error opening src.ino.hex: No such file or directory
avrdude-original: can’t determine file format for src.ino.hex, specify explicitly
avrdude-original: read from file ‘src.ino.hex’ failed

avrdude-original: safemode: lfuse reads as 0
avrdude-original: safemode: hfuse reads as 0
avrdude-original: safemode: efuse reads as 0
avrdude-original: safemode: Fuses OK (E:00, H:00, L:00)
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe

avrdude-original done. Thank you.

strace: |autoreset: Broken pipe

I’ve also tried renaming the file but to no avail.
Any help would be great thanks,

Jack

That is saying it can’t find your file. All the following errors don’t mean much. Do you need to specify the full path? That would be my first move. Looking at it, that command seems to assume it’s being run inside the Pi, and that the hex file is in the current directory. If that’s not the case, then it will fail. But I don’t know what you were doing with SSH, or even if it can execute a command and transfer the file at the same time. I’d suspect not.

Other than that, I’ve no idea. I think I’ve only ever done it once, and that was a long time ago, so I can’t remember. But I do know that I’ve pointed people at those instructions a few times, and they’ve worked. So unless something’s been changed and nobody’s updated the Wiki, I don’t know.

That’s fine, I’ll connect to the Pi directly and see if I can sort it.

Thanks again

J