Changing SPI pins using SOFTSPI in RF24 library doesn't work (nRF24L01+ module)

I'm trying to get the nRF24L01+ module to work on different pins other than the SPI pins (50-52) on the Arduino Mega. Using the RF24 library, I discovered that I should be able to do this if I follow these steps:

  1. Uncomment the #define SOFTSPI line in the RF24_config.h file.
  2. #include <DigitalIO.h> in the sketch.
  3. Define new pins (40-42) for MOSI, MISO and SCK using the same macros used in the library.

This, in theory should work however it doesnt with me. Am I missing a step?
This module works normally on hardware SPI pins

Receiver code:

#define SOFT_SPI_MISO_PIN 42
#define SOFT_SPI_MOSI_PIN 41
#define SOFT_SPI_SCK_PIN 40

#include <SPI.h>
#include <RF24.h>
#include <DigitalIO.h>
#include <nRF24L01.h>


RF24 radio(2, 3); // CE, CSN

const byte address[6] = "00001";

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}

void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

Did the same NRF24 module work on the hardware SPI pins ?

Yes, tested multiple times

Have a look at this post. Post #5.

I saw this post before, his solution in the end is exactly what im doing right now this is why im confused

Did anyone find a solution to this? I'm doing the exact same thing as @saifeldeenadel but on an Uno. No transmission is taking place with software spi. Hardware SPI works flawless.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.