GithubHelp home page GithubHelp logo

paulstoffregen / radiohead Goto Github PK

View Code? Open in Web Editor NEW
246.0 35.0 156.0 549 KB

Version of RadioHead library for Teensy boards

Home Page: http://www.airspayce.com/mikem/arduino/RadioHead/

License: Other

C++ 80.29% C 18.98% Perl 0.70% Shell 0.04%

radiohead's Introduction

radiohead's People

Contributors

kurte avatar mjs513 avatar paulstoffregen 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

radiohead's Issues

"ISR not in IRAM" crash when RH_RF95.ccp is used with ESP8266 using latest "github.com/esp8266/Arduino" code

When "#include <RH_RF95.h>" is used in the Arduino-IDE with the ESP8266 and any recent "https://github.com/esp8266/Arduino" code (eg.May19), the ESP8266 crashes at run-time at "RH_RF95.init()" with the message "ISR not in IRAM".

I succeeded in fixing this by editing the "RH_RF95.cpp" file, and changing following 3 lines:
from "void RH_RF95::isr0()" to "void ICACHE_RAM_ATTR RH_RF95::isr0()"
from "void RH_RF95::isr1()" to "void ICACHE_RAM_ATTR RH_RF95::isr1()"
from "void RH_RF95::isr2()" to "void ICACHE_RAM_ATTR RH_RF95::isr2()"

I understand that this is an issue for both the ESP8266 and the ESP32 (although I have not tested the ESP32).

I hope this info will be of use!

Library not up to date with RadioHead

Just an FYI - this version seems to be out of date with the RadioHead on AirSpayce. Currently looking at straight forward changes that are available in the updates.

Kommunication to a RN2483 node

I use the RadioHead library on a Adafruit feather M0 RFM9X LoRA radio. I select 434 freq. I have several of those and they can talk to one another. I also have some RN2438 from Microchip

In this I have the following configuration:

sys reset
mac pause
radio set wdt 0
radio set pwr 13
radio set mod lora
radio set freq 434000000
radio set cr 4/5
radio set crc on
radio set bw 125
radio set sync 12
radio set iqi on
radio set sf sf7
radio tx 0123456789ABCDEF

This is to conform to default configuration after init:

Bw125Cr45Sf128 = 0,  // < Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Default medium range

But the modules wont communicate. Is there some parameters I am missing in the RH_RF95 library?

Is Sf = 128chips/symbol the same as lora documents mean by "sf7"

/gh

ATSAMD51 Support

Hello,

I was just compiling the RadioHead library for the Adafruit feather M4 and I am unable to compile as the library only supports the ATSAMD21's timers and not the ATSAMD51s. The problem is in RH_ASK.cpp on the fallowing lines-

#elif defined (__arm__) && defined(ARDUINO_ARCH_SAMD)
    // Arduino Zero
    #define RH_ASK_ZERO_TIMER TC3
    // Clock speed is 48MHz, prescaler of 64 gives a good range of available speeds vs precision
    #define RH_ASK_ZERO_PRESCALER 64
    #define RH_ASK_ZERO_TIMER_IRQ TC3_IRQn

    // Enable clock for TC
    REG_GCLK_CLKCTRL = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TCC2_TC3)) ;
    while ( GCLK->STATUS.bit.SYNCBUSY == 1 ); // wait for sync
    
    // The type cast must fit with the selected timer mode
    TcCount16* TC = (TcCount16*)RH_ASK_ZERO_TIMER; // get timer struct
    
    TC->CTRLA.reg &= ~TC_CTRLA_ENABLE;   // Disable TC
    while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
    
    TC->CTRLA.reg |= TC_CTRLA_MODE_COUNT16;  // Set Timer counter Mode to 16 bits
    while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
    TC->CTRLA.reg |= TC_CTRLA_WAVEGEN_MFRQ; // Set TC as Match Frequency
    while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync

    // Compute the count required to achieve the requested baud (with 8 interrupts per bit)
    uint32_t rc = (VARIANT_MCK / _speed) / RH_ASK_ZERO_PRESCALER / 8;
    
    TC->CTRLA.reg |= TC_CTRLA_PRESCALER_DIV64;   // Set prescaler to agree with RH_ASK_ZERO_PRESCALER
    while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
    
    TC->CC[0].reg = rc; // FIXME
    while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
    
    // Interrupts
    TC->INTENSET.reg = 0;              // disable all interrupts
    TC->INTENSET.bit.MC0 = 1;          // enable compare match to CC0
    
    // Enable InterruptVector
    NVIC_ClearPendingIRQ(RH_ASK_ZERO_TIMER_IRQ);
    NVIC_EnableIRQ(RH_ASK_ZERO_TIMER_IRQ);
    
    // Enable TC
    TC->CTRLA.reg |= TC_CTRLA_ENABLE;
    while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync

Does anyone have the correct file that could be used with the M4? In case you need the compilation error-

C:\Users\woode\.platformio\lib\RadioHead_ID124/RadioHead.h:306:51: warning: "/*" within comment [-Wcomment]
cp /usr/local/projects/arduino/libraries/RadioHead/*.cpp .
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp: In member function 'void RH_ASK::timerSetup()':
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:246:5: error: 'REG_GCLK_CLKCTRL' was not declared in this scope
REG_GCLK_CLKCTRL = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TCC2_TC3)) ;
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:246:36: error: 'GCLK_CLKCTRL_CLKEN' was not declared in this scope
REG_GCLK_CLKCTRL = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TCC2_TC3)) ;
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:246:57: error: 'GCLK_CLKCTRL_GEN_GCLK0' was not declared in this scope
REG_GCLK_CLKCTRL = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TCC2_TC3)) ;
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:246:110: error: 'GCLK_CLKCTRL_ID' was not declared in this scope
REG_GCLK_CLKCTRL = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TCC2_TC3)) ;
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:247:19: error: 'struct Gclk' has no member named 'STATUS'
while ( GCLK->STATUS.bit.SYNCBUSY == 1 ); // wait for sync
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:253:27: error: 'volatile struct TC_STATUS_Type::<anonymous>' has no member named 'SYNCBUSY'
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:256:27: error: 'volatile struct TC_STATUS_Type::<anonymous>' has no member named 'SYNCBUSY'
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:257:22: error: 'TC_CTRLA_WAVEGEN_MFRQ' was not declared in this scope
TC->CTRLA.reg |= TC_CTRLA_WAVEGEN_MFRQ; // Set TC as Match Frequency
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:258:27: error: 'volatile struct TC_STATUS_Type::<anonymous>' has no member named 'SYNCBUSY'
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:264:27: error: 'volatile struct TC_STATUS_Type::<anonymous>' has no member named 'SYNCBUSY'
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:267:27: error: 'volatile struct TC_STATUS_Type::<anonymous>' has no member named 'SYNCBUSY'
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
^
C:\Users\woode\.platformio\lib\RadioHead_ID124\RH_ASK.cpp:279:27: error: 'volatile struct TC_STATUS_Type::<anonymous>' has no member named 'SYNCBUSY'
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync

Thank you,
Sam

Couldn't achieve long range RH_RF95

I'm working on a project using LoRa module Ra-01 Ai-thinker which is operating at 433 Mhz connected to an Arduino Nano.
i used the example codes in RH_RF95 to transmit and receive data between 2 nodes.
However i only can achieve a range of approx 30meters.
Anybody can help me out how can i achieve further range?
Tried adjusting the transmitting power still but still no improvement.

What I am doing is that:
-Sender will send "on/off" or "blink" to turn on/off or blink the receiver's LED

-Receiver receives data from sender and turns on/off or blink LED
-Then it sends back an acknowledgement back to the sender

Sender code
`
#include <SPI.h>
#include <RH_RF95.h>

#define RH_RF95_LONG_RANGE_MODE 0x80

typedef enum
{
Bw125Cr45Sf128 = 0, ///< Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Default medium range
Bw500Cr45Sf128, ///< Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Fast+short range
Bw31_25Cr48Sf512, ///< Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, CRC on. Slow+long range
Bw125Cr48Sf4096, ///< Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, CRC on. Slow+long range
} ModemConfigChoice;

int lastButtonState1 = HIGH;
int lastButtonState2 = HIGH;
int buttonState1;
int buttonState2;
unsigned long lastDebounceTime1 = 0;
unsigned long lastDebounceTime2 = 0;
unsigned long debounceDelay = 20;
const int onoffbuttonpin = 4;
const int blinkbuttonpin = 5;
String data;
int redPin = 6;
int greenPin = 7;
int bluePin = 8;
int info;
int flag = 0;

// Singleton instance of the radio driver
RH_RF95 SX1278;

void setup() {
Serial.begin(9600);
while (!Serial) ;
if (!SX1278.init())
Serial.println("Notice:init failed");
SX1278.setFrequency(433.0);
SX1278.setTxPower(20);
bool setModemConfig(ModemConfigChoice Bw125Cr48Sf4096);

pinMode(onoffbuttonpin, INPUT_PULLUP);
pinMode(blinkbuttonpin, INPUT_PULLUP);

pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);

digitalWrite(redPin, HIGH); // turn on RED during setup

}

void loop() {
uint8_t on[] = "on";
uint8_t off[] = "off";
int reading1 = digitalRead(onoffbuttonpin);
int reading2 = digitalRead(blinkbuttonpin);

if (reading1 != lastButtonState1) {

lastDebounceTime1 = millis();

}

if ((millis() - lastDebounceTime1) > debounceDelay) {

if (reading1 != buttonState1) {
  buttonState1 = reading1;

  if (buttonState1 == LOW) {
    SX1278.send(on, sizeof(on));
    Serial.println((char*)on);
    SX1278.waitPacketSent();
    digitalWrite(redPin, LOW);
    digitalWrite(greenPin, HIGH);
    flag = 1;    
  }
}

}
lastButtonState1 = reading1;

if (reading2 != lastButtonState2) {

lastDebounceTime2 = millis();

}

if ((millis() - lastDebounceTime2) > debounceDelay) {

if (reading2 != buttonState2) {
  buttonState2 = reading2;

  if (buttonState2 == LOW) {
SX1278.send(off, sizeof(off));
Serial.println((char*)off);
SX1278.waitPacketSent();
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);    
flag = 1;
  }
}

}
lastButtonState2 = reading2;

if(flag = 1){
if (SX1278.available())
{
// Should be a message for us now
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (SX1278.recv(buf, &len)){
String data = (char*)buf;
Serial.println(data);
Serial.println("RSSI");
Serial.println(SX1278.lastRssi(), DEC);

  if(data == "ack"){
     flag = 0;
     Serial.println("Received packet ack please wait 2 seconds");
     delay(500);
     digitalWrite(greenPin, LOW);
     digitalWrite(bluePin, HIGH);
     delay(1500);
     digitalWrite(bluePin, LOW);
     digitalWrite(redPin, HIGH);         
      }
    }
 } 

}
} //end loop
`

Receiver code
`
#include <SPI.h>
#include <RH_RF95.h>

#define RH_RF95_LONG_RANGE_MODE 0x80

typedef enum
{
Bw125Cr45Sf128 = 0, ///< Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Default medium range
Bw500Cr45Sf128, ///< Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Fast+short range
Bw31_25Cr48Sf512, ///< Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, CRC on. Slow+long range
Bw125Cr48Sf4096, ///< Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, CRC on. Slow+long range
} ModemConfigChoice;
uint8_t ack[] = "ack";
RH_RF95 SX1278;

void setup() {
Serial.begin(9600);
while (!Serial) ; // Wait for serial port to be available
pinMode(3,OUTPUT);
digitalWrite(3,LOW);
if (!SX1278.init())
Serial.println("init failed");
SX1278.setFrequency(433.0);
SX1278.setTxPower(20);
bool setModemConfig(ModemConfigChoice Bw125Cr48Sf4096);

}

void loop() {
if (SX1278.available())
{
// Should be a message for us now
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
int flag = 1;
if (SX1278.recv(buf, len))
{
Serial.println((char*)buf);
String data = (char*)buf;
if (data == "on"){
Serial.println("1");
Serial.println("RSSI");
Serial.println(SX1278.lastRssi(), DEC);

        if(digitalRead(3) == LOW){
        led_on();
        send_ack();             
       }
       
        else if(digitalRead(3) == HIGH){
        led_off();
        send_ack();            
        }  
       }      
       
    
     else if(data == "off"){
      Serial.println("2");
      Serial.println("RSSI"); 
        Serial.println(SX1278.lastRssi(), DEC);
      led_blink();
      send_ack(); 
  }
    else
    {
        Serial.println("Invalid");
        
    }

}
}
}

void led_on(){
digitalWrite(3, HIGH);
//delay(1000);
}

void led_off(){
digitalWrite(3, LOW);
//delay(1000);
}

void led_blink(){
for(int i = 0; i<5; i++){
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
}
}

void send_ack(){
SX1278.send(ack, sizeof(ack));
Serial.println("sending ack");
Serial.println((char*)ack);
SX1278.waitPacketSent();
}
`

problem at nodemcu 1.0

hello,

i have a boring problem with a webserver running on nodemcu 1.0 using ask_reliable_datagram_client. i identified this codeline to stop the server working ...

	**dtostrf(gTemp, 10, 2, reinterpret_cast<char *>(&data));** 
	data[0] = 'T';
	manager.sendtoWait(data, sizeof(data), ServerAdr);

i tried several options to bring "data" into uint8_t dataformat with different succes - from immediate crash till some hours of working. if i comment out the dtostrf the server works well again (also sprintf does not work).

have somebody an idea why this happens?

best regards
andreas

Larger Address Space

Hello,

I have a use case that would require me to potentially have an address space larger than 8 bits. Is there any method for accomplishing this functionality using this library?

Also, is there any known technique for allocating addresses without collisions or hard-coding the addresses into firmware.

Any help much appreciated - and thank you for your work on this library,

Andrew

Servo.h ahd RH_RF2.h multiple definition of `__vector_11'

this is what is causing the problem
#include <SPI.h>
#include <RH_RF22.h>
#include <Servo.h>

this is what error i've got:

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `__vector_11'

libraries\RadioHead\RH_ASK.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Pro or Pro Mini.

Teensy 3.1 not able to init() nrf24l01+

I am sure after a week of trying that wires are correctly connected proper voltage (3.24V ) and capacitor 10uF is connected to nrf24. same circuit with pro mini is working as server and client.
Now I am trying to upgrade my project to teensy 3.1 and it fails in init() at
if (spiReadRegister(RH_NRF24_REG_1D_FEATURE) != (RH_NRF24_EN_DPL | RH_NRF24_EN_DYN_ACK)){
return false;

wiring is proper for sure.
I have tried all possible things for now.
my arduino is 1.6.3 and teensyduino 1.23.

NRF24.send lose my end data but for next time send that

Hi ,
I wanted you to tell me how can I solve this problem
which I send my data from master like 5 times
but in slave or client the receive is 4 time then when you send the sixth (from master)
the receiver shows the 5th,
I appreciate if you help me,
thanks lot,

void RH_RF69::setOpMode(uint8_t mode) hangs in example rf69_server

I did not manage to get the example rf69_server working.
It hangs in void RH_RF69::setOpMode(uint8_t mode)
at
// Wait for mode to change.
while (!(spiRead(RH_RF69_REG_27_IRQFLAGS1) & RH_RF69_IRQFLAGS1_MODEREADY)) ;
Strange thing is, receiver works, and if I merge receiver and sender to the same ino and let them run on the same Arduino uno, than it works.
Switching to lowpower lib examples works straight.
Something is wrong. I wonder that I´m the only one.

Safety issues with ENCYPTION KEY?

I made some test with two very short programs (based on your examples!) on the feather... the dont have the same ENCRYPTION KEY but the receiver is still getting frequently messages from rf69_manager.available() ! Whats wrong here! Huge problem !!

Last hex on the TX and RX are different!

Message avaible!!
Sending failed (no ack)
Message avaible!!
Sending failed (no ack)
Message avaible!!
Sending failed (no ack)
Message avaible!!
Sending failed (no ack)
Message avaible!!
Sending failed (no ack)
Message avaible!!
Sending failed (no ack)
Message avaible!!
Sending failed (no ack)
Message avaible!!
Sending failed (no ack)
Message avaible!!
Sending failed (no ack)
Message avaible!!
Sending failed (no ack)
Message avaible!!
Sending failed (no ack)

TX:

// rf69 demo tx rx.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple addressed, reliable messaging client
// with the RH_RF69 class. RH_RF69 class does not provide for addressing or
// reliability, so you should only use RH_RF69  if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example rf69_server.
// Demonstrates the use of AES encryption, setting the frequency and modem
// configuration

#include <SPI.h>
#include <RH_RF69.h>
#include <RHReliableDatagram.h>
/************ Radio Setup ***************/

// Change to 434.0 or other frequency, must match RX's freq!
#define RF69_FREQ 433.0

// Where to send packets to!
#define DEST_ADDRESS   1
// change addresses for each client board, any number :)
#define MY_ADDRESS     2

  #define RFM69_CS      8
  #define RFM69_INT     3
  #define RFM69_RST     4
  #define LED           13


// Singleton instance of the radio driver
RH_RF69 rf69(RFM69_CS, RFM69_INT);

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram rf69_manager(rf69, MY_ADDRESS);

struct package {
  uint8_t value1 = 1;
  uint16_t value2 = 222;
  uint8_t value3 = 3;
  uint8_t value4 = 4;
} remPackage;

struct callback {
  float value1 = 100.0;
  float value2 = 200.0;
  long value3 = 300;
  long value4 = 400;
  uint8_t value5 = 5;
  float value6 = 600.0;
  float value7 = 700.0;
  float value8 = 800.0;
  bool value9 = true;
} returnData;

void setup()
{
  Serial.begin(115200);
  //while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer

  pinMode(LED, OUTPUT);
  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, LOW);

  Serial.println("Feather Addressed RFM69 TX Test!");
  Serial.println();

  // manual reset
  digitalWrite(RFM69_RST, HIGH);
  delay(10);
  digitalWrite(RFM69_RST, LOW);
  delay(10);

  if (!rf69_manager.init()) {
    Serial.println("RFM69 radio init failed");
    while (1);
  }
  Serial.println("RFM69 radio init OK!");
  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM (for low power module)
  // No encryption
  if (!rf69.setFrequency(RF69_FREQ)) {
    Serial.println("setFrequency failed");
  }

  // If you are using a high power RF69 eg RFM69HW, you *must* set a Tx power with the
  // ishighpowermodule flag set like this:
  rf69.setTxPower(20);  // range from 14-20 for power, 2nd arg must be true for 69HCW

  // The encryption key has to be the same as the one in the server
  uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x02};
  rf69.setEncryptionKey(key);

  pinMode(LED, OUTPUT);

  Serial.print("RFM69 radio @");  Serial.print((int)RF69_FREQ);  Serial.println(" MHz");
}


// Dont put this on the stack:

uint8_t len = sizeof(remPackage);

void loop() {
  delay(50);  // Wait 50 ms between transmits, could also 'sleep' here!

  // Send a message to the DESTINATION!
  if (rf69_manager.sendtoWait((uint8_t *)&remPackage, len, DEST_ADDRESS)) {
    // Now wait for a reply from the server
    len = sizeof(returnData);
    uint8_t from;
    if (rf69_manager.recvfromAckTimeout((uint8_t *)&returnData, &len, 50, &from)) {

      Serial.print("Got reply from #"); Serial.print(from);
      Serial.print(" [RSSI :");
      Serial.print(rf69.lastRssi());
      Serial.print("] : ");
      Serial.print("value1 ");Serial.println(returnData.value1);
      Serial.print("value2 ");Serial.println(returnData.value2);
      Serial.print("value3 ");Serial.println(returnData.value3);
      Serial.print("value4 ");Serial.println(returnData.value4);
    } else {
      Serial.println("No reply, is anyone listening?");
    }
  } else {
    Serial.println("Sending failed (no ack)");
  }
}

RX:

// rf69 demo tx rx.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple addressed, reliable messaging client
// with the RH_RF69 class. RH_RF69 class does not provide for addressing or
// reliability, so you should only use RH_RF69  if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example rf69_server.
// Demonstrates the use of AES encryption, setting the frequency and modem
// configuration

#include <SPI.h>
#include <RH_RF69.h>
#include <RHReliableDatagram.h>

/************ Radio Setup ***************/

// Change to 434.0 or other frequency, must match RX's freq!
#define RF69_FREQ 433.0

// who am i? (server address)
#define MY_ADDRESS     1

  #define RFM69_CS      8
  #define RFM69_INT     3
  #define RFM69_RST     4

// Singleton instance of the radio driver
RH_RF69 rf69(RFM69_CS, RFM69_INT);

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram rf69_manager(rf69, MY_ADDRESS);

struct package {
  uint8_t value1 = 1;
  uint16_t value2 = 222;
  uint8_t value3 = 3;
  uint8_t value4 = 4;
} remPackage;

struct callback {
  float value1 = 100.0;
  float value2 = 200.0;
  long value3 = 300;
  long value4 = 400;
  uint8_t value5 = 5;
  float value6 = 600.0;
  float value7 = 700.0;
  float value8 = 800.0;
  bool value9 = true;
} returnData;

void setup()
{
  Serial.begin(115200);
  while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer

  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, LOW);

  Serial.println("Feather Addressed RFM69 RX Test!");
  Serial.println();

  // manual reset
  digitalWrite(RFM69_RST, HIGH);
  delay(10);
  digitalWrite(RFM69_RST, LOW);
  delay(10);

  if (!rf69_manager.init()) {
    Serial.println("RFM69 radio init failed");
    while (1);
  }
  Serial.println("RFM69 radio init OK!");
  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM (for low power module)
  // No encryption
  if (!rf69.setFrequency(RF69_FREQ)) {
    Serial.println("setFrequency failed");
  }

  // If you are using a high power RF69 eg RFM69HW, you *must* set a Tx power with the
  // ishighpowermodule flag set like this:
  rf69.setTxPower(20);  // range from 14-20 for power

  // The encryption key has to be the same as the one in the server
  uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01};
  rf69.setEncryptionKey(key);

  Serial.print("RFM69 radio @");  Serial.print((int)RF69_FREQ);  Serial.println(" MHz");
}

// Dont put this on the stack:
uint8_t data[] = "And hello back to you";
// Dont put this on the stack:

void loop() {
  if (rf69_manager.available())
  {
    Serial.println("Message avaible!!");
    // Wait for a message addressed to us from the client
    uint8_t len = sizeof(remPackage);
    uint8_t from;
    if (rf69_manager.recvfromAckTimeout((uint8_t*)&remPackage, (uint8_t*)&len, 50, &from)) {
      if (returnData.value1 > 1 || returnData.value2 > 222 || returnData.value3 > 3 || returnData.value4 > 4){
        Serial.print("Got reply from #"); Serial.print(from);
        Serial.print(" [RSSI :");
        Serial.print(rf69.lastRssi());
        Serial.println("] : ");
        Serial.print("value1: ");Serial.println(returnData.value1);
        Serial.print("value2: ");Serial.println(returnData.value2);
        Serial.print("value3: ");Serial.println(returnData.value3);
        Serial.print("value4: ");Serial.println(returnData.value4);
        }
      }

      // Send a reply back to the originator client
      len = sizeof(returnData);
      if (!rf69_manager.sendtoWait((uint8_t*)&returnData, len, from)){
        Serial.println("Sending failed (no ack)");
    }
  }
}

RadioHead RF95 interrupt bug

RadioHead/RH_RF95.cpp:90

On the mentioned line the interrupt pin is set as an input. This happens after attaching the interrupt to the pin. On the TeensyLC I tested with, this caused the interrupt to not work.

Fix:

  1. Move the line where the pin is set as an input to before attaching the interrupt. It should be around line 60.
    -or-
  2. Update the RadioHead library to the latest one, as it is fixed in the latest version.

RH_RF69 send hang due to waitPacketSent failed

Hi
I have problems with stable transmissions for the RFM69. Initialization seems to be fine, but when I transmit with _spRFM->send(_spData, 2) sometimes the call will never come back. It looks like the internal call waitPacketSend() is the reason. Does someone know what the reasons are for not returning from waitPacketSend? The comparison inside is while (_mode == RHModeTx). But what is responsible for not "leaving" the transmission-mode? Can it be that it is something like too much noise on the radio frequency or no receiver found? As far as I understand it is not a confirmed transmission, it is fire and forget?

Investigating further, it looks like the interrupt is not called. After that, the mode is for ever RHModexTX (which makes sense). The question is now, what can create such a scenario? Instable power supply? Some time the interrupt is fine, sometimes not.

Has someone an idea?

Kind regards
Pix

Error compiling ask_transmitter example on Arduino Nano Every

Hi!

I´m trying to get started with the library on a Nano Every but the interrupt attachments seem "unpopular" with the compiler. First I got this message:

Arduino: 1.8.10 (Windows 10), Board: "Arduino Nano Every, None (ATMEGA4809)"

C:\Users\frol\Documents\Arduino\libraries\RadioHead\RH_Serial.cpp:11:11: fatal error: HardwareSerial.h: No such file or directory

Multiple libraries were found for "RH_ASK.h"
  #include <HardwareSerial.h>

 Used: C:\Users\frol\Documents\Arduino\libraries\RadioHead
           ^~~~~~~~~~~~~~~~~~

Multiple libraries were found for "SPI.h"
compilation terminated.

 Used: C:\Users\frol\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\libraries\SPI
exit status 1
Error compiling for board Arduino Nano Every.

I then moved the missing files in STM32ArduinoCompat up one level and tried again
Then I got this:

Arduino: 1.8.10 (Windows 10), Board: "Arduino Nano Every, None (ATMEGA4809)"

C:\Users\frol\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp: In member function 'virtual void RHHardwareSPI::attachInterrupt()':

C:\Users\frol\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:70:9: error: 'static void SPIClass::attachInterrupt()' is private within this context

     SPI.attachInterrupt();

         ^~~~~~~~~~~~~~~

In file included from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RadioHead.h:1269:0,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RHGenericSPI.h:10,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RHHardwareSPI.h:10,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:7:

C:\Users\frol\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\libraries\SPI\src/SPI.h:177:22: note: declared private here

   inline static void attachInterrupt() { SPI0.INTCTRL |= (SPI_IE_bm); }

                      ^~~~~~~~~~~~~~~

C:\Users\frol\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:70:25: error: 'static void SPIClass::attachInterrupt()' is private within this context

     SPI.attachInterrupt();

                         ^

In file included from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RadioHead.h:1269:0,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RHGenericSPI.h:10,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RHHardwareSPI.h:10,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:7:

C:\Users\frol\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\libraries\SPI\src/SPI.h:177:22: note: declared private here

   inline static void attachInterrupt() { SPI0.INTCTRL |= (SPI_IE_bm); }

                      ^~~~~~~~~~~~~~~

C:\Users\frol\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp: In member function 'virtual void RHHardwareSPI::detachInterrupt()':

C:\Users\frol\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:77:9: error: 'static void SPIClass::detachInterrupt()' is private within this context

     SPI.detachInterrupt();

         ^~~~~~~~~~~~~~~

In file included from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RadioHead.h:1269:0,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RHGenericSPI.h:10,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RHHardwareSPI.h:10,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:7:

C:\Users\frol\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\libraries\SPI\src/SPI.h:178:22: note: declared private here

   inline static void detachInterrupt() { SPI0.INTCTRL &= ~(SPI_IE_bm); }

                      ^~~~~~~~~~~~~~~

C:\Users\frol\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:77:25: error: 'static void SPIClass::detachInterrupt()' is private within this context

     SPI.detachInterrupt();

                         ^

In file included from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RadioHead.h:1269:0,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RHGenericSPI.h:10,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead/RHHardwareSPI.h:10,

                 from C:\Users\frol\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:7:

C:\Users\frol\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\libraries\SPI\src/SPI.h:178:22: note: declared private here

   inline static void detachInterrupt() { SPI0.INTCTRL &= ~(SPI_IE_bm); }

                      ^~~~~~~~~~~~~~~

Multiple libraries were found for "RH_ASK.h"
 Used: C:\Users\frol\Documents\Arduino\libraries\RadioHead
Multiple libraries were found for "SPI.h"
 Used: C:\Users\frol\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\libraries\SPI
exit status 1
Error compiling for board Arduino Nano Every.

Is my problem that the library isn´t supporting the Every board or am I missing something?

Thank you for any help!

RH_ASK.h compiles with NANO, wont compile with NANO EVERY

Here is the output from the compiler, IDE 1.8.16. A NANO EVERY is attached to the USB. All libraries have been upgraded to current. If #include <RH_ASK.h> is commented out, (//), the test code runs OK. Removing the // and an error is displayed by the compiler. It appears that setBitOrder might have a problem (?). If an "ordinary" NANO is substituted for the EVERY, the test code runs without any problems. The IDE is running in a Windows 7 partition within a MacBook running OS Catalina:

\Mac\Home\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp: In member function 'virtual void RHHardwareSPI::attachInterrupt()':
\Mac\Home\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:49:25: error: 'virtual void SPIClassMegaAVR::attachInterrupt()' is private within this context
SPI.attachInterrupt();
^
In file included from \Mac\Home\Documents\Arduino\libraries\RadioHead/RadioHead.h:540:0,
from \Mac\Home\Documents\Arduino\libraries\RadioHead/RHGenericSPI.h:10,
from \Mac\Home\Documents\Arduino\libraries\RadioHead/RHHardwareSPI.h:10,
from \Mac\Home\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:7:
C:\Users\David Richardson\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\libraries\SPI\src/SPI.h:186:15: note: declared private here
inline void attachInterrupt() { SPI0.INTCTRL |= (SPI_IE_bm); }
^~~~~~~~~~~~~~~
\Mac\Home\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp: In member function 'virtual void RHHardwareSPI::detachInterrupt()':
\Mac\Home\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:56:25: error: 'virtual void SPIClassMegaAVR::detachInterrupt()' is private within this context
SPI.detachInterrupt();
^
In file included from \Mac\Home\Documents\Arduino\libraries\RadioHead/RadioHead.h:540:0,
from \Mac\Home\Documents\Arduino\libraries\RadioHead/RHGenericSPI.h:10,
from \Mac\Home\Documents\Arduino\libraries\RadioHead/RHHardwareSPI.h:10,
from \Mac\Home\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:7:
C:\Users\David Richardson\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\libraries\SPI\src/SPI.h:187:15: note: declared private here
inline void detachInterrupt() { SPI0.INTCTRL &= ~(SPI_IE_bm); }
^~~~~~~~~~~~~~~
\Mac\Home\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp: In member function 'virtual void RHHardwareSPI::begin()':
\Mac\Home\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:92:29: warning: invalid conversion from 'uint8_t {aka unsigned char}' to 'BitOrder' [-fpermissive]
SPI.setBitOrder(bitOrder);
^
In file included from \Mac\Home\Documents\Arduino\libraries\RadioHead/RadioHead.h:540:0,
from \Mac\Home\Documents\Arduino\libraries\RadioHead/RHGenericSPI.h:10,
from \Mac\Home\Documents\Arduino\libraries\RadioHead/RHHardwareSPI.h:10,
from \Mac\Home\Documents\Arduino\libraries\RadioHead\RHHardwareSPI.cpp:7:
C:\Users\David Richardson\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\libraries\SPI\src/SPI.h:171:8: note: initializing argument 1 of 'void SPIClassMegaAVR::setBitOrder(BitOrder)'
void setBitOrder(BitOrder order);
^~~~~~~~~~~
exit status 1
Error compiling for board Arduino Nano Every.

Usage of Cad Detection

Hi, there is a plan to use the CAD detection feature on the sx1276 modules to enable the detection on more the one channel?

Thanks guys

RH95 driver not interrupt safe on ESP8266

I am playing around with SX1296 modules connected to ESP8266's and found out that the interrupt handlers called within the various layers of drivers (RH95, various SPI layers, ...) are not ESP8266 interrupt safe (they do not have the ICACHE_RAM_ATTR).

I also had to modify Arduino's ESP8266 core SPI library as I also found this one "not interrupt safe".

For now, I have made my own mods and seem to now have a stable ESP8266 implementation (scope to RH95 for now).

Am I the only one to have met those issues?

If any interrest, I am happy to share the mods even if they are limited to RH95 support.

how to disable CRC check in RF95?

Now I want to keep all of the packets received at the LoRa server or LoRa shield.
However, in current implementation of RadioHead, with enabling CRC, only packets that pass CRC check will be keeped.

I have tried my best to disable CRC but it can not work.
I have looked up from the datasheet sx1276_77_78_79 to find the register, and modify the corresponding value for RxPayloadCrcOn in RegModemConfig2(0x1E).
According to the description,

Enable CRC generation and check on payload:
0 -> CRC disable
1 -> CRC enable
If CRC is needed, RxPayloadCrcOn should be set:

  • in Implicit header mode: on Tx and Rx side
  • in Explicit header mode: on the Tx side alone (recovered from
    the header in Rx side)

Then it should be worked when I add a new function like this.

void RH_RF95::setCRCState(int8_t crcState)
{
spiWrite(RH_RF95_REG_1E_MODEM_CONFIG2, (spiRead(RH_RF95_REG_1E_MODEM_CONFIG2) & 0xfb) | ((crcState << 2) & 0x04));
}

According to the output from the serial, I have successfully modified the value of RxPayloadCrcOn from 1 to 0.
However, when I recompile the sketch of LoRa_client and LoRa_server.
The LoRa shield can not received the packets from the LoRa server anymore.

Therefore, how to disable CRC check correctly?

NRF24L01 Packet Queueing Problem

I am trying to create a simple TCP-like sending protocol by sending, waiting for an ack, and if no ack is received in a certain amount of time, try again.

I got it mostly working except for a frequent, but random occurring problem. The recipient will randomly miss a packet, but when the next packet is received, it receives the previous missed packet. I have tried clearing and flusing the rx buffer, but to no avail. It appears as if the rx queue is receiving it, but it cannot be detected until another packet is received.

Perhaps a packet is available, but available() is returning an incorrect value?

Here is thread from the arduino forum that mentions a similar issue:

Here is the output that demonstrates this issue
screen shot 2017-06-01 at 1 16 01 pm

Sender Code

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24(9, 8); //my implementation

void setup() {
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");
}

void loop() {
  delay(2000);
  uint8_t data1[] = "testtesttest";
  sendTCP(data1, sizeof(data1));
}

int timeout = 200;
byte maxAttempts = 1;
bool sendTCP(uint8_t *data, uint8_t len) {
  static uint8_t packetId = 0;
  byte attempts = 0;

  Serial.print(millis());
  Serial.println(": TCP sending");
  Serial.print("  packet id: ");
  Serial.println(packetId);
  
  while(attempts < maxAttempts) {
    //send data
    nrf24.setHeaderId(packetId);  //set packet id in order to differentiate between packets and their ack
    nrf24.send(data, len);        //send data
    nrf24.waitPacketSent();       //block while data is sending
    
    //wait for ack
    //Serial.println("  waiting for ack");
    uint8_t temp_buf[RH_NRF24_MAX_MESSAGE_LEN];
    uint8_t temp_len = sizeof(temp_buf);
    if(nrf24.waitAvailableTimeout(timeout) && nrf24.recv(temp_buf, &temp_len)) {
      Serial.print("  ack received...");
      if(nrf24.headerId() == packetId) {
        Serial.println("id match");
        break;
      }
      Serial.print("no id match ");
      Serial.print(nrf24.headerId());
      Serial.println(", clearing buffer");
      while(nrf24.available() && nrf24.recv(temp_buf, &temp_len)) { //clear buffer in case there is more than 1 packet
        ; //no-op
      }
    }
    attempts++;

    Serial.print("  ack timeout, sending again ");
    Serial.print(attempts);
    Serial.print(" / ");
    Serial.println(maxAttempts);
  }

  packetId++;

  if(attempts >= maxAttempts) {
    Serial.println("  sending failed");
    return false;
  }
  Serial.println("  sending succeeded");
  return true;
}

Receiver Code

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24(9, 8); //my implementation

void setup() {
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");
}

void loop() {
  uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  if(nrf24.available() && recvTCP(buf, &len)) {
    ;
  }
}

bool recvTCP(uint8_t* buf, uint8_t* len) {
  static int packetId = -1;
  Serial.print(millis());
  Serial.print(": Checking if data available...");
  if(nrf24.recv(buf, len)) {
    //send ack
    uint8_t data[] = "";
    nrf24.setHeaderId(nrf24.headerId()); //set packet id to received packet's header id
    nrf24.send(data, sizeof(data));      //send data (ack)
    nrf24.waitPacketSent();              //block while ack is sending

    //repeat packet
    if(nrf24.headerId() == packetId) {   //server didn't get our ack, so it sent the packet again, just ack again and ignore
      Serial.print("yes, repeat packet: ");
      Serial.println(packetId);
      nrf24.flushRx();
      nrf24.clearRxBuf();
      return false;
    }
    
    packetId = nrf24.headerId();         //remember our last received packet id
    
    Serial.print("yes: ");
    Serial.println(packetId);
    Serial.print("   Received message: ");
    Serial.println((char*)buf);
  } else {
    Serial.println("no");
    nrf24.flushRx();
    nrf24.clearRxBuf();
    return false;
  }
  nrf24.flushRx();
  nrf24.clearRxBuf();
  return true;
}

Separate networks on RH_RF95

Hello!

I working with LoRa on RH_RF95 and I would like to separate two networks which can works around self. I tried to make SyncWord but it not works (producer give me info about that).

I'm trying to add param "networkId" to RadioHead lib to check that packet is coming from network of my node. NetworkId is something like Address of node but it could make bigger grids in LoRa.

I know that I need to add 1 byte (networkId) to header of send packet and i know that i need compare byte in receive packet but I have problem with implement in this library.

Anybody can help me?

Best Regards!
Patryk

RH_NRF24.h: No such file or directory

Hello friends, this is first time I am using RH_NRF24.h, but as I try to upload code its say No such file or directory. So please help me to solve this issue, I am struggling a lot to solve this but I am stuck on it. PLEASE HELP ME TO SOLVE THIS AS SOON AS POSSIBLE.

htons redefined

Hi,
On ESP8266 I've got many warning regarding ntohs and htons redefined. This name is in conflict with ESP8266WiFi Library.
I've resolved renaming all ntoh and hton definitions to rh_ntoh and rh_hton in RadioHead.h lines1700-1720
It do not create new warning or error on compiling. Can you check if this mod can cause some other problems? I' was'nt able to find any occurrency about these names in whole library, so I supposed it is unused.

Issue with Arduino Mega board (and probably others ?)

Tested RH_NRF24 with Arduino Maga.
The documentation says

/// For an Arduino Mega:
/// \code
///                 Mega         Sparkfun WRL-00691
///                 5V-----------VCC   (3.3V to 7V in)
///             pin D8-----------CE    (chip enable in)
///          SS pin D53----------CSN   (chip select in)
///         SCK pin D52----------SCK   (SPI clock in)
///        MOSI pin D51----------SDI   (SPI Data in)
///        MISO pin D50----------SDO   (SPI data out)
///                              IRQ   (Interrupt output, not connected)
///                 GND----------GND   (ground in)
/// \endcode
/// and you can then use the constructor RH_NRF24(8, 53). 

But that does not work, as the file RadioHead.h sets "SS" in an incorrect way.
In the Arduino pins_arduino.h file you find (for the Mega)

#define PIN_SPI_SS    (53)
#define PIN_SPI_MOSI  (51)
#define PIN_SPI_MISO  (50)
#define PIN_SPI_SCK   (52)

static const uint8_t SS   = PIN_SPI_SS;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK  = PIN_SPI_SCK;

So SS is a static const of type uint8_t !!!
In the file RadioHead.h SS is set with "#define", and you find

// Slave select pin, some platforms such as ATTiny do not define it.
#ifndef SS
 #define SS 10
#endif

As a result, for the Mega, SS is defined as pin 10 :-( :-(

You can easily test this. A simple sketch

#include <SPI.h>
void setup() {
  Serial.begin(115200);
  Serial.println(SS);
}
void loop() {
}

shows correctly 53 on the Serial monitor, while

#include <RH_NRF24.h>
#include <SPI.h>
void setup() {
  Serial.begin(115200);
  Serial.println(SS);
}
void loop() {
}

shows 10 ! :-(

Work around : use pin 10 for SS and initialize as
RH_NRF24 nrf24(8, 10);

Please add support for B-L072Z-LRWAN1 - STM32L0 Discovery kit

Hi there,
I am using Radiohead library since 2015 and I love this library to use in my university project. I like to request the team of this library to add support for B-L072Z-LRWAN1 - STM32L0 Discovery kit. Its a great kit with in build sx1276 LoRa module with strong STM32L0 micro-controller. It would very nice if you could manage some time and add support for this kit (it is cost effective compared to other devices) .

Thanks in advance

Struggling using RF95 in an Interrupt function (ISR), help please !

Hello,

I'm struggling using the RH_RF95 with an ISR. I need to send a message when a pin's state change. But when the state change the serial is just freezing and nothing is sent. This issue disapear when I comment this line :
rf95.send(data, sizeof(data));
My interrupt PIN is 3 on Arduino Uno, could the issue come from here ? Or maybe it's not possible to use LoRa comm insisde ISR ? Thank you for your time !

Here is my code :

// I2C Master
// Include the required Wire library for I2C
#include <Wire.h>
#include <SPI.h>
#include <RH_RF95.h>

// Singleton instance of the radio driver
RH_RF95 rf95;

const byte interruptPin = 3;

void setup() {
  Serial.begin(9600);
  Wire.begin();    // Start the I2C Bus as Master

  pinMode(BUZZER_PIN, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  
  attachInterrupt(digitalPinToInterrupt(interruptPin), InterruptVol, CHANGE); 
 

  //Initialize LoRa Module
  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    while (1);
  }

  Serial.println("SETUP FINISHED !");
  Serial.println("");
}

void InterruptVol(){  
  Serial.println("INTERRUPTION");
  alerte = true;
  if(digitalRead(interruptPin)){
    SendAlertMessage(); // LoRa ne marche pas dans fct d'interruption
  } else {
    alerte = false;
    noTone(BUZZER_PIN);
  }
}

void SendAlertMessage(){
  blabla...

  SendLoraData(msgAlerte);
}

void SendLoraData(char data[]) {
    Serial.print("[LoRa] Sending data... ");
    data[strlen(data)]='\0';
    //Serial.println(data); //debug
    rf95.send(data, sizeof(data));
    Serial.println(" Data sent ! ");
    rf95.waitPacketSent(1000);
  
  delay(1000);
}

Example code cleanup : remove unused variable declaration

On line 27 of the loop() functon of the ask_receiver.pde example sketch, there's a variable "i" declared that appears to serve no function:
int i;

No biggie, but for the sake of not confusing people thought it might be best to remove this!

Cheers.

stm32l0_gpio.h not found

Error during compilation for STM32L031 Nucleo-32 (Nucleo-L031K6)

  C:\Users\me\Documents\Arduino\libraries\RadioHead/RadioHead.h:1502:11: fatal error: stm32l0_gpio.h: No such file or directory
  1502 |  #include <stm32l0_gpio.h>
       |           ^~~~~~~~~~~~~~~~

Caused by this line:
#include <RH_RF22.h>

Arduino Due client/server for nRF905 - missing PWR set HIGH after init()

Had no success connecting up pair of Arduino Due each with Duinotech XC-4522 RF433MHz modules. XC-4522 uses nRF905. Wired up as per the RadioHead example code instructions.

Eventually found this, claiming that the PWR pin was not connected or used in the Radiohead code:
http://www.edaboard.com/thread338917.html

So I did as they recommend and the example sprang into life.

I wired PWR to D7 on each Arduino and added a line of code right after successful init()
digitalWrite(7, HIGH)

Might help some others to know this.

not working with lora sx1272 mbed shield

I am using DRAGINO LORA SHIELD WITH ARDUINO (server) and SX1272 MBED SHIELD WITH ARDUINO (client) for node to node communication. I am using examples of Radiohead library for RF95 FOR CLIENT AND SERVER side. BUT I am getting issues
Sending to rf95_server
No reply, is rf95_server running?

AT server side i am not getting any output.
so radio head library is compatible with sx1272 mbed shield?

setTxPower() serious output power bug

void RH_RF95::setTxPower(int8_t power, bool useRFO)
{
    // Sigh, different behaviours depending on whther the module use PA_BOOST or the RFO pin
    // for the transmitter output
    if (useRFO)
    {
	if (power > 14)
	    power = 14;
	if (power < -1)
	    power = -1;
	spiWrite(RH_RF95_REG_09_PA_CONFIG, RH_RF95_MAX_POWER | (power + 1));
    }
    else
    {
	if (power > 23)
	    power = 23;
	if (power < 5)
	    power = 5;

	// For RH_RF95_PA_DAC_ENABLE, manual says '+20dBm on PA_BOOST when OutputPower=0xf'
	// RH_RF95_PA_DAC_ENABLE actually adds about 3dBm to all power levels. We will us it
	// for 21, 22 and 23dBm
	if (power > 20)
	{
	    spiWrite(RH_RF95_REG_4D_PA_DAC, RH_RF95_PA_DAC_ENABLE);
	    power -= 3;
	}
	else
	{
	    spiWrite(RH_RF95_REG_4D_PA_DAC, RH_RF95_PA_DAC_DISABLE);
	}

	// RFM95/96/97/98 does not have RFO pins connected to anything. Only PA_BOOST
	// pin is connected, so must use PA_BOOST
	// Pout = 2 + OutputPower.
	// The documentation is pretty confusing on this topic: PaSelect says the max power is 20dBm,
	// but OutputPower claims it would be 17dBm.
	// My measurements show 20dBm is correct
	spiWrite(RH_RF95_REG_09_PA_CONFIG, RH_RF95_PA_SELECT | (power-5));
    }
}

The last line seems to not be correct, it should be (power-2) as Pout = 2 + OutputPower? I double checked with a LMIC library (LoRaWan) where they take (power - 2).

This is quite a serious bug and is on all RadioHead libraries on GitHub.

Don't work in STM32duino

Users/wizz/Documents/Arduino/libraries/RadioHead/RHHardwareSPI.cpp: In member function 'virtual void RHHardwareSPI::begin()':
/Users/wizz/Documents/Arduino/libraries/RadioHead/RHHardwareSPI.cpp:117:29: error: invalid conversion from 'uint8_t {aka unsigned char}' to 'BitOrder' [-fpermissive]
SPI.setBitOrder(bitOrder);
^
In file included from /Users/wizz/Documents/Arduino/libraries/RadioHead/RadioHead.h:739:0,
from /Users/wizz/Documents/Arduino/libraries/RadioHead/RHGenericSPI.h:10,
from /Users/wizz/Documents/Arduino/libraries/RadioHead/RHHardwareSPI.h:10,
from /Users/wizz/Documents/Arduino/libraries/RadioHead/RHHardwareSPI.cpp:7:
/Users/wizz/Documents/Arduino/hardware/Arduino_STM32/STM32F1/libraries/SPI/src/SPI.h:220:7: error: initializing argument 1 of 'void SPIClass::setBitOrder(BitOrder)' [-fpermissive]
void setBitOrder(BitOrder bitOrder);
^
exit status 1
Error compile for board Generic STM32F103Z series.

RH_ASK doesn't work with Servo.h

I can't use the Servo library with Radiohead. I think it's an issue with the timers conflicting. How can I fix this?
Thanks
-Isaac

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.