nRF24L01+ over software SPI

Hi all,

this is my first post after reading and googling for two weeks; I hope this post is in the right place and I hope someone can help or give me a good direction to find a solution.

I'm building a project with: Arduino MEGA 2560 R3, nRF24L01+ and TFT screen.

I'm able to run succesfully these configurations:

  • (1)- nRF24L01+ alone ( using HW SPI and "RF24.h" library )
  • (2)- TFT alone ( using HW SPI and "Adafruit_ILI9341.h" library )
  • (3)- nRF24L01+ ( using HW SPI and "RF24.h" library) together with TFT ( using SW SPI and "Adafruit_ILI9341.h" library )

All above configurations are running well, no problem.

The side effect is that running configuration (3), TFT is really very slow and not usable; in addition my application need few packets with nRF24L01+. For above reasons I'm looking to run this configuration:

  • (4)- nRF24L01+ ( using SW SPI and "iBoardRF24.h" library) together with TFT ( using SW SPI and "Adafruit_ILI9341.h" library )

PROBLEM: There is no way to make nRF24L01+ running using SW SPI and "iBoardRF24.h" library... or better, I can't find a way to TRANSMIT packets...

By running alone nRF24L01+ using SW SPI and "iBoardRF24.h" library I see the scan sample works well, so I guess pins are well wired, but TX/write DOESN'T work ( radio is not available ).

note:

    • I controlled wiring 20/30 times ( with special care to interrupt pins )
    • nRF24L01+ is correctly powered with an additional power board
    • nRF24L01+ is set to power_min
    • tried with simplest sketch, without any possible conflict

I read at least three people are able to use nRF24L01+ using SW SPI and "iBoardRF24.h" library, without any special notice or comment; I tried without succes.

HELP ! :o

SPI is a bus system. Why aren't you using hardware SPI for both the nRF24 and the display?

...R

Ciao Robin,

thanks for your time.

I tried to put both in parallel with hardware SPI ( and different CS of course ), but for some reason they goes in conflict and doesn't cohexist. I read this is a common issue.

note: my TFT has also SD card slot, but it is not used. I tried also to disconnect MISO of the TFT.

Do you think I've to insist with both devices in parallel with hardware SPI ?

Thanks

bc-hero:
I tried to put both in parallel with hardware SPI ( and different CS of course ), but for some reason they goes in conflict and doesn't cohexist. I read this is a common issue.

That could be because each of them needs different SPI settings. You could modify your program so it creates the correct settings for each device before it starts talking to the device.

I have never tried Sofware SPI so I have no idea what its limitations may be. I suspect it is considerably slower and also that it prevents the Arduino from doing other things while it is active. You could always get a very simple nRF24 program working with Hardware SPI and then try switching it to SW SPI.

...R

Dear Robin,

you are right, something goes in conficts with the SPI parameters of the "RF24.h" and "Adafruit_ILI9341.h" libs when using both the hardware SPI ( maybe they have different speed, mode, etc ).

I found a very deep investigation by googling "Using nrf24l01+ with other devices together on one SPI-Bus"...

The nRF24L01+ remains hooked somewhere and not responding if it shares same hardware SPI with the TFT.

I SOLVED leaving the TFT over hardware SPI (it is fast enought now) and moving nRF24L01+ to a software SPI.

To move nRF24L01+ over a software SPI i did in this way:

  • edited RF24_config.h and UNcommented #define SOFTSPI (it was //#define SOFTSPI)
  • added DigitalIO lib to my project
  • wired nRF24L01+ MISO, MOSI, SCK of to pin 9, 8, 7 of my arduino MEGA

this is my lib including:

#include <SPI.h>
#include <RF24.h>
#include "DigitalIO.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

this is how are created the two instances of the objects:

//TFT
#define TFT_DC 44
#define TFT_CS 46
#define TFT_RST 48
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); // remaining pin to hw spi 50,51,52

//radio
RF24 radio(41,40); // ce, cs

It took 2 weeks of my life, but I can now go on with my project.

Thanks a lot

Andrea

1 Like