emonTX and RFData

Hry Guys,

 

I have setup and configured my emonTX, emonGLCD, and emonCMS.

Currently the the emonTX only sends the following payload  {power1, power2, power3, Vrms; }

I want to also be able to read the power factor and any other valuable data, 

I am using hte emonTx_CT123_Voltage and can not see where it's getting the Pf from. 

 

Also I want to understand how do I calibrate the unit to get the best result..... this link in the sketch is not valid.

http://openenergymonitor.org/emon/modules/emontx/firmware/calibration

 

Robert Wall's picture

Re: emonTX and RFData

"how do I calibrate the unit to get the best result..... this link in the sketch is not valid."

Really?  The one you posted above works for me. I've recently sent Trystan a (hopefully) improved and enlarged version so that should appear soon.

Power factor is calculated in emonLib right at the end of EnergyMonitor::calcVI( ).  It's public, so you can pick it up as ct1.powerFactor and put it into your payload (make sure all 3 ends use the same payload struct!).

warlock's picture

Re: emonTX and RFData

Thanks Robert,

Really strange I tried that link last night and again before I posted and it was not working, Just checked it now and seem to be fine. 

 

As for the Power factor thank you for the information, I' give it a ago.

 

I just have to say, before I bought into the emon devices I was using TheOwl and also tried the eFergy and found them to limiting, After uploading the sketches last night I am very happy to report it was definitely the correct way to go.

Once I have the emonTX correctly configured and emonCMS setup, I'll be looking a controlling the solar pump for my solar water collector. The beauty about this system is that it's virtually limit less and not locked down to the vendors code... If I don;t like something I just change it.

Last one, does anyone use anything special to design their icons for the LCD, like an app or something ?

thanks again

 

warlock's picture

Re: emonTX and RFData

ok I manager to get the powerFactor displayed in the Serial Console by doing the following in the emonTX sketch

emontx.powerFactor = ct1.powerFactor;

Serial.print(" "); Serial.print(ct1.powerFactor);

I have also added the poer factor to the TX payload

typedef struct { int power1, power2, power3, Vrms, powerFactor; } PayloadTX;

and in the emonGLCD I have added the same struct

typedef struct { int power1, power2, power3, Vrms, powerFactor; } PayloadTX;

emonGLCD variables

double usekwh = 0, genkwh = 0, Volts = 0, Pf = 0;

Pf = 0;
Pf += (emontx.powerFactor);

else if (page==4)

{

      draw_voltage_page("VOLTAGE :" , Volts, "Pf", Pf);
      draw_temperature_time_footer(temp, mintemp, maxtemp, hour,minute);
      glcd.refresh();
    }

//------------------------------------------------------------------

// Draws a page showing Voltage and Pokwer Factor Single value in big font
//------------------------------------------------------------------
void draw_voltage_page(char* powerstr, double powerval, char* energystr,  double energyval)
{
  glcd.clear();
  glcd.fillRect(0,0,128,64,0);
 
  char str[50];        //variable to store conversion
  glcd.setFont(font_clR6x8);     
  strcpy(str,powerstr); 
  strcat(str,"");
  glcd.drawString(0,0,str);
  strcpy(str,energystr); 
  strcat(str,"");
  glcd.drawString(0,38,str);

  // volts value
  glcd.setFont(font_helvB24);
  itoa((int)powerval,str,10);
  strcat(str,"v");  
  glcd.drawString(3,9,str);
 
  // Power Factor
  glcd.setFont(font_clR6x8);
   dtostrf(energyval,0,2,str); 
  strcat(str,"");
  glcd.drawString(20,38,str);       
}

 

The voltage shows fine but I can't get the power factor to show up ? Am I missing something

Thanks

Robert Wall's picture

Re: emonTX and RFData

Yes, you've declared powerFactor as an integer inside the struct - it needed to be a float or a double. The value can never exceed 1, and as it gets truncated by the integer conversion, you always get zero. But as you might be using the same struct to pass the data to emoncms (which can only accept integers), you need to leave it as an integer and you must multiply the value by 100 or 1000 as you load it into the struct (thereby giving you two or three significant figures), and divide back down again it prior to displaying in both the GLCD and in emoncms (do the maths there on the Feeds page).

I'm not sure about the lines

Pf = 0;
Pf += (emontx.powerFactor);

those seem totally wrong and as memory in the GLCD is tight, it might in any case be better to not use Pf, save a variable and write

else if (page==4)
{
      draw_voltage_page("VOLTAGE :" , Volts, "Pf", emontx.powerFactor/100.0);

[... etc]

warlock's picture

Re: emonTX and RFData

Awesome thanks Robert, I'll give that a go

Robert Wall's picture

Re: emonTX and RFData

Oops - I've just edited it a bit! - I'd forgotten you were using it to send to emoncms as well.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.