I'm not using a relay. I'm trying to measure the mains.
your voltage input appears to be connected to the relay coil. this is not the mains.
need to remove that relay. it is causing problems.
you do not have anything running in the CT to measure.
all you will get is stray values until you fix the inputs to be connected to the mains and run a current through the CT
What it looks like a relay is actually a PCB 220V -> 9V transformer. Really small.
Just measured the output of the CT and voltage parts and I'm getting 2.265 V on both outputs. An adjustable resistor should do the trick.
Update:
I've replaced the voltage reference divider with suggested 100k and 10k and instead of one 470k resistor I've used a 330k resistor and a 100k adjustable resistor. Now I have exactly 2.5V on the outputs of both references.
I still can't get the power factor right. I tried with a 100W soldering gun and the max I get is 0.43 with the required calibrations.
If the 5volt is constant, so is the 2.5volt midpoint.
You said you have a "5volt only" Arduino, so feed it with a regulated 5volt supply.
e.g. a 5volt cellphone supply with microUSB lead.
This is from the Yún spec sheet: It is recommended to power the board via the micro-USB connection with 5VDC.
Leo..
Either way, same results. Power factor still won't go up.
You should have zero power on your display when no power is drawn from the mains.
Is that correct, or do you still have random values.
With a passive current transformer, resolution is VERY low.
You won't see anything on the display untill you connect a user that is drawing several hundred watts.
You only have ~350 steps of resolution with a 10bit A/D. (1024/2)x0.7
Leo..
Is there anything I can do about the resolution?
You have to use those 350 steps as good as you can.
Your current transformer has to output 1.75volt (1750mV) at the maximum expected current of the user.
(1.75volt is the square root of 2 of the midpoint voltage)
The ASM-030 CT produces 55mV at 30A.
That's 1.83mV (=2.59mV top) per amp.
One arduino step (with midpoint) is ~10mV.
So 4Amp is just seen as one step.
Amplifying the sensor output first fixes this.
Leo..
Right now the CT's specs are same as the yhdc 013 030 from the original guide, with an output of 1V at 16 amps. That can be adjusted with the right burden resistor.
I Just gave you the ways to calculate things.
Up to you how you want to use it.
Leo..
The ACS712 is an active sensor but as I read or as you mentioned, it's very noisy. So that leads me to same results, I recon.
Yes, did not realise that.
I see noise is 11mV for a 20A version.
Not a big problem if you have to measure large users, but it can be with small users.
Why don't you add an opamp to your current transformer.
Crank it up to 1750mV.
Still don't know what maximum current we are talking about.
Single user, or whole house.?
Leo..
Single user, max 15A.
The yhdc 013 030 current sensor has 500mV output at 15A (datasheet).
That's exactly 100 digital steps per 15A. =150mA/step. = 34.5watt/step (on 230v mains).
That is the threshold. Below that, nothing is detected.
You can lower that with an opamp to 10watt/step. Opamp gain = 3.5x
Don't know how the software reacts to low loads.....
I guess.... you need at least an amp for a meaningfull current/Pf reading.
Also don't know if the current/voltage phase relation is solved in software.
You might have to try flipping the mains wires to the voltage transformer (or flip the current clamp).
Leo..
Flipping the current clamp will result in negative values.
I was wondering what if use an already made energy monitor IC and connect the output with the arduino so the board will be in charge of only streaming?
You probably will face different problems.
Better to work this one out first.
Split it up in two.
1/ Can you calibrate the voltage reading. Is is accurate. Resolution should be ~1volt.
2/ Can you calibrate the current reading. Use a resistive load, like a 1000- or 2000watt heater.
Then think of the power factor.
Leo..
there are two steps that would help greatly.
#1) as has been mentioned multiple times. add an op-amp, or more correctly, a precision rectifier.
this will give your a much higher resolution of your amp reading.
B) use an op-amp as an AC amp, and not a rectifier. you can adjust the output to swing from 5 to 0 and use half of the range of the 10 bit ADC in the Arduino.
#2) use a higher ADC. the Teensy has a 16 bit ADC, I think 13 bit available ? not sure about the loss of performance.
I think there are other suppliers of 16 bit ADC chip that connects to the Arduino. using the teensy eleminates some of the lag with serial buss operation.
The transformer you are using is not suitable for a voltage probe.
Have a look to the waveform (attachment picture). You cannot get anything accurate. Use a larger one (x10 the VA you are using, as recommanded on openenergymonitor website), or a specificaly designed one (far better in terms of linearity and phase response !).
It's hard to see because of parallax, but it seems to me that the secondary winding is not connected (shifted by one column on the breadboard). Check that.
If you don't want to use an amplifier, just choose the correct current transformer. For example, with its recommanded 250 ohm burden, the DL-CT1005A is just fine for 10 amps, its ratio is 2000:1 with one turn on the secondary (other models for larger currents if you want) ; no need for anything (except the burden) : no divider, no amp, and it gives very accurate results (verified). Easy to find and very cheap from eBay. Needs an external burden (far better, as you can play with its value, but keeping in mind that the recommanded value will be the best for linearity and phase : the secondary + burden = LR filter). Important : a current transformer must never been connected without a burden : connect burden first, then mains. Without a burden, high voltage is generated as it tries to push current (kind of current source) : this could destroy the secondary winding by internal arcing.