RFM69CW to code

I need help
anyone can add to RFM69CW emoncms I do not get out the.
Unfortunately I can not coding.
Unfortunately Sorry can not attach files.

//Basic energy monitoring sketch
//Authors: Trystan Lea, Eric Sandeen

//Licenced under GNU General Public Licence more details here
// openenergymonitor.org

//Sketch measures voltage and current. 
//and then calculates useful values like real power,
//apparent power, powerfactor, Vrms, Irms.

//Setup variables
int numberOfSamples = 3000;

//Set Voltage and current input pins
int inPinI = 1;
int inPinI1 = 2;

//Sanity check calibration method thanks to Eric Sandeen http://sandeen.net/wordpress
//See discussion here: http://openenergymonitor.org/emon/node/59
//Enter the values of your setup below 

// Voltage is reduced both by wall xfmr & voltage divider
#define AC_WALL_VOLTAGE        122
#define AC_ADAPTER_VOLTAGE     15.2
// Ratio of the voltage divider in the circuit
// CT: Voltage depends on current, burden resistor, and turns
#define CT_BURDEN_RESISTOR    62
#define CT_TURNS              1900

//Calibration coeficients
//These need to be set in order to obtain accurate results
//Set the above values first and then calibrate futher using normal calibration method described on how to build it page.
double VCAL = 1.0;
double VCAL1 = 1.0;
double ICAL = 2.87;
double ICAL1 = 2.88;
double PHASECAL = 2.3;

// Initial gueses for ratios, modified by VCAL/ICAL tweaks
double I_RATIO = (long double)CT_TURNS / CT_BURDEN_RESISTOR * 5 / 1024 * ICAL;
double I_RATIO1 = (long double)CT_TURNS / CT_BURDEN_RESISTOR * 5 / 1024 * ICAL1;

//Sample variables
int lastSampleI,sampleI;
int lastSampleI1,sampleI1;

//Filter variables
double lastFilteredI, filteredI;
double lastFilteredI1, filteredI1;
double filterTemp;

//Power calculation variables
double sqI,sumI;
double sqI1,sumI1;

//Useful value variables
double Irms;
double Irms1;
void setup()

void loop()

for (int n=0; n<numberOfSamples; n++)

   //Used for offset removal
   //Read in voltage and current samples.   
   sampleI = analogRead(inPinI);
   sampleI1 = analogRead(inPinI1);
   //Used for offset removal
   lastFilteredI = filteredI;
   lastFilteredI1 = filteredI1;
   //Digital high pass filters to remove 2.5V DC offset.
   filteredI = 0.996 * (lastFilteredI+sampleI-lastSampleI);
   filteredI1 = 0.996 * (lastFilteredI1+sampleI1-lastSampleI1);
   //Root-mean-square method current
   //1) square current values
   sqI = filteredI * filteredI;
   sqI1 = filteredI1 * filteredI1;
   //2) sum 
   sumI += sqI;
   sumI1 += sqI1;

//Calculation of the root of the mean of the voltage and current squared (rms)
//Calibration coeficients applied. 
Irms = (I_RATIO * sqrt(sumI / numberOfSamples)) - 0.09;
Irms1 = (I_RATIO1 * sqrt(sumI1 / numberOfSamples)) - 0.09; 

double watt = (230 * Irms);
Serial.println("***** Solar Anlage Alberd *****");
Serial.print("Anlage 1 : ");Serial.print(watt);Serial.print(" Watt "); Serial.print(Irms);Serial.print(" Ampere");
double watt1 = (230 * Irms1);
Serial.println("***** Solar Anlage Klaus *****");
Serial.print("Anlage 2 : ");Serial.print(watt1);Serial.print(" Watt "); Serial.print(Irms1);Serial.print(" Ampere");
Serial.println(); //delay(3000);

//Reset accumulators
sumI = 0;
sumI1 = 0;


I think you should look at this sketch:


From that sketch, you must take these lines from that sketch and add them to yours in similar places:

#define RF_freq RF12_433MHZ                                                // Frequency of RF12B module can be RF12_433MHZ, RF12_868MHZ or RF12_915MHZ. You should use the one matching the module you have.
const int nodeID = 6;                                                  // emonTx RFM12B node ID
const int networkGroup = 210;                                           // emonTx RFM12B wireless network group - needs to be same as emonBase and emonGLCD                                                 

#define RF69_COMPAT 1 // set to 1 to use RFM69CW 
#include <JeeLib.h>   // make sure V12 (latest) is used if using RFM69CW

typedef struct { int watt, watt1;} PayloadTX;      // create structure - a neat way of packaging data for RF comms
PayloadTX emontx;                                                       

  rf12_initialize(nodeID, RF_freq, networkGroup);                          // initialize RFM12B

Instead of
you can write this:

      // if ready to send + exit loop if it gets stuck as it seems too
    int i = 0; while (!rf12_canSend() && i<10) {rf12_recvDone(); i++;}
    rf12_sendStart(0, &emontx, sizeof emontx);
      // set the sync mode to 2 if the fuses are still the Arduino default
      // mode 3 (full powerdown) can only be used with 258 CK startup fuses

You will need to install JeeLib. That is necessary to use the RFM69CW. You can find the instructions here.

I do not know so that they can from installing me in my program?

Ihre Nachrichten werden in der Übersetzung verloren. Können Sie bitte auf Deutsch schreiben?

Welche Art von Hardware haben Sie? Es könnte besser sein, wenn Sie eine unserer Firmware, die für das emonTx geschrieben wird.

Können sie mit bitte in das obere Programm rf einbauen.
Ich bekomme es nicht hin.

Vielen dank

Ich bin sehr beschäftigt. Ich kann für Sie das tun, aber Sie müssen ein paar Wochen warten. Zuerst muss ich einen Stromwandler prüfen und einen Bericht schreiben, dann muss ich das “Continuous Monitoring” Bibliothek beenden.

Klaus.zip (5.5 KB)

Here is your sketch. I have added some lines near the beginning, one line in setup( ) and some more lines near the end of loop( ).
I have added the code for the RFM69CW as a second file, therefore you do not need JeeLib. But you must have the SPI and checksum libraries, which are part of the Arduino IDE.

I do not know what your hardware is, therefore you must change RFMSELPIN & RFMIRQPIN (line 46 & 48) as necessary.
You may change nodeID & networkGroup as you wish.

The sketch sends 4 variables of type double (16 bytes). This is defined in line 57.

I have tested your sketch on an emonTx V3.4, and I think it is working. My test program on my GLCD is unable to interpret double, but does receive the correct number of bytes.

Hi. I am using an EmonTx shield on an Arduino Mega 2560. I am unable to initialise the RFM69 with the JeeLib library (even after setting RF69_COMPAT to 1 - I2C communication ceases with this option set and the initialize command causes the sketch to freeze). I tried the sketch above (in Klause.zip) and after reassigning #define RFMSELPIN 53, the RFM is happily transmitting and Emonbase is now happily receiving packets.

I would like to use the rfm.ino in my sketches in future, but note that it only has initialize and send, no receive functionality.

Where did you get the code for this? Is there a way to add receive functionality so that I can set up control nodes and use with remote displays? Any help would be very much appreciated. Thanks in advance!

The sketch is JeeLib code, except for the actual transmit loop and the final line that waits for the transmit buffer to empty; but as you can see, it is almost all ‘in line’ rather than having many nested subroutine calls. (Or it was exact JeeLib code when I extracted it. Subsequent changes to JeeLib may have caused it to become different in an important detail.)

I don’t intend to add receive to it. If you have a problem with I2C and JeeLib, I strongly suspect you are not the only one and it should be something that JCW and his team over at JeeLabs can help you with.