Talking to emonPi with Arduino and RFM69HW radio

I have put together an Arduino clone and a RFM69HW radio to see if I can get additional range out of several of my further nodes that cannot reach my emonPi currently. The problem that I have run into is that I cannot seem to get the RFM69HW equipped node to communicate with my emonPi.

I have verified multiple times that my NodeID, Freq and Network Group are all set correctly. I can communicate with my other test node using this same radio and configuration, just not the emonPi.

#define NODEID       26  //network ID used for this unit
#define NETWORKID    210  //the network ID we are on
#define FREQUENCY  RF69_433MHZ //others: RF69_868MHZ, RF69_915MHZ
#define IS_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!
RFM69 radio;

snip

void setup() {
 Serial.begin(SERIAL_BAUD);
 delay(10);
 radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
 radio.setHighPower(); //uncomment only for RFM69HW!
#endif

I looked around I ā€˜thinkā€™ I have figured out that it has something to do with the JeeLib library. I guess my question is do I need to use a specific library for my radio to talk to the emonPi? Or have I got something else messed up?

Thanks

Iā€™m not sure that JeeLib supports RFM69HW. I think you may need to use the LowPower labs lib:

Hi Glyn -

That is the library that I am using as someone pointed me in that direction, but using that library I cannot talk to the emonPi which defeats my purpose of using the high power radio!

If you can figure out how to drive the RFM69HW with low-level commands, you could lift the RF code out of a PLL sketch that I posted on the old forums a few days ago in response to someone whoā€™d put JeeLib into MartinRā€™s PLL diverter and couldnā€™t get it to work (it wonā€™t, itā€™s too slow), and convert/extend that.

https://openenergymonitor.org/emon/node/1535#comment-41534

1 Like

Robert -

Wowā€¦that is all I can sayā€¦that is quite some code!

I didnā€™t see a library loaded for the radio. I was expecting to see something RFM69.h or JeeLib.h - I assume these are not present because you are driving the radio with the low level commands instead of making calls to a library.

Am I thinking of that correctly?

I thought it said ā€œDoes not useā€¦ā€ but it doesnā€™t - thatā€™s doesnā€™t say and doesnā€™t use JeeLib per se. Most of it is actually straight from JeeLib, slimmed down to pick out only the bits that are absolutely necessary for what we do.

? Not sure what you are asking Robert -

I am NOT using the JeeLibs library since it does not support the RFM69HW (or at least I could not make it work). I am using the RFM69 library from LowPowerLabs.

I have been able to make the radio work when I combine both of those libraries and send the highpower command to the radio via the RFM69 library (this works):

#include <JeeLib.h>                                   //https://github.com/jcw/jeelib - Tested with JeeLib 3/11/14 
#include <avr/power.h>
#include <avr/sleep.h> 
#include <RFM69.h>

#define RF_freq RF12_433MHZ
int nodeID = 26;
const int networkGroup = 210;

RFM69 radio;

snip

 rf12_initialize(nodeID, RF_freq, networkGroup);
#ifdef IS_RFM69HW
 radio.setHighPower(); 
#endif

ā€¦

rf12_sleep(RF12_WAKEUP);
dodelay(100);
rf12_sendNow(0, &water, sizeof water);
rf12_sendWait(2);       // set to 2 if using Arduino default fuses
rf12_sleep(RF12_SLEEP);
dodelay(100);

.
.
.

This does not work:

#include <RFM69.h>

radio.initialize(nodeID, RF_freq, networkGroup);
#ifdef IS_RFM69HW
radio.setHighPower(); //uncomment only for RFM69HW!
#endif

ā€¦

radio.sendWithRetry(0, &water, sizeof water);

I can use the jeelibs library to transmit the data to the emonPi one I use the LPL library to set the radio to high power, but something tells me this is a horrible way to make this work, so I am trying to get the RFM69HW to talk to my emonPi via the LowPowerLabs RFM69.h library and nothing that I do seems to work.

So I am sure that I am missing something (maybe simple) about using the RFM69 library to talk to the emonPi.

As far as I know, LowPowerLabs use a completely different protocol to JeeLib. So if Iā€™m right, your failure doesnā€™t surprise me.
If you want to go with LPL, youā€™d need to replace the firmware in the RFM69Pi, and that sounds too much like a can of worms for my liking.

Ah, so that is the rub. If I am going to use the RFM69 library, there is no way to talk to the emonPi. OK, so my next question - using the external RJ45 connection on the Pi is there a way to add a second radio (an HW) to listen to my HW nodes?

I am thinking the Pi could listen to the serial output of the HW.

I canā€™t answer that, but my inclination would be to look at what the differences are between the respective commands to make the RFM69 transmit. My guess is they will correspond fairly closely, and you may need only to slip in one or two extra settings in the setup procedure. I havenā€™t looked, so I might be wrong, but if I were doing a high-powered variant of an existing design, Iā€™d make it pretty much a dead ringerā€¦

Robert -

Thanks for the insightā€¦I will take a look and see if I can figure it out.

You also need to bear in mind that the ā€œOEMā€ rfm69 are being used in a mode to be compatible with rfm12ā€™s not in there native ā€œrfm69ā€ mode. the Low Power Labs Lib is not and will probally be using a full complement of rfm69 only features and almost definitely not be doing anything remotely similar to the rfm12 jeelib.
Do a search over on JeeLabs forum for some more info, I recall some discussion that questioned inter-operability between the rfm69hw and the rfm69cw even when running in full rfm69 mode, I donā€™t think running in rfm12 mode is likely to help that situation any.

Thanks Paul -

I have been doing some searching and it would look like I would have to modify the library to make it work, something I am not sure I can manage after looking at it. But it is something to keep trying!

Iā€™ve downloaded the RFM69HW data sheet and while I havenā€™t compared it with the RFM69CW character by character, the two look much the same. What Iā€™d do is take the low-level commands, which I referred you to earlier and which follow exactly the JeeLib protocol, and look up each in each data sheet and compare the two modules that way. My guess is youā€™d only have to add or alter a couple of commands to set the power level.

Thanks Robert -

So basically I would not be including a library, but using the low level commands directly in the sketch?

Yes, those commands were lifted straight out of JeeLib, but I have included only the part of JeeLib thatā€™s actually necessary to do the job in hand with the values that we require. There is nothing there to receive, for example. And do remember you need to find each command in the RFM69CW data sheet and check that itā€™s the same in the RFM69HW, or change it as you require, and youā€™ll need to look out for anything particular in the 'HW options that might need to be looked at, and ask. Because both are not only from the same manufacturer, but from the same family as well, Iā€™d expect the differences to be small - probably only in the output power settings. Although it would be a very useful thing to do, I donā€™t think Iā€™ll have time to do that any time soon - much as Iā€™d like to. You might even find that there are no apparent changes, in which case thereā€™s a good chance that it will work unchanged.

Understood Robert,

I will get the datasheets and try my hand at itā€¦the worst thing that can happen is they simply do not transmit! :slight_smile:

Thanks for the help!

I just got a EmonTH clone working with the RFM69HW, using the JeeLib library. I changed the value of RegPaLevel by adding
writeReg(0x11, 0x5f);
after
rf12_initialize(nodeID, RF_freq, networkGroup);
This sets the power to 13bBm, same as RFM69CW. To increase power to 17dBm set 0x11 to 7F. To get 20dBm three other registers need to be modified. See, 3.3.7 High Power Settings, page 21 and 22 of the datasheet. Make sure to NOT use these settings for radios other than the HW.

1 Like

It might be worth adding that by reducing the power further, and this applies to the RFM69CW too, then provided the received signal strength remains adequate, battery life will be extended. (But I have not tried to calculate by how much.) Battery life will be reduced if the output power is increased.

Hi - did you manage to resolve this and publish the code anywhere? I have a similar issue with a Adafruit Feather M0 and and RFM69HCW - I have a few old RFM12 transmitters and an emonPi with RFM12 onboard (all working for a long time) I donā€™t want to rip an replace. It appears you can put compatibility mode on with the #define RF69_COMPAT 1 - but not sure if this is limited to the jeelib code ā€¦ Iā€™m having to use LowPowerLab for the M0 as jeelib wonā€™t compileā€¦ assuming the libraries arenā€™t written for ARM Cortex??? ā€¦ So I get using lowpowerlib on one and jeelib on another is not going to work - have you managed to use common libraries on both and deal with a RFM12 to 69 ?