i would like to display all power, current ,voltage and power factor in one serial monitor of two current sensors(ct1, ct2) from my emontx shield, how could i edit the code in the sketch of emonTXshield)CT1234_voltage
thanks
Archived Forum |
|
emontx shieldSubmitted by Guest on Thu, 19/09/2013 - 11:35i would like to display all power, current ,voltage and power factor in one serial monitor of two current sensors(ct1, ct2) from my emontx shield, how could i edit the code in the sketch of emonTXshield)CT1234_voltage thanks » |
Re: emontx shield
It is all done for you.
You have four instances of EnergyMonitor already defined, and you will be using the first two (or any two): ct1 & ct2.
After you call the method ct1.calcVI(20,2000) (and the same for ct2), you will have the public attributes available to send to the serial port. These are listed in line 41 of emonlib.h - the comment "//Useful value variables" is a hint for you, and you send them like this:
Serial.print("Real Power = "); Serial.println(ct1.realPower);
If you want to send them to an emonGLCD or to emoncms, you must extend the payload structure PayloadTX and copy each into that, just like:
emontx.power1 = ct1.realPower;
but remember all the values in PayloadTX must be integers, so you must multiply powerFactor by 100 or 1000 to make it an integer, then divide by 100 or 1000 at the other end. And similarly if you want the voltage to better than 1 V precision.
(And if you have an emonGLCD, you must use the new payloadTX in that sketch as well.)
Re: emontx shield
so it would be the same for current,voltage and power factor just like:
Serial.print("current= "); Serial.println(ct1 Irms.);
Serial.print("voltage= "); Serial.println(ct1 Vrms.);
Serial.print("power factor= "); Serial.println(ct1.powerFactor.);
put them after Serial.print("current= "); Serial.println(ct1 Irms.);
for both ct1 and ct2?
if i want to send them to emoncms, i should do like:
emontx.current1=ct1.Irms;
emontx.voltage1=ct1.Vrms;
emontx.powerfactor1=ct1.powerFactor;
Re: emontx shield
also in the orginal sketch, for ct1, there is a line of code like this :
emontx.Vrms = ct1.Vrms*100;
but for other 3 CTs there is nothing.. and also
Serial.print(" "); Serial.print(ct1.Vrms); is only for ct1 what about other CTs
thank you
Re: emontx shield
1.Yes, you have that roughly right, but not exactly. Read what I wrote again, carefully.
2. You only have one measure of voltage! The voltage is measured each time, but not displayed. If you are concerned about a small change between reading the first c.t. and reading the next 20 cycles (0.4 s) later each time, you can repeat those lines for the other c.t's.
Re: emontx shield
i think
Serial.print("current= "); Serial.println(ct1 Irms.);
Serial.print("voltage= "); Serial.println(ct1 Vrms.);
Serial.print("power factor= "); Serial.println(ct1.powerFactor.);
they are correct
but
emontx.current1=ct1.Irms;
emontx.voltage1=ct1.Vrms;
emontx.powerfactor1=ct1.powerFactor;
which shows me the errors. so the sketch can only send real power to emoncms, i think my problem how to make current, power factor, Vrms to be sent to emoncms by editing the code.
Re: emontx shield
"you must extend the payload structure PayloadTX" This is the first part you missed.
"remember all the values in PayloadTX must be integers, so you must multiply powerFactor by 100 or 1000 to make it an integer, then divide by 100 or 1000 at the other end." That is the second part you missed.
Do you know how to interpret the compiler error message? When I deliberately make the first mistake that I think you have made, I get:
emonTxShield_CT1234_Voltage.ino: In function 'void loop()':
emonTxShield_CT1234_Voltage:108: error: 'struct PayloadTX' has no member named 'powerfactor'
What is it trying to tell you? What do you think you need to do to put it right?