# Struggling with resistance values for reading voltage with Particle Photon

The Particle Photon has a 3.3v max on analogue pins. I’m struggling with figuring out the correct resistance values on reading voltage. I currently have 22k on R2 and 10k on R1 with 470k on R3 and 470k on R4 but with a calibration of emon1.voltage(1, 105, 1.7); my power factor is reading .18.

Particle Photon:
https://docs.particle.io/datasheets/photon-datasheet/

I’m using a transformer with a parallel peak to peak voltage of 17.6.
https://www.digikey.com/product-detail/en/tamura/3FS-410/MT2203-ND/285616

Why is my power factor so low?
Could this be software related?
BTW how do I post code correctly on this forum?

Can we assume your R? component references are from Building Blocks - Measuring AC Voltage with an AC to AC power adapter ?

If so a 22k + 10k voltage divider will give you a 3.2:1 ratio, and with a “peak to peak voltage of 17.6” that would present a 5.5v P-P signal and you say “The Particle Photon has a 3.3v max on analogue pins”.

the “105” is the Vcal (voltage amplitude calibration) without knowing your line voltage it’s difficult to confirm the numbers, but it should be line voltage / transformer output x voltage divider ratio = Vcal, so reverse calculating from the “105” and reported transformer voltage and resistor values, your line voltage would be expected to be ~577.5v P-P (~206vrms) which I strongly suspect isn’t the case, especially as the transformer you linked has a primary of 115v (Which sounds like you are monitoring just one leg if you are in the US).

Given the UK line voltage is double the US (single leg) and 17.6 P-P is similar to the shop AC:AC, I would expect your custom voltage divider ratio to be around half of similar too what you see in the building blocks example eg 100k + 10k since the Arduino ADC’s are also 3.3v. (although the emonTx’s which also work in the US do have a 120k + 10k divider)

The 1.7 phasecal is for the shop sold AC:AC and may be entirely different for your transformer, once you get the voltage divider and amplitude calibration (Vcal) right you will need to do some phasecal calibration using a purely resistive load.

To post code you can use

before and after the block of code

Thanks, yes I’m using the building blocks example. I am using 120V for the input. You’re right my voltage output is to much for the 3.3v. The 10K for R1 and 100K for R2 look right afterall.

I bet I still have a low Power Factor. I’ll try tonight.

It’s difficult to be sure about the calculations as the transformer spec you link to is confusing things as the primary is rated at 115v [hence my incorrect assumption your line voltage was 110v not 120v] and you say the output is 17.6v P-P but the linked spec is for a 2x5v output.

How are you measuring PF? is it a pure resisitive load? how big?

Ideally you need to be sure the voltage sensing front end is correct before even thinking about looking at power factor.

What is your application? why are you using the secondaries in parallel? that would suggest a sizable load, which would most likely impact your voltage signal, plus I’m guessing there is a chance the secondaries have different phase errors which could distort the waveform further.

Power factor is calculated in emonLib (quite properly - it’s the definition) as the ratio of real power to apparent power. If your voltage divider ratio is wrong and the input is clipping, those power values will in turn both be quite wrong, and your value for power factor will be meaningless, as it was calculated from two wrong numbers.

And don’t pay too much attention to the transformer voltage on the spec. sheet. It is specified at full power and with a transformer of that size, I’d expect the unloaded voltage to rise by around 20%, but anything up to 50% is not unheard of.

Reinforcing what Paul wrote, the phase errors in your transformer are anyone’s guess, and until you get true undistorted voltage and current waveforms into the ADC, I wouldn’t even look at power factor.

@pb66 The 17.8 pk to pk comes from my oscilloscope. For clarification on the picture, the bottom left circled 5V shows what each block on the oscilloscope’s grid represents(5V). The Pk-Pk is obviously peak to peak.

The goal is to build an energy monitor that can give me kilowatts and cost per breaker of my home. I looked on digikey for a transformer that could provide an AC output around 5V that I can rectify for DC for simply powering my microcontroller(max input 6.5V for micro-controller), and also hoping to read voltage right off the transformer. I agree the linked spec sheet is misleading, the 3FS-410 transformer is the one I ordered.

How are you measuring PF? is it a pure resisitive load? how big?

I don’t understand what you’re asking here, sorry. The only load on the transformer is the micro-controller.

My goal here is to measure energy from each breaker of my panel and provide a kilowatt/cost per breaker. I’d have a CT sensor on each breaker, including the mains inside my energy panel. To get to kilowatts I need power factor, voltage, current, and a time variable as well i understand that. I guess I should ask am I on the right path to get power factor in this way? Can one power factor reading from this transformer apply for each breaker’s kilowatt usage and inevitably costs?

A few points here.

1. You cannot use the same transformer winding to both supply the power (using a full wave bridge rectifier) and to monitor the voltage. But you can (subject to the distortion that the current pulses drawn by the power supply introduce) use separate windings on the same transformer.

2. “The only load on the transformer is the micro-controller.” That undoubtedly will give you a poor power factor. You should see the calibration instructions in Resources > Building Blocks for how to calibrate properly.

3. You seem to be mixing up power (measured in watts (w) and kilowatts (kW), and energy (Joules, or kilowatt hours (kWh).

You don’t need power factor if you are using emonLib. calcVI( ) will calculate real power, and it’s the time integral of that (kWh) which determines how much you are charged for your electricity. (As I tried to explain above, power factor is a by-product of measuring real power.) You will need to measure the current for each circuit that you want to measure, but you can use a common measure of voltage in each instance. Again, more details are on the “EmonTx - Use in North America” page. Each circuit will have its own power factor, which will vary according to the load that’s connected to it.

1 Like

Thank you for your experience on this @pb66 and @Robert.Wall. Still learning. I understand now I can not monitor voltage and power anything from the same transformer unless I’m using different secondary windings. I was loose on my terminology with kw and kwh as well!

@Robert.Wall you said I don’t need power factor to determine how much I will be charged.

I’m looking at this part of emonLib

float V_RATIO = VCAL * ((SUPPLYVOLTAGE / 1000.0) / 4096.0);
Vrms = V_RATIO * sqrt(sumV / numberOfSamples);
float I_RATIO = ICAL * ((SUPPLYVOLTAGE / 1000.0) / 4096.0);
Irms = I_RATIO * sqrt(sumI / numberOfSamples);
//Calculation power values
realPower = V_RATIO * I_RATIO * sumP / numberOfSamples;
apparentPower = Vrms * Irms;
powerFactor = realPower / apparentPower;

Wondering what is the formula for kwh using real power to end up with cost? Oh… real power is kw so I’ll multiply that by hours used and also cost per kilowatt?

so cost = real power * cost per kilowatt * hours used

That’s correct. (And in emonLib, the unit of realPower is watts.)

Bear in mind that unless the power is constant, you’ll need to add up the kWh in small steps. We usually work in Joules for that (1 J = 1 Ws), so 1 kWh = 3600000 J. Also bear in mind that the time interval between readings is not the delay between readings, so you need to keep a separate record of time to accurately determine the time interval.

Big help. Will try this out.Thanks again.