RadioHead Packet Radio library for embedded microprocessors
###Version 1.67
This is a fork of the original RadioHead Packet Radio library for embedded microprocessors. It provides a complete object-oriented library for sending and receiving packetized messages via a variety of common data radios and other transports on a range of embedded microprocessors.
Please read the full documentation and licensing from the original author site
features added with this fork
=================================
Compatible with boards
LoRasPI, Raspberry PI Lora Gateway, Dragino Lora GPS HAT
- Added moteino modem setting on RF69 to be compatible with lowpowerlab RF69 configuration library
- Added possibility to work with no IRQ connected for RF69 and RF95
- for example to get one more GPIO free
- on Raspberry Pi, we do not have
attachInterrupt()
like with bcm2835 library
- Added samples for multiples Raspberry Pi boards with RF69 and RF95 modules such as
- LoRasPI, simple RFM9x or RFM69HCW shield
- iC880A or Linklabs Raspberry PI shield with RFM9x or RFM69HCW onboard
- Raspberry PI Lora Gateway with multiple RFM9x or RFM69HCW shield
- Dragino Lora shield
- Sample code are in rf95, rf69, nrf24 and multi_server, note that old sample NRF24 sample has been moved to nrf24 folder for consistency.
- Added 2 samples test tools (for Raspberry PI) do detect RF69 and RF95 modules and check IRQ rising edge
Sample code for Raspberry PI is located under RadioHead/examples/raspi folder.
Installation on Raspberry PI
================================
Clone repository
git clone https://github.com/hallard/RadioHead
To avoid system hangs/instability starting with kernel 4.14, disable all GPIO kernel interrupts by adding this line to your /boot/config.txt
:
dtoverlay=gpio-no-irq
This works around an issue with the design of the bcm2835 library and how it handles rising/falling edge detection events, but has some downsides as well. For more information, see this issue and this discussion.
Connection and pins definition
Boards pins (Chip Select, IRQ line, Reset and LED) definition are set in the new RadioHead/examples/raspi/RasPiBoards.h file. In your code, you need to define board used and then, include the file definition like this
// LoRasPi board
#define BOARD_LORASPI
// Now we include RasPi_Boards.h so this will expose defined
// constants with CS/IRQ/RESET/on board LED pins definition
#include "../RasPiBoards.h"
// Your code start here
#ifdef RF_RST_PIN
// Blah blah do reset line
#endif
Then in your code you'll have exposed RF_CS_PIN, RF_IRQ_PIN, RF_RST_PIN and RF_LED_PIN and you'll be able to do some #ifdef RF_LED_LIN
for example. See rf95_client sample code.
So you have 3 options to define the pins you want
- The board you have is already defined so just need to define it your source code (as explained above)
- You can add your board into RasPiBoards.h and then define it your source code as above
- You can manually define pins in your code and remove the board definition and
#include "../RasPiBoards.h"
To go further with examples :
go to example folder here spi_scan
cd RadioHead/examples/raspi/spi_scan
Build executable
root@pi03(rw):~/RadioHead/examples/raspi/spi_scan# make
g++ -DRASPBERRY_PI -DBCM2835_NO_DELAY_COMPATIBILITY -c -I../../.. spi_scan.c
g++ spi_scan.o -lbcm2835 -o spi_scan
root@pi03(rw):~/RadioHead/examples/raspi/spi_scan
And run
root@pi03(rw):~/RadioHead/examples/raspi/spi_scan# ./spi_scan
Checking register(0x42) with CS=GPIO06 => Nothing!
Checking register(0x10) with CS=GPIO06 => Nothing!
Checking register(0x42) with CS=GPIO08 => SX1276 RF95/96 (V=0x12)
Checking register(0x10) with CS=GPIO08 => Nothing!
Checking register(0x42) with CS=GPIO07 => Nothing!
Checking register(0x10) with CS=GPIO07 => Nothing!
Checking register(0x42) with CS=GPIO26 => Nothing!
Checking register(0x10) with CS=GPIO26 => Nothing!
And voila! with LoRasPi board RFM95 dedected on SPI with GPIO8 (CE0)
If I'm doing same test with PI Lora Gateway with 2 RFM95 (one 433MHz and one 868MHz) and one RFMHW69 433MHz on board like this
Here are the results when trying to detect the onboard modules:
root@pi01(rw):~/RadioHead/examples/raspi/spi_scan# ./spi_scan
Checking register(0x42) with CS=GPIO06 => Nothing!
Checking register(0x10) with CS=GPIO06 => Nothing!
Checking register(0x42) with CS=GPIO08 => SX1276 RF95/96 (V=0x12)
Checking register(0x10) with CS=GPIO08 => Nothing!
Checking register(0x42) with CS=GPIO07 => SX1276 RF95/96 (V=0x12)
Checking register(0x10) with CS=GPIO07 => Nothing!
Checking register(0x42) with CS=GPIO26 => Unknown (V=0x01)
Checking register(0x10) with CS=GPIO26 => SX1231 RFM69 (V=0x24)
Voila! 3 modules are seen, now let's try listenning packets with PI Lora Gateway.
My setup has another Raspberry Pi with RFM95 868MHZ LoRasPI shield running rf95_client
sample and some ULPnode prototypes always running with on board RFM69 configured as Group ID 69 on 433MHz. I don't have a Lora 433MHz sender running so we won't receive anything on this one.
Here the results starting from scratch
Client side
multi server side
It works!
Difference with original Author repo
========================================
Due to easier maintenance to keep in sync with original author lib, I've got 2 repo:
- My master one (this one) https://github.com/hallard/RadioHead that is the one you need if you want to use my projects or lib added features.
- The one above has been forked to https://github.com/ch2i/RadioHead where I put the original version released by the author.
Like this, I can do Pull Request from ch2i to hallard to add new features added by the author to my version. This mean that this one is just a github copy version of the latest original done by Mike, I don't do any change on this one. I know it's not the best way, but I didn't found a better solution for now, if you have better idea, just let me know.