Closed MArimont3 closed 4 years ago
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);
RH_NRF24 nrf24(8, 10);
This repository is a copy adapted to Teensy. Definitely the wrong place to ask about use of Arduino Mega.
Tested RH_NRF24 with Arduino Maga. The documentation says
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)
So SS is a static const of type uint8_t !!! In the file RadioHead.h SS is set with "#define", and you find
As a result, for the Mega, SS is defined as pin 10 :-( :-(
You can easily test this. A simple sketch
shows correctly 53 on the Serial monitor, while
shows 10 ! :-(
Work around : use pin 10 for SS and initialize as
RH_NRF24 nrf24(8, 10);