Arduino simple software setup?

For discussions related to emonPi, emonTx, emonBase and emonGLCD hardware and Arduino firmware

hello I’m new to all this, Please give me if I’m posting this in the wrong Section. My first time on this site. I’m working with the Basic hardware for Monitoring current on my Ac system. I followed this page here. So far everything is current. I have the same hardware as far as current sensor, Resistors and caps. My skills lay in hardware not software. But I’m learning as much as i can.

I have tired the arduino code that is on the page with the library. I do notice where the voltage is at in the code originally it was set for 230v. So i changed it to my voltage which I’m in the USA at 120v. However i do not know how to do the Calculate for this line
double Irms = emon1.calcIrms(1480); // Calculate Irms only. Can someone please help me. My ac unit the breakers are at 30a.

Joseph

Hello i forgot one last thing there is another section that says
emon1.current(1, 111.1); // Current: input pin, calibration.

I think the first 1 follow by , is the arduino analog pin. but I’m not sure what the 111.1 is for?

Joeph

“1480” is the number of samples to average to give you a reading.

When you use calcVI(…) to measure power, it measures a whole number of cycles of mains voltage - because it has a voltage input. This is the best way we have found for accurate results.

You are not using the voltage input, therefore all you can do is guess how many samples your Arduino will measure in a whole number of mains cycles. For you, one cycle is 16.667 ms, and we aim to measure for 200 ms, so 12 cycles.

We have found that the sampling rates, measured with a standard emonTx V3.4 (and the emonPi and Arduino Uno have the same processor) are:
  calcIrms( ) - approx 5588 current samples per second.
  calcVI( ) - approx 2535 pairs of voltage & current samples per second.

“1480” is out of date - we’ve speeded up the calculations since that was written. The ‘best’ number now is 1118. There’s more information here:

Sampling rate of emonLib

“111.1” is the calibration constant. In numbers, it is the current in the c.t. that gives you 1.0 V at the ADC input. So it depends on the c.t. ratio (100 A : 50 mA) and the burden resistor you’re using (18 Ω).

Hello Robert, thank you I’m all to new to this. But i will get there. This is a little over my head. however this is what i got. Sense I’m using a 33ohm for the burden resistor I get 2.5v out of it. Also I’m using the two 10k Resistors.as well as the 10uf cap. If this is all out of date. I will try to update to the latest library. One thing is i do not have a 18-Ohm resistor for the Burden resistor.

Can i still use the 33Ohm resistor for the new library and just adjust the code for it?

Joseph

You get 2.5 V peak, but about 1.6 V rms, out of it. Any more than that and you will overload the Arduino input.

No this is up to date - it was the sample sketch that is out of date, and only that one number is, not wrong, but not the best value.

You don’t need that with the YHDC SCT-013-000 c.t.

Yes. The calculation is: What is the maximum current that you can measure?
Answer: 100 A rms.
What secondary current will you then get out of the c.t?
Answer: 50 mA.
What value of burden resistor will give you 1.6 V rms (= a little less than 5 V peak-peak) at 50 mA?
Answer: 32 Ω. Using a 33 Ω resistor means that, on a bad day if you have a c.t. that gives you a little more than 50 mA and your Arduino’s 5 V is a little low, and your 33 Ω resistor is a little high in value, you won’t be able to measure quite up to 100 A. I don’t think that will be a problem.
The only code you need to adjust is the calibration constant. To find out what it should be, work the maths backwards:
1 V at the Arduino input requires 30.303 mA flowing in the burden.
To get 30.3 mA out of the c.t., you need 60.6 A flowing in the primary winding - and the primary winding is in fact the wire that you’re measuring the current in. So for your c.t. and the 33 Ω burden and a 5 V Arduino, the calibration constant should be 60.606.
If your burden isn’t quite 33 Ω, or the 5 V is slightly out, or the c.t. ratio is a bit off, that number might be wrong by a few percent.

Hello Robert thank you. It is a little over my head as far as programming and calculating what i need. Okay so i did find a 18Ohm resistor and the two 10k Reistors. Where do i find the newest library please?

Joseph

You HAVE the newest library. EmonLib has not changed for many years now.
I wrote:

If you must download emonLib again, it is here: GitHub - openenergymonitor/EmonLib: Electricity monitoring library - install in Arduino IDE's libraries folder then restart the IDE

Ahh Okay. I just don’t know how to calculate for my Power it is something i never did before or know how to do. Can you help me with that please? I can change the hardware but I’m not no where close to actually figuring out the programming side.

Joseph

Have you read all of the section in ‘Learn’ where you found the sketch you are using? That explains the hardware you need and the calculations.
https://learn.openenergymonitor.org/electricity-monitoring/ac-power-theory/introduction
is the place to start.