rfm69 network issue
-
Hello,
I am trying to make a GW with rfm69hcw (433Mhz) to talk to a node with rfm69cw (433Mhz).
Both radio init went well, but they cannot see each other. I am using 2.0b libraryI the node I see the following:
Starting sensor (RRNNA-, 2.0.0-beta) Radio init successful. find parent send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc: find parent send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc: find parent send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc: find parent send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc: find parent send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc: find parent send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc: find parent send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc: Init complete, id=1, parent=255, distance=255And the following on the GW:
0;255;3;0;9;Starting gateway (RRNGA-, 2.0.0-beta) 0;255;3;0;9;Radio init successful. 0;255;3;0;14;Gateway startup complete. 0;255;0;0;18;2.0.0-beta 0;255;3;0;9;Init complete, id=0, parent=0, distance=0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0 0;255;3;0;9;send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0 0;255;3;0;9;send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0 0;255;3;0;9;send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0 0;255;3;0;9;send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0 0;255;3;0;9;send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0 0;255;3;0;9;send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0 0;255;3;0;9;read and forward: 1-1-255 s=255,c=3,t=7,pt=0,l=0,sg=0I understand the GW receives the signal from the node, fails to send the message to the node (ft=fail:0). Some kind of one way communication?
I have changed in MyConfig.h the following:
#define MY_RFM69_FREQUENCY RF69_433MHZ
to match 433Mhz hardware setup.The sketches I am using are just standard sketches for GW and a node.
I have 17cm isolated wire antenna on both transceivers.Anyone could give me any clues please?
-
it could be because of not receiving ack. Maybe you could check if your rfm69 interrupt pin is well set. If not, so you can't receive any response and that could be the problem.
I hope this helps. -
What kind of gateway are you using? I have seen similar issues with RFM69 on ESP8266 gateways (although my RFM69 modules are 868 MHz). The issue was present with a wire as an antenne, as well as with a rubber antenna connected to a SMA connector directly to the RFM. I was able to solve the issue in several ways:
- Touching the antenna on the ESP8266 side with my fingers! (obviously a very temporary solution)
- Connecting a ground plane to the rubber antenna (I used the lid from a can of beans)
- Connecting a dipole antenna with a 1-2 meter cable
The easiest way to debug this is to load the Gateway and Node sketches from https://github.com/LowPowerLab/RFM69/tree/master/Examples on your sensor board and gateway, since these sketches provides instant feedback and tests in both directions.
Hopefully the RFM69 driver will get better debug output at some point.
-
if you want to be sure of your antenna, cut your wire at the right lenght as you know and solder it directly on rfm69 antenna pad module. you should not have big problem with your antenna like this. then you can add a capa of course. I never had problem ...so far at least :)
You can have spi port well attached but the irq pin not well set and still have radio init done. But of course, if no interrupt pin, then no trigger on receive msg as rfm69 is interrupt driven, and of course no ack (which is mostly what means st:fail). I say this because it happened to me, i searched for hours what i was doing wrong before i remember i changed my variant pins (it was for arduino zero and each pin can be an irq, depending of the mapping variant...). And depending of your esp (i don't know if it's a new GW you're building), you can have different mapping for D0, d1 etc...(what a pain...) -
yes this shoud be d2/int2 for 1284p...have you tried your GW with a working node to see on what side is your problem.
i agree with you, i have an adapter for rfm69 i use sometimes for breadboarding but it's really not as good as radio modules directly soldered on pcb but it works on my side..
What's your other node? 3v vcc or 5v?? rfm69 isn't 5v tolerant.. -
yes this shoud be d2/int2 for 1284p...have you tried your GW with a working node to see on what side is your problem.
i agree with you, i have an adapter for rfm69 i use sometimes for breadboarding but it's really not as good as radio modules directly soldered on pcb but it works on my side..
What's your other node? 3v vcc or 5v?? rfm69 isn't 5v tolerant.. -
yes this shoud be d2/int2 for 1284p...have you tried your GW with a working node to see on what side is your problem.
i agree with you, i have an adapter for rfm69 i use sometimes for breadboarding but it's really not as good as radio modules directly soldered on pcb but it works on my side..
What's your other node? 3v vcc or 5v?? rfm69 isn't 5v tolerant..@scalz This is a low power node so 3.3V. Basically, I just used the socket for nrf24l01+ and inserted the adapter. There is a J2 pad to connect IRQ to D2 (INT2). Everything should be working fine, but ...
This is the node I am using:
https://www.openhardware.io/view/5/Battery-based-atmega328p-sensor-no-SMD -
@scalz This is a low power node so 3.3V. Basically, I just used the socket for nrf24l01+ and inserted the adapter. There is a J2 pad to connect IRQ to D2 (INT2). Everything should be working fine, but ...
This is the node I am using:
https://www.openhardware.io/view/5/Battery-based-atmega328p-sensor-no-SMDThis is a node scheme:

Pretty much standard.
I wonder if anyone has used a constructor for rf69 library?By the way I tried to load the default sketches (gateway and node) from lowpower lab and gateway does not hear the node. Again, I'm not sure wiring on the node is done in a standard moteino way - I'm using the pins which MySensors are using
D9 - not used
D10 - NSS
D11 - MOSI
D12 - MISO
D13 - SCK
IRQ - D2Obviously 3.3V and GND and ANT
EDIT: yes the pins used my Moteino Mega are different.

So the question is how do I used a constructor for rf69 and MySensors???
-
i guess you have soldered the jumper...hmm, with lowpowerlab for instance, if your gw send a packet, does the node receive something? Or vice versa ?
For debugging, bad practice in prod but :
You could put a serial message in the isr of your radio module lib , and check if it reachs it at least. Then if ack flag is triggered etc. But at least, if it doesn't enter in your isr, then it's sure there is a problem with your irq pin...
You can debug this in interruptHandler() of rfm69.cpp
i have looked briefly in mysensors libs, but i don't see why that couldn't work for your moteino mega. i have one too but not tried with mysensors and no radio on it. But i use rfm69 libs with mysensors on Atsam (arduino zero similar) so this is working.What do you mean by rfm69 constructor??
-
i guess you have soldered the jumper...hmm, with lowpowerlab for instance, if your gw send a packet, does the node receive something? Or vice versa ?
For debugging, bad practice in prod but :
You could put a serial message in the isr of your radio module lib , and check if it reachs it at least. Then if ack flag is triggered etc. But at least, if it doesn't enter in your isr, then it's sure there is a problem with your irq pin...
You can debug this in interruptHandler() of rfm69.cpp
i have looked briefly in mysensors libs, but i don't see why that couldn't work for your moteino mega. i have one too but not tried with mysensors and no radio on it. But i use rfm69 libs with mysensors on Atsam (arduino zero similar) so this is working.What do you mean by rfm69 constructor??
-
After fiddling with the radios I manage to make them talk, but the following I got from the node:
Starting sensor (RRNNA-, 2.0.0-beta) Radio init successful. send: 1-1-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=fail: send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=fail:2.0.0-beta send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:0 send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=16,sg=0,st=fail:Light Lux Sensor send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=fail:1.0 send: 1-1-0-0 s=0,c=0,t=16,pt=0,l=0,sg=0,st=fail: find parent send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc: Init complete, id=1, parent=0, distance=255 54612 send: 1-1-0-0 s=0,c=1,t=23,pt=3,l=2,sg=0,st=fail:54612Meantime, I can see that the same message is transferred three times. From the Domoticz log:
2016-06-29 20:03:18.057 Hardware Monitor: Fetching data (System sensors) 2016-06-29 20:03:22.299 MySensors: Node: 1, Sketch Name: Light Lux Sensor 2016-06-29 20:03:22.347 MySensors: Node: 1, Sketch Name: Light Lux Sensor 2016-06-29 20:03:22.393 MySensors: Node: 1, Sketch Name: Light Lux Sensor 2016-06-29 20:03:22.442 MySensors: Node: 1, Sketch Version: 1.0 2016-06-29 20:03:22.485 MySensors: Node: 1, Sketch Version: 1.0 2016-06-29 20:03:22.529 MySensors: Node: 1, Sketch Version: 1.0 2016-06-29 20:03:24.856 (Moteino) Lux (Light Level) 2016-06-29 20:03:24.899 (Moteino) Lux (Light Level) 2016-06-29 20:03:24.944 (Moteino) Lux (Light Level) -
These test sketches work just fine including ACK
Node sketch (rfm69cw)
/* RFM69 library and code by Felix Rusu - felix@lowpowerlab.com // Get libraries at: https://github.com/LowPowerLab/ // Make sure you adjust the settings in the configuration section below !!! // ********************************************************************************** // Copyright Felix Rusu, LowPowerLab.com // Library and code by Felix Rusu - felix@lowpowerlab.com // ********************************************************************************** // License // ********************************************************************************** // This program is free software; you can redistribute it // and/or modify it under the terms of the GNU General // Public License as published by the Free Software // Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will // be useful, but WITHOUT ANY WARRANTY; without even the // implied warranty of MERCHANTABILITY or FITNESS FOR A // PARTICULAR PURPOSE. See the GNU General Public // License for more details. // // You should have received a copy of the GNU General // Public License along with this program. // If not, see <http://www.gnu.org/licenses></http:>. // // Licence can be viewed at // http://www.gnu.org/licenses/gpl-3.0.txt // // Please maintain this license information along with authorship // and copyright notices in any redistribution of this code // **********************************************************************************/ #include <RFM69.h> //get it here: https://www.github.com/lowpowerlab/rfm69 #include <SPI.h> //********************************************************************************************* // *********** IMPORTANT SETTINGS - YOU MUST CHANGE/ONFIGURE TO FIT YOUR HARDWARE ************* //********************************************************************************************* #define NETWORKID 100 // The same on all nodes that talk to each other #define NODEID 2 // The unique identifier of this node #define RECEIVER 1 // The recipient of packets //Match frequency to the hardware version of the radio on your Feather #define FREQUENCY RF69_433MHZ //#define FREQUENCY RF69_868MHZ //#define FREQUENCY RF69_915MHZ #define ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes! #define IS_RFM69HCW false // set to 'true' if you are using an RFM69HCW module //********************************************************************************************* #define SERIAL_BAUD 115200 #define RFM69_CS 10 #define RFM69_IRQ 2 #define RFM69_IRQN 0 // Pin 2 is IRQ 0! #define RFM69_RST 9 #define LED 8 // onboard blinky int16_t packetnum = 0; // packet counter, we increment per xmission RFM69 radio; //RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, IS_RFM69HCW, RFM69_IRQN); void setup() { while (!Serial); // wait until serial console is open, remove if not tethered to computer Serial.begin(SERIAL_BAUD); Serial.println("Arduino RFM69HCW Transmitter"); // Hard Reset the RFM module pinMode(RFM69_RST, OUTPUT); digitalWrite(RFM69_RST, HIGH); delay(100); digitalWrite(RFM69_RST, LOW); delay(100); // Initialize radio radio.initialize(FREQUENCY,NODEID,NETWORKID); if (IS_RFM69HCW) { radio.setHighPower(); // Only for RFM69HCW & HW! } radio.setPowerLevel(31); // power output ranges from 0 (5dBm) to 31 (20dBm) radio.encrypt(ENCRYPTKEY); pinMode(LED, OUTPUT); Serial.print("\nTransmitting at "); Serial.print(FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915); Serial.println(" MHz"); } void loop() { delay(1000); // Wait 1 second between transmits, could also 'sleep' here! char radiopacket[20] = "Hello World #"; itoa(packetnum++, radiopacket+13, 10); Serial.print("Sending "); Serial.println(radiopacket); if (radio.sendWithRetry(RECEIVER, radiopacket, strlen(radiopacket))) { //target node Id, message as string or byte array, message length Serial.println("OK"); Blink(LED, 50, 3); //blink LED 3 times, 50ms between blinks } radio.receiveDone(); //put radio in RX mode Serial.flush(); //make sure all serial data is clocked out before sleeping the MCU } void Blink(byte PIN, byte DELAY_MS, byte loops) { for (byte i=0; i<loops; i++) { digitalWrite(PIN,HIGH); delay(DELAY_MS); digitalWrite(PIN,LOW); delay(DELAY_MS); } }Gateway sketch (Moteino Mega, rfm69hcw):
/* RFM69 library and code by Felix Rusu - felix@lowpowerlab.com // Get libraries at: https://github.com/LowPowerLab/ // Make sure you adjust the settings in the configuration section below !!! // ********************************************************************************** // Copyright Felix Rusu, LowPowerLab.com // Library and code by Felix Rusu - felix@lowpowerlab.com // ********************************************************************************** // License // ********************************************************************************** // This program is free software; you can redistribute it // and/or modify it under the terms of the GNU General // Public License as published by the Free Software // Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will // be useful, but WITHOUT ANY WARRANTY; without even the // implied warranty of MERCHANTABILITY or FITNESS FOR A // PARTICULAR PURPOSE. See the GNU General Public // License for more details. // // You should have received a copy of the GNU General // Public License along with this program. // If not, see <http://www.gnu.org/licenses></http:>. // // Licence can be viewed at // http://www.gnu.org/licenses/gpl-3.0.txt // // Please maintain this license information along with authorship // and copyright notices in any redistribution of this code // **********************************************************************************/ #include <RFM69.h> //get it here: https://www.github.com/lowpowerlab/rfm69 #include <SPI.h> //********************************************************************************************* // *********** IMPORTANT SETTINGS - YOU MUST CHANGE/ONFIGURE TO FIT YOUR HARDWARE ************* //********************************************************************************************* #define NETWORKID 100 //the same on all nodes that talk to each other #define NODEID 1 //Match frequency to the hardware version of the radio on your Feather #define FREQUENCY RF69_433MHZ //#define FREQUENCY RF69_868MHZ //#define FREQUENCY RF69_915MHZ #define ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes! #define IS_RFM69HCW true // set to 'true' if you are using an RFM69HCW module //********************************************************************************************* #define SERIAL_BAUD 115200 #define RFM69_CS 10 #define RFM69_IRQ 2 #define RFM69_IRQN 0 // Pin 2 is IRQ 0! #define RFM69_RST 9 #define LED 15 // onboard blinky int16_t packetnum = 0; // packet counter, we increment per xmission RFM69 radio; void setup() { while (!Serial); // wait until serial console is open, remove if not tethered to computer Serial.begin(SERIAL_BAUD); Serial.println("Feather RFM69HCW Receiver"); // Hard Reset the RFM module pinMode(RFM69_RST, OUTPUT); digitalWrite(RFM69_RST, HIGH); delay(100); digitalWrite(RFM69_RST, LOW); delay(100); // Initialize radio radio.initialize(FREQUENCY,NODEID,NETWORKID); if (IS_RFM69HCW) { radio.setHighPower(); // Only for RFM69HCW & HW! } radio.setPowerLevel(31); // power output ranges from 0 (5dBm) to 31 (20dBm) radio.encrypt(ENCRYPTKEY); pinMode(LED, OUTPUT); Serial.print("\nListening at "); Serial.print(FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915); Serial.println(" MHz"); } void loop() { //check if something was received (could be an interrupt from the radio) if (radio.receiveDone()) { //print message received to serial Serial.print('[');Serial.print(radio.SENDERID);Serial.print("] "); Serial.print((char*)radio.DATA); Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]"); //check if received message contains Hello World if (strstr((char *)radio.DATA, "Hello World")) { //check if sender wanted an ACK if (radio.ACKRequested()) { radio.sendACK(); Serial.println(" - ACK sent"); } Blink(LED, 40, 3); //blink LED 3 times, 40ms between blinks } } radio.receiveDone(); //put radio in RX mode Serial.flush(); //make sure all serial data is clocked out before sleeping the MCU } void Blink(byte PIN, byte DELAY_MS, byte loops) { for (byte i=0; i<loops; i++) { digitalWrite(PIN,HIGH); delay(DELAY_MS); digitalWrite(PIN,LOW); delay(DELAY_MS); } } -
@alexsh1 ok. i thought you were talking about something else. So to answer, it works the same for 328p, 1284p if irq and pin is right. for st fail, perhaps the adapter..it's a lot better when soldered directly on node pcb.
-
Anyone knows how I can change the rfm69 speed within the sketch?
Something like MY_RF69_DATARATE or something?Additionally, I'd like to use encryption, but no idea where to start. This is very easy with rf69 library, but not sure how to apply in MySensors.
-
This is the final product - I am @GertSanders would appreciate it

-
@alexsh1 cool :) for encryption this is done at radio init. You can enable/disable it by using MY_RFM69_ENABLE_ENCRYPTION
And for the datarate, there is no var for this. it's done by using register in radio init. I could look at adding this as I have locally updated mys with the latest rfm69 features. -
@alexsh1 cool :) for encryption this is done at radio init. You can enable/disable it by using MY_RFM69_ENABLE_ENCRYPTION
And for the datarate, there is no var for this. it's done by using register in radio init. I could look at adding this as I have locally updated mys with the latest rfm69 features. -
@alexsh1 For the encrypt key...I'm not sure how this works in mysensors. I will look into this later today ;)
Actually, it works like this : during radio init, encryption is enabled or not depending of the above define. For the key (which is stored in eeprom) it uses EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS which is related to signing defines..you can have more info on this in MyEepromAddresses.h . you will see how it is constructed.
