Git Product home page Git Product logo

rfm69's People

Contributors

ademuri avatar androlgenhald avatar atalonica avatar brainelectronics avatar christineyen avatar damadmai avatar dekay avatar drewblessing avatar haschler avatar ivankravets avatar janhrach avatar jdede avatar jgillula avatar lowpowerlab avatar lukagith avatar markbergsma avatar maxgerhardt avatar mcspr avatar ortegafernando avatar per1234 avatar plattrap avatar renno-bih avatar rlpipkin avatar spetrow avatar sraillard avatar strange-v avatar underscoreho avatar wifixcort avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rfm69's Issues

sendFrame is called even if canSend is false?

Just checking to make sure I have the logic right:
The send() function checks to make sure there isn't channel activity with the canSend() function. send() then blocks until the RF69_CSMA_LIMIT_MS is exceeded or if the channel clears. Looking at the while loop, it seems that if the RF69_CSMA_LIMIT_MS is exceeded but, the channel is still active , the sendFrame() proceeds.

I'm suggesting something like the following:
while (!canSend() && millis() - now < RF69_CSMA_LIMIT_MS) receiveDone();
if(!canSend() && millis()-now > RF69_CSMA_LIMIT_MS){
return;
}else{
sendFrame(toAddress, buffer, bufferSize, requestACK, false);
}

Please let me know if I'm wrong or on the wrong track

Missing keywords in keywords.txt

The following keywords are missing from keywords.txt:

setNetwork
ACKRequested
setPowerLevel
readTemperature
rcCalibration
readAllRegs

Also, 'CryptFunction' is declared in keywords.txt but doesn't appear anywhere in the code and should be removed.

RFM69HCW: transmit in PA0 mode?

[new to github -- apologies if this isn't the place to ask this]

Thanks for the library.

I'm trying to transmit in PA0 mode and it doesn't work. You have in your code that:

"// for RFM69HW only: you must call setHighPower(true) after initialize() or else transmission won't work"

Thought I don't fully understand the differences between H, HW, and HCW, I tried calling setHighPower(false) and, indeed, it doesn't appear to transmit.

Do you know why this is? Is it possible to transmit in PA0 mode with some different settings? Basically, I'm trying to reduce power consumption on transmit, moreso than with setPowerLevel().

ack timeout when a broadcast is sent ...

In my case I need to use send with retry all the time for direct address and broadcast.
of course in broadcast I should loose the retry and ack functionalities.

I think you try to catch this in the ACKReceived but it is not working for a braoadcast because my receivers will not ack a broadcast message (of course )

so the sendWithRetry will spin and time out all retries...

here a dirty modification to ACKReceived that exit with true immediatly went a broadcast address was used, so not time out.

:-)

//-----------------------------
bool RFM69::ACKReceived(uint8_t fromNodeID) {

if(fromNodeID == RF69_BROADCAST_ADDR) {
receiveDone();
return true;
}
if (receiveDone()) {
return( ((SENDERID == fromNodeID) && ACK_RECEIVED ));
//return (SENDERID == fromNodeID || fromNodeID == RF69_BROADCAST_ADDR) && ACK_RECEIVED;
}
return false;
}

//-----------------------------
bool RFM69::sendWithRetry(uint8_t toAddress, const void* buffer, uint8_t bufferSize, uint8_t retries, uint8_t retryWaitTime) {
uint32_t sentTime;
for (uint8_t i = 0; i <= retries; i++)
{
send(toAddress, buffer, bufferSize, true);
sentTime = millis();
while (millis() - sentTime < retryWaitTime)
{
if (ACKReceived(toAddress))
{
Serial.print(" ~ms:"); Serial.print(millis() - sentTime);
return true;
}
}
Serial.print(" RETRY#"); Serial.println(i + 1);
}
return false;
}

// check whether an ACK was requested in the last received packet (non-broadcasted packet)
bool RFM69::ACKRequested() {
return ACK_REQUESTED && (TARGETID != RF69_BROADCAST_ADDR);
}

Node crashes on radio.sleep()

Hi, I am making a home automation sensor network using RFM69's. Set-up is working great so far but I am having a small problem...

I'm using the example "DeepSleep_usingLowPowerLibrary" to test the sleep power consumption of my nodes. Problem is: The example is not running on my sensor node's.

I first tried using only the LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); statement to test the ATmega328 sleep functionality, witch works perfect.

Second test was to put also the Radio in sleep mode using the radio.sleep(); statement. But the moment the Arduino executes that line of code it won't continue.
If I place the radio.sleep(); statement in the void loop I got the same problem. The arduino stops working when it arrives at the sleep line...
I tested the above with the serial monitor and proper capacitors/power supply!
Note: I am not using the Flash Mem functionality in the "DeepSleep_usingLowPowerLibrary" so I just commented the #define WITH_SPIFLASH line out

I would really want to know if someone has the same problem or has a solution!
Thanks in advance

Multiple Radios per node

I think a relatively simple, and nice addition would be the ability for this library to handle multiple instances with multiple radios.

I think the changes would be relatively simple, currently there is just a public static RFM69 *self pointer, that gets called by the ISR. All you would have to do is create a simple linked list of RFM69 objects, add an additional attribute to the class that is a RFM69 *next pointer. Whenever the ISR fires, in the isr routine just traverse through the list and digitalRead each RFM69's isr pin to figure out which device triggered the interrupt, then call the associated handler.

Why no hardware address filtering?

Hello again. Im sorry for being annoying, but I still have some questions. Ive found the way how to enable harware address filtering, but I`m interested why you decided to tunt it off and how can it effect if I enable it.

millis rollover

here and there is are code that checks some time past with similar
while (!canSend() && millis() - now < RF69_CSMA_LIMIT_MS) receiveDone();
But millis function rollover every ~49 days, this means after that there are glitches where code keeps running another 49 days because now is bigger than millis()

Slow to send ACK on ESP8266

I am using the Adafruit HUZZAR ESP8266 board with an RFM69HW module. It is listening for packets then forwarding them on via WiFi to MQTT. The sensor is using sendWithRetry to send its data. I noticed that the send always failed but the data was still getting through. After much investigation I noticed that the ESP gateway was typically taking 1005ms to send its ACK. Of that 1000ms is the collision timeout. It all gets hung up on the canSend() function. This intensive loop stops the ESP from doing its background tasks. I tried using yield() or delay(1) at the top of the canSend() function. Both improved the situation, using yield() gave a typical ACK response of 400ms; still a bit long. However using delay(1) gave an ACK response time of 5ms; much better.

You may want to consider adding this tweak to your library.

Initialize fails on UNO

It seems the initialize function (RFM69) fails on a Arduino Uno R3 board. Tried to swap out radio's and even run the working sender on the Uno with no success. I used the default pinout (RST: 9, CS: 10; MOSI: 11; MISO: 12; CLK: 13; IRQ: 2). I'm using an RFM69HCW board on a breakout from Adafruit.

Gateway example migth not request ACK from every node

The Gateway example requests ACK from every 3th packet received. Depending on the sending frequency and the number of remote nodes, it might not requests ACKs from alle the remotes. Maybe an array to track packet numbers per node is more accurate.

Trasmission time

Hi, thank very much for you great job, this library is very useful.
I figure out the transmission time is about 1 sec. but i think that time seems too much. Maybe I've wrong in my sketch ?
The receiver see the packet as soon the led in the transmitter node became on, so there is time not useful on the transmitter maybe awaiting the and of something or some timeout ?
Thanks in advance.

#include <LowPower.h>
#include <SPI.h>
#include <RFM69.h>

#define ledPin 3

#define NETWORKID     0   // Must be the same for all nodes
#define MYNODEID      2   // Trasmitter node ID
#define TONODEID      1   // Destination node ID
#define FREQUENCY   RF69_433MHZ

RFM69 radio;

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

void setup() {
  pinMode(ledPin, OUTPUT);

  Serial.begin(57600);

  radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
  radio.setHighPower();

}

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

void loop() {
   delay(10);

   char buff[] = "123 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   byte buffLen=strlen(buff);

   long start_timer=millis();
   
   digitalWrite(ledPin, HIGH);
   Serial.println("Sending buffer ...");
 
   radio.send(TONODEID, buff, buffLen);
   
   digitalWrite(ledPin, LOW);
   Serial.print("Trasmission time = "); Serial.println((millis() - start_timer));
   Serial.println();

   
   delay(200);
}

The output is:

Sending buffer ...
Trasmission time = 1014

Sending buffer ...
Trasmission time = 1012

Sending buffer ...
Trasmission time = 1014

Sending buffer ...
Trasmission time = 1013

Sending buffer ...
Trasmission time = 1012

Sending buffer ...
Trasmission time = 1014

Sending buffer ...
Trasmission time = 1013

Sending buffer ...
Trasmission time = 1012

Sending buffer ...
Trasmission time = 1014

Sending buffer ...

Hardware address filtering

Hello. Im trying to enable hardware address filtering, because in your lib its commented by default. The problem is when you have several nodes in one network each node will interrupt the MCU whatever nodeID it has, and only MCU decides if this message belongs or not. So I`d like to know how to make RMF intrerrupt MCU only if networkID AND nodeID matches.

setPowerLevel sets the wrong level for HW radios

Datasheet section 6.3 Transmitter Registers, Table 25 has a footnote regarding OutputPower saying "Only the 16 upper values of OutputPower are accessible" when any of PA1 or PA2 are on.

the existing code has an if (_isRFM69HW) _powerLevel /= 2; which seems wrong as it'll force the supplied 0..31 value into the 0..15 range rather than in the 16..31 range as the datasheet implies is intended with its OutputPower -> dBm calculations. I suggest adding 16 after you divide by 2 so that your 0..31 input maintains its meaning and is spread across the documented allowed register value range.

The actual behavior of my RFM69CHW in high power mode appears similar regardless of which way I write the register (but I don't have a scope, just watching the RSSI on another RFM69 receiver as I play with a transmitter). So it may have internal logic that works either way. But what I describe above is consistent with the -11dBm + OutputPower = tx dBm description in the datasheet.

HCW vs HW

Maybe more a question than an issue:
What is exactly the difference between the HCW and the HW version, as they both are +20dB? Just the pinout?
should the
#ifdef IS_RFM69HW
radio.setHighPower(); //only for RFM69HW!
#endif

also be set for the HCW version?

RFM69HW Get lock when sending an ACK

Hello,

I'm getting an error with the ACK with a radio.setHighPower() and radio.sendACK after receiving a message.

The code is very simple, and my RFM69 work at 868MHz:

void setup() {
  radio.initialize(FREQUENCY, NODEID, NETWORKID);
  radio.encrypt(ENCRYPTKEY);
  radio.promiscuous(true);
  radio.setHighPower();
  radio.sleep();
}

void loop() {
if (radio.receiveDone())
  {
    for (byte i = 0; i < radio.DATALEN; i++)
      buff[i] = (char)radio.DATA[i];
    buff[radio.DATALEN] = '\0';
    if ((radio.TARGETID == NODEID) && radio.ACKRequested())
    {
     radio.sendACK();   
    }
...

The code get lock on the sendAck line (tested with debug log on each line)
If I comment the radio.sendACK(); every thing work fine.
If a comment the radio.setHighPower(); every thing work fine.

It's look like both are not compatible.

Running on Teensy 3.2

In the example code, the DIO0 is connected to D2 on a 328 for the interrupt. What pin do I used for the interrupt on a Teensy 3.2?

send() locks up for 433MHz RFM69HCW

Hi, I'm Mike Grusin, one of the engineers at SparkFun Electronics.

We're about to release some breakout boards for the RFM69 module in the HCW (high power + compact) variant. We very much like your RFM69 library and are planning on using it as the baseline for our tutorials, etc.

I've run into an interesting problem that I'm still tracking down but wanted to get your insight on.

Everything has worked great with the 915MHz module. But when we run the same code on the 433MHz module, only changing the FREQUENCY definition to RF69_433MHZ, we get consistent lockups when we try to send a packet. The code is locking up in RF69.cpp line 162, which is:

while (!canSend()) receiveDone();

Interestingly, if you run the same 433MHz code on a 915MHz module, it does not lock up (though it can only barely transmit).

Also interestingly, if you run the 915MHz code on a 433MHz module, it does not lock up (and can actually get packets across a few feet). The flexibility of this chip is pretty remarkable.

I'll keep poking at it, but as you are vastly more familiar with the internals of the chip I hope you might have some ideas. I would be more than happy to send you a few of our boards if it would help.

Thanks very much for any assistance you might have, and also for your work on this library. We're big fans of the stuff you do at LowPowerLab. If you're ever interested in licensing your Moteino design to us for manufacture, let me know. (I can't promise anything, but it's a great board and I would push hard to make it so.)

Best, Mike Grusin
[email protected]

Incompatibility with Adafruit PWM Servo Library

chiptesting.zip

I have found an issue when sending a radio transmission, my arduino uno freezes. I"m using the library located here (https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library) to control my PCA9685.

The issue only seems to occur when actually transmitting.

Attached is my code, since it wouldn't paste correctly. It is a modification of the Adafruit example file.

If I comment out
radio.sendWithRetry(GATEWAYID, (const void*)(&theData), sizeof(theData));
the program loops successfully.

Any help would be appreciated. I'm not that good of a coder.

CLKOUT defines are not correct

Hi,

In registers.h

#define RF_DIOMAPPING2_CLKOUT_32 0x00
#define RF_DIOMAPPING2_CLKOUT_16 0x01
#define RF_DIOMAPPING2_CLKOUT_8 0x02
#define RF_DIOMAPPING2_CLKOUT_4 0x03
#define RF_DIOMAPPING2_CLKOUT_2 0x04
#define RF_DIOMAPPING2_CLKOUT_1 0x05 // Reset value
#define RF_DIOMAPPING2_CLKOUT_RC 0x06
#define RF_DIOMAPPING2_CLKOUT_OFF 0x07 // Recommended default

I think it's wrong, it must be:

#define RF_DIOMAPPING2_CLKOUT_1 0x00
#define RF_DIOMAPPING2_CLKOUT_2 0x01
#define RF_DIOMAPPING2_CLKOUT_4 0x02
#define RF_DIOMAPPING2_CLKOUT_8 0x03
#define RF_DIOMAPPING2_CLKOUT_16 0x04
#define RF_DIOMAPPING2_CLKOUT_32 0x05
#define RF_DIOMAPPING2_CLKOUT_RC 0x06 // Reset value
#define RF_DIOMAPPING2_CLKOUT_OFF 0x07 // Recommended default

Best regards

SS undefined when used with attiny core

The definition for SPI_CS = SS at line 14 throws error when used with attiny cores due to SS not being defined in pins_arduino.h for those cores. Work around has been to explicitly define 'static cont unit8_t SS = ' in the code. Any workaround you could think of in the library ?

fatal error: avr/wdt.h: No such file or directory

Hi
I'm not sure if it is really a problem, or not. I'm using Arduino 1.6.12 (Windows).
After downloading RFM69 and SPIFlash to the library and loading the "Node" example, I get the following error:

C:\Users\Pixinger\Documents\Arduino\libraries\RFM69\RFM69_OTA.cpp:35:21: fatal error: avr/wdt.h: No such file or directory
#include <avr/wdt.h>

The weired thing is, it is physically available: C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\avr\wdt.h

Is someone having similar problems?
Kind regards
Pix

RFM69Base class

Hi, great library!

One problem though is that the base class (RFM69) already has a bunch of specific functionality built in. For example, the packet layout is fixed, and you have no direct control over address bytes, and there is no way to send raw data, the library repacks it into a specific way.

In many use cases, people may not necessarily want to use the RFM69 in the way it is currently implemented in the library. I think it would be awesome if there could be a simple RFM69Base class that is just a thin driver on top the radio, and provides a simple api for configuring and using the radio, such as sync address, payload length, sending raw data, handling radio interrupts, etc...

Then your RFM69 class can inherit from this base class, and implement all the implementation specific details needed for the way it handles sending packets, etc...

I needed just a simple radio driver for a project where I am reverse engineering a commerical product that already uses this radio. So I need methods to be able to configure every aspect of the radio. I ended up stripped all the use case specific details from the RFM69 class into a RFM69Base class. It can be seen here:
https://github.com/wizard97/BetterRFM69

I would be happy to put in the additional work of having the RFM69 class inherit from the RFM69Base class, as long as you can confirm this is a change you would accept a pull request from.

ESP8226

Does this library work with the ESP8266?

Moteino Leo?

What happened to this project? Because I like having the USB port on the board I am working on a 32u4 based + RF69 radio board. Been having trouble getting this to work with the Moteino RFM69 library. Specifically I think the SS, CS, IRQ pins are not wired correctly. Any help would be great.

Corrupted packets when using encrypted transmission

Hi,

I was testing you library and it is very cool, however I was observing strange phenomena.
When you send data from one node to another while they don't have same encryption keys,
sometimes a corrupted packed is received.
I would expect that no packet should be received because keys are different.

For example:
I was sending a 61 byte long packet where first 4 bytes were random numbers and rest were numbers in sequence 4, 5, 6, ..., 59, 60, with encryption key #define KEY "SAMPLEenCRYPTkEY"
-5 106 6 0 4 5 6 7 8 ... 54 55 56 57 58 59 60

I received this corrupted packet (encryption key is "sampleEncryptKey")
[10] [RX_RSSI:-31] [Data len:61] [ERROR in data]
23 103 148 98 11 223 13 205 200 113 33 153 105 153 140 31 142 100 63 65 101 212 25 9 76 80 169 39 61 251 253 59 54 113 155 172 166 44 21 238
210 92 245 218 91 85 123 78 185 167 0 56 236 37 102 137 119 254 224 173 205

I attached two sketches (sender and receiver as example) let it run for some time.
Receiver sketch is displaying only corrupted packets.

I would assume if the encryption keys are not same than packets cannot be received because of invalid crc.
Does that mean that CRC collision happens more frequently than it is expected?

When you use promiscuous mode it is more visible.
sketches.zip

Btw I'm using Funky V3 instead of Moteino. It is visible in setup() function.
Regards
Vitek

will LoRa be supported

Hey Felix,

thanks for your great work on the RFM-libs. We are about to deploy them in our bee-monitoring project @hiveeyes. Since we are trying to have a small energy footprint and still support infrastructural outstanding locations we are very interessted in the Long Range modules from hopeRF.

Are you planning to write an arduino lib for them?

Thanks a lot

einsiedlerkrebs

readReg(0x30) (networkID) returns 0, albeit set something else

Hello,

I have been struggling with my RFM69HCW modules for a while. Even though the transmitting side seems to be working, I cannot receive anything at the other end of the transmission. I started investigating the issue by reading the registers. This is how I realized something interesting.

In details, as far as I understand the register 0x30 of the module is used for network id which set during the initialization process. In theory, when the register is read after initialization I should be reading the value set during initialization. However, when I read the value with the function readReg(0x30) I receive 0 no matter what value was assigned during the initialization.

I would be glad if you let me know if it is problem with my modules or I am reading the wrong register.

I am providing a hunk of the code running the nodes below.

Thanks in advance.

Bests,
M

#include <RFM69.h>    //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>

#define NETWORKID     6  // The same on all nodes that talk to each other
#define NODEID        99    // The unique identifier of this node
#define FREQUENCY     RF69_915MHZ
#define IS_RFM69HCW   true // set to 'true' if you are using an RFM69HCW module
#define ENCRYPTKEY     "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes!
readReg(0x30) 
//*********************************************************************************************
#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

RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, IS_RFM69HCW, RFM69_IRQN);

int16_t packetnum = 0;  // packet counter, we increment per xmission
int16_t rssi[8];

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");

  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 
  // Hard Reset the RFM module
  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, HIGH);
  delay(100);
  digitalWrite(RFM69_RST, LOW); //(5dBm) to 31 (20dBm)

  radio.encrypt(ENCRYPTKEY);

  Serial.print("\nTransmitting at ");
  Serial.print(FREQUENCY == RF69_433MHZ ? 433 : FREQUENCY == RF69_868MHZ ? 868 : 915);
  Serial.println(" MHz");
}

radio.sendWithRetry

Hi

I am having issues with ACKs & radio.sendWithRetry.

Please confirm if the length filed should be the number of bytes or number of individual characters?

Thanks

pinMode for interrupt pin

Guys, please add setting of interrupt pin mode to INPUT somewhere -- I've just killed two days trying to figure out why radio.send hangs...

Implement SoftSPI

Is it possible to implement SoftSPI like in NRF24 libs to esay use with MySensors.

How FHSS work on RFM69?

Good Evening.

I'm Adriel Praba Wicaksono from Electronic Engineering Polytechnic Institute of Surabaya, Indonesia. I'm Telecommunication Engineering Final Year Student.

This year, I develop my final project. The title is "Wireless Communication System with Frequency Hopping Spread Spectrum using Raspberry Pi and FSK Modem". And i used RFM69HW as FSK Modem. But, i have some problem with the library. The problem is how to activate Frequency Hopping at RFM69HW. Is the FHSS activated by default in RFM69HW? How many frequency that synthesize by this module? Or there's unpredictable how many frequency that synthesize?

Would you help me to tell me where's the source code parts/datasheet parts that explain it?

Thank You.

ESP32 random crashes

I am running a slightly modified version of the Gateway example, having removed the SPIFlash for compatibility reasons.

Here's a snippet:

// Sample RFM69 receiver/gateway sketch, with ACK and optional encryption, and Automatic Transmission Control
// Passes through any wireless received messages to the serial port & responds to ACKs
// It also looks for an onboard FLASH chip, if present
// **********************************************************************************
// Copyright Felix Rusu 2016, http://www.LowPowerLab.com/contact
// **********************************************************************************
// 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.                              
//                                                        
// 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 <RFM69_ATC.h>     //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>           //included with Arduino IDE install (www.arduino.cc)

#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
#define RFM69_CS      10
#define RFM69_IRQ     2
#define RFM69_IRQN    digitalPinToInterrupt(RFM69_IRQ)
#define RFM69_RST     9
#define LED           13  // onboard blinky
#elif defined(__arm__)//Use pin 10 or any pin you want
// Tested on Arduino Zero
#define RFM69_CS      10
#define RFM69_IRQ     5
#define RFM69_IRQN    digitalPinToInterrupt(RFM69_IRQ)
#define RFM69_RST     6
#define LED           13  // onboard blinky
#elif defined(ESP8266)
// ESP8266
#define RFM69_CS      15  // GPIO15/HCS/D8
#define RFM69_IRQ     4   // GPIO04/D2
#define RFM69_IRQN    digitalPinToInterrupt(RFM69_IRQ)
#define RFM69_RST     2   // GPIO02/D4
#define LED           0   // GPIO00/D3, onboard blinky for Adafruit Huzzah
#else
#define RFM69_CS      5
#define RFM69_IRQ     16
#define RFM69_IRQN    digitalPinToInterrupt(RFM69_IRQ)
#define RFM69_RST     17
#endif

//*********************************************************************************************
//************ IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
#define NODEID        1    //unique for each node on same network
#define NETWORKID     200  //the same on all nodes that talk to each other
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
//#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_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!
//*********************************************************************************************
//Auto Transmission Control - dials down transmit power to save battery
//Usually you do not need to always transmit at max output power
//By reducing TX power even a little you save a significant amount of battery power
//This setting enables this gateway to work with remote nodes that have ATC enabled to
//dial their power down to only the required level
//#define ENABLE_ATC    //comment out this line to disable AUTO TRANSMISSION CONTROL
//*********************************************************************************************
#define SERIAL_BAUD   115200

#ifdef __AVR_ATmega1284P__
  #define LED           15 // Moteino MEGAs have LEDs on D15
  #define FLASH_SS      23 // and FLASH SS on D23
#else
  #define LED           9 // Moteinos have LEDs on D9
  #define FLASH_SS      8 // and FLASH SS on D8
#endif

#ifdef ENABLE_ATC
  RFM69_ATC radio;
#else
  RFM69 radio;
#endif

bool promiscuousMode = false; //set to 'true' to sniff all packets on the same network

void setup() {
  Serial.begin(SERIAL_BAUD);
  delay(10);
  Serial.println("Here");
  // Initialize radio
  radio = RFM69(RFM69_CS, RFM69_IRQ, true, RFM69_IRQN);
  // Hard Reset the RFM module
  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, HIGH);
  delay(100);
  digitalWrite(RFM69_RST, LOW);
  delay(100);
  
  Serial.println("Here!");
  if (!radio.initialize(FREQUENCY,NODEID,NETWORKID)) {
    Serial.println("radio.initialize failed!");
  }
  
  Serial.println("Here!!");
  #ifdef IS_RFM69HW
    radio.setHighPower(); //only for RFM69HW!
  #endif
  
  radio.setPowerLevel(31);
  radio.encrypt(ENCRYPTKEY);
  //radio.promiscuous(promiscuousMode);
  char buff[50];
  sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(buff);
  Serial.print("Network "); Serial.println(NETWORKID);
  Serial.print("Node "); Serial.println(NODEID);
  Serial.print("Encryptkey "); Serial.println(ENCRYPTKEY);

  Serial.println();

#ifdef ENABLE_ATC
  Serial.println("RFM69_ATC Enabled (Auto Transmission Control)");
#endif
}

byte ackCount=0;
uint32_t packetCount = 0;
void loop() {

  if (radio.receiveDone())
  {
    Serial.print("#[");
    Serial.print(++packetCount);
    Serial.print(']');
    Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
    if (promiscuousMode)
    {
      Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
    }
    for (byte i = 0; i < radio.DATALEN; i++)
      Serial.print((char)radio.DATA[i]);
    Serial.print("   [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
    
    if (radio.ACKRequested())
    {
      byte theNodeID = radio.SENDERID;
      radio.sendACK();
      Serial.print(" - ACK sent.");

      // When a node requests an ACK, respond to the ACK
      // and also send a packet requesting an ACK (every 3rd one only)
      // This way both TX/RX NODE functions are tested on 1 end at the GATEWAY
      if (ackCount++%3==0)
      {
        Serial.print(" Pinging node ");
        Serial.print(theNodeID);
        Serial.print(" - ACK...");
        delay(3); //need this when sending right after reception .. ?
        if (radio.sendWithRetry(theNodeID, "ACK TEST", 8, 0))  // 0 = only 1 attempt, no retries
          Serial.print("ok!");
        else Serial.print("nothing");
      }
    }
    Serial.println();
  }
}

After a random number of messages I receive the following error:

Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0)
Register dump:
PC      : 0x40083537  PS      : 0x00060034  A0      : 0x80084b3b  A1      : 0x3ffc0590  
A2      : 0x3ffc1380  A3      : 0x00060021  A4      : 0x00060e23  A5      : 0x00000020  
A6      : 0x00000020  A7      : 0x00060023  A8      : 0xb33f0000  A9      : 0xb33fffff  
A10     : 0x00060021  A11     : 0x00000000  A12     : 0x00060021  A13     : 0x3ffc7724  
A14     : 0x00000003  A15     : 0x0000000f  SAR     : 0x00000012  EXCCAUSE: 0x00000005  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  

Backtrace: 0x40083537:0x3ffc0590 0x40084b3b:0x3ffc05b0 0x400834ce:0x3ffc05d0 0x40085644:0x3ffc05f0 0x40081b09:0x3ffc0600

Decoding the backtrace using EspExceptionDecoder I get the following:

0x40083537: uxPortCompareSet at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/include/freertos/portmacro.h line 239
:  (inlined by) vPortCPUAcquireMutex at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./port.c line 315
0x40083537: uxPortCompareSet at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/include/freertos/portmacro.h line 239
:  (inlined by) vPortCPUAcquireMutex at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./port.c line 315
0x40084b3b: xTaskIncrementTick at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./tasks.c line 4420
0x400834ce: xPortSysTickHandler at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./port.c line 275 (discriminator 1)
0x40085644: _frxt_timer_int at ?? line ?
0x40081b09: _xt_lowint1 at xtensa_vectors.o line ?

Anyone have a clue why this could be happening?

Thanks much in advance.

chaining the rfm on the spi bus

I can successfully use this library, receive data on the radio and print it to the serial port but when I add another component to the spi chain the radio no longer can connect with it's partner. There is no SS conflict, the radio's on pin 10 and the other component on pin 5 (quadruple checked).

I have searched with no success for any example of people pairing the radio with other spi components; I've only found projects with I2C sensors and then the radio on the spi bus.

Have you ever successfully added another component to the spi chain along with the radio (ie an OLED display)?
There's an old thread over at arduino.cc:
http://forum.arduino.cc/index.php?topic=186792.0
which talks about a similar difficulty only solved by going to an older lowpowerlab library.

Reduce battery power drain by enabling address filtering on both sync and address bytes

The current implementation of the library doesn't leverage the RFM69's ability to filter variable-length packets based on the sync and address bytes: this severely impacts the battery life of all the nodes within the same network because all the nodes on the network "wake up" whenever a node transmits data.

While filtering on the sync byte alone does enable the 'promiscuous mode' feature of the library, it feels like 'promiscuous mode' is a corner-case scenario (troubleshooting / network monitoring) which should not impact the much more common scenario where the radio should only "wake up" the MCU when necessary.

I believe that address filtering on both the sync and address bytes should be enabled by default in the library as it would eliminate unnecessary battery drain in the most common usage scenario.

atmega128

Connected rfm69 to atmega128
The problem with the definition of Interrupt. pin 4 is what is the interrupt number? Someone rfm69 connected to the atmega128. https://github.com/MCUdude/MegaCore

#define RFM69_CS 8
#define RFM69_IRQ 4 //pin
#define RFM69_IRQN 4// ?

RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, true, RFM69_IRQN);

TxRxBlinky on Arduino

I am attempting to run the TxRxBlinky example on an Arduino Uno, but i continue to run into problems.
I instal a switch on the Int1 and a Green LED on D9, as indicated in the file. When i compile and run the example, it compiles with no errors. When it runs i get;

Listening at 868 Mhz...
in the Serial monitor. When I press the button I get:
Button pressed!

but the green light does not light and the unit appears to lock up as i get no further reaction from the button and no further messages.

I am running the RFM69HW using a breakout board and i connecting to the 3.3v pin on the Arduino Uno. Based on other indications, i am wondering if this device uses too much power for the 3.3v supply and maybe I should use the 5v supply with a 3.3v chip? Also wondering if maybe there is something I am missing in the setup/intialization, such as telling it that this is an Arnduino Uno instead of a Moteino?

Sorry for the questions, but I am a noob and am probably just missing something obvious.

Any help would be appreciated.

ESP32 compatibility

Hi,

I was wondering if it is possible to port this library to an ESP32 and how much effort would be required?

It seems that there are some issues with the SPIFlash lib.

lib\SPIFlash-master\SPIFlash.cpp: In member function 'void SPIF
lash::select()':
lib\SPIFlash-master\SPIFlash.cpp:59:11: error: 'SPCR' was not d
eclared in this scope
_SPCR = SPCR;
^
lib\SPIFlash-master\SPIFlash.cpp:60:11: error: 'SPSR' was not d
eclared in this scope
_SPSR = SPSR;
^
lib\SPIFlash-master\SPIFlash.cpp: In member function 'void SPIF
lash::unselect()':
lib\SPIFlash-master\SPIFlash.cpp:83:3: error: 'SPCR' was not de
clared in this scope
SPCR = _SPCR;
^
lib\SPIFlash-master\SPIFlash.cpp:84:3: error: 'SPSR' was not de
clared in this scope
SPSR = _SPSR;
^
lib\SPIFlash-master\SPIFlash.cpp: In member function 'boolean S
PIFlash::initialize()':
lib\SPIFlash-master\SPIFlash.cpp:90:11: error: 'SPCR' was not d
eclared in this scope
_SPCR = SPCR;
^
lib\SPIFlash-master\SPIFlash.cpp:91:11: error: 'SPSR' was not d
eclared in this scope
_SPSR = SPSR;
^
*** [.pioenvs\esp32doit-devkit-v1\lib\SPIFlash-master\SPIFlash.
o] Error 1

Any help would be much appreciated.

Thanks in advance.

EDIT: I later realised that RFM69 is not dependant upon SPIFlash.h so the lib, together with any functions referring to it can simply be removed. Thus, no porting is required, simply import only RMF69 related libs.

Should enable Whitening by default

Lost two days debugging my application of sending 41 bytes every 33ms with no ACK. Was getting high packet loss. Forum member finally had me enable whitening with

RF_PACKET1_DCFREE_WHITENING

and problems went away. Why not have this on by default? Is there a drawback to enabling whitening all the time?

RSSI

The module RFM69HW. If the mode of radio.setHighPower(), rssi shows about 100 regardless of the signal strength. It is only in the receive mode to enable setHighPower(false),then everything responds as it should. But again setHighPower(true) as the rssi again about 100 and does not change.

ListenMode ISR hook

It would be nice to attach a function to the ListenMode ISR from user space. As it stands right now the userland code has no way of knowing if a WDT ISR or ListenMode ISR triggered the wake up.

On board GPIO

How do you access the GPIO outs from the RFM69HCW PCB ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.