ESP32 C3 Supermini and nrf24l01

Hi.

I am battling to get the ESP32 C3 SuperMini to talk to the NRF24L01 board.
Trying to use the ESP as a NRF => wifi bridge.

There are no real examples for this board and the topic How to use nrf24l01 with esp32 s3 / c3 didn't help me in any way.

I have used the following code to test the connection:

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

#include <printf.h>

#define CE_PIN 10
#define CSN_PIN 9
#define SCK_PIN 4
#define MISO_PIN 5
#define MOSI_PIN 6
#define SS_PIN 7


const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;


void setup() {

    //SPI.begin(SCK_PIN, MISO_PIN, MOSI_PIN, SS_PIN);
    Serial.begin(9600);
    printf_begin();

    Serial.println("CheckConnection Starting");
    Serial.println();
    Serial.println("FIRST WITH THE DEFAULT ADDRESSES after power on");
    Serial.println("  Note that RF24 does NOT reset when Arduino resets - only when power is removed");
    Serial.println("  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not");
    Serial.println("     communicating with the nRF24");
    Serial.println();
    radio.begin();
    radio.printDetails();
    Serial.println();
    Serial.println();
    Serial.println("AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1");
    Serial.println(" and 250KBPS data rate");
    Serial.println();
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.setPALevel(RF24_PA_MIN);
    radio.setDataRate( RF24_250KBPS );
    radio.printDetails();
    Serial.println();
    Serial.println();
}


void loop() {

}

with both the SPI.begin(...) line included and excluded.
I have checked the pins_arduino.h file for this board (using the "ESP32 C3 Dev Module" library) and it matches what I have done in my physical wiring and sw definitions.

However, all I ever get on the serial output it

ESP-ROM:esp32c3-api1-20210207
CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
  Note that RF24 does NOT reset when Arduino resets - only when power is removed
  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
     communicating with the nRF24

SPI Speedz	= 10 Mhz
STATUS		= 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1	= 0x0000000000 0x0000000000
RX_ADDR_P2-5	= 0x00 0x00 0x00 0x00
TX_ADDR		= 0x0000000000
RX_PW_P0-6	= 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA		= 0x00
EN_RXADDR	= 0x00
RF_CH		= 0x00
RF_SETUP	= 0x00
CONFIG		= 0x00
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= Disabled
PA Power	= PA_MIN
ARC		= 0


AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1
 and 250KBPS data rate

SPI Speedz	= 10 Mhz
STATUS		= 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1	= 0x0000000000 0x0000000000
RX_ADDR_P2-5	= 0x00 0x00 0x00 0x00
TX_ADDR		= 0x0000000000
RX_PW_P0-6	= 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA		= 0x00
EN_RXADDR	= 0x00
RF_CH		= 0x00
RF_SETUP	= 0x00
CONFIG		= 0x00
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= Disabled
PA Power	= PA_MIN
ARC		= 0

which shows basically no communications between the ESP and the RF module.
My circuit is on a PCB (not a breadboard) and I have a 10uF cap across the power rails.
I have also swapped the RF module out (I have the TX half of the comms project running on an Arduino Mini) and had no issues getting it up and running and talking to a proto receiver running on an Uno.

So I am now stuck. I have double checked my wiring traces on the board and all are fine.
As far as I understand I can connect CE and CSN to any available pin however maybe I have chosen unwisely here.

So basically, has anyone successfully connect these two modules together and if so, any special hardware/software considerations.

How is the NRF powered? It needs more current than the ESP32's 3.3v regulator can source. You either need a separate power supply. Here's one solution that provide 3.3V from a wide input range:
https://www.amazon.com/Socket-Adapter-NRF24L01-Wireless-Module/dp/B00NJCB7FS/ref=asc_df_B00NJCB7FS/?tag=hyprod-20&linkCode=df0&hvadid=693380207983&hvpos=&hvnetw=g&hvrand=5639444854938363299&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9003668&hvtargid=pla-350998793695&psc=1&mcid=342084039ecc36ecb726e22a73efaa4c

Assuming that they're being powered properly, my next step would be to put a logic analyzer on the SPI interface lines and see what they are doing.

Thanks for response. It is powered via an external 3V3 regulator (actually both modules are running off the regulator rather than the USB port and the ESP internal reg). Only connecting the usb to monitor the serial output. I have not put the Vcc on a scope yet to see how stable it is but will do so. Will look at connecting up a logic analyser to see what the pins are putting out.

Have you seen our ESP32 / SPI documentation at:

Optimized high speed nRF24L01+ driver class documentation: Arduino (Scroll down)

You can specify the SPI BUS / pins to use, which could help your case because yeah, the radio is just not talking correctly with the MCU.

Thanks very much. Will give it a try over the next couple of days (day job is calling :stuck_out_tongue_winking_eye:).

using program from ESP32 SPI Communication: Set Pins the default pins on the ESP32-C3-MINI-1 are

MOSI: 6
MISO: 5
SCK: 4
SS: 7
SDA: 8
SCL: 9

using the following code

//  ESP32C3 > NRF24L01 receiver test using a text string

// UNO/Nano connections
// arduino SCK pin 11 goes to NRF24L10_pin MOSI
// arduino MISO pin 12 goes to NRF24L10_pin MI
// arduino MOSI pin 13 goes to NRF24L10_pin SCK
// NRF24L10 CE to arduino pin 9
// NRF24L10 CSN to arduino pin10

// ESP32 connections
// ESP32 SCK pin GPIO18 goes to NRF24L10_pin SCK
// ESP32 MISO pin GPIO19 goes to NRF24L10_pin MI
// ESP32 MOSI pin GPIO23 goes to NRF24L10_pin MO
// NRF24L10 CE to ESP32 pin GPIO4
// NRF24L10 CSN to ESP32 pin GPIO 5

// ESP32_S3_DevKit_1 connections
// ESP32_S3 SCK pin GPIO12  to NRF24L10_pin SCK
// ESP32_S3 MISO pin GPIO13  to NRF24L10_pin MISO
// ESP32_S3 MOSI pin GPIO11  to NRF24L10_pin MOSI
// ESP32_S3 SS  pin GPIO 10   to NRF24L10 SS
// ESP32_S3 pin GPIO16   to NRF24L10 CE
// ESP32_S3 pin GPIO17 to NRF24L10 CSN

// ESP32-C3-MINI-1 connections using default SPI pins
// ESP32_C3 SCK pin GPIO4  to NRF24L10_pin SCK
// ESP32_C3 MISO pin GPIO5  to NRF24L10_pin MISO
// ESP32_C3 MOSI pin GPIO6  to NRF24L10_pin MOSI
// ESP32_C3 SS  pin GPIO7   to NRF24L10 SS
// ESP32_C3 pin GPIO10   to NRF24L10 CE
// ESP32_C3 pin GPIO9 to NRF24L10 CSN

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

#define CE_PIN 10
#define CSN_PIN 9

bool radioNumber = 1;
const uint8_t pipes[][6] = { "1Node", "2Node" };

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10];  // this must match dataToSend in the TX
bool newData = false;

//===========

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("\n\nESP32_C3 > NRF24L01 Receive text");
  radio.begin();
  if (radio.isChipConnected())
    Serial.println("Receiver NF24 connected to SPI");
  else {
    Serial.println("NF24 is NOT connected to SPI");
    while (1)
      ;
  }
  radio.setChannel(125);
  radio.setDataRate(RF24_1MBPS);
  //radio.setDataRate(RF24_250KBPS);
  radio.printDetails();
  if (!radioNumber) {
    radio.openWritingPipe(pipes[0]);
    radio.openReadingPipe(1, pipes[1]);
  } else {
    radio.openWritingPipe(pipes[1]);
    radio.openReadingPipe(1, pipes[0]);
  }
  radio.startListening();
  // radio.setPayloadSize(sizeof(Struct1));
}

//=============

void loop() {
  if (radio.available()) {
    char testString[10] = "";
    radio.read(testString, sizeof(testString));
    Serial.print("Test string:      ");
    Serial.println(testString);
  }
}

the serial monitor displays

ESP32_C3 > NRF24L01 Receive text
Receiver NF24 connected to SPI
SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR		= 0xe7e7e7e7e7
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x7d
RF_SETUP	= 0x07
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 0

photo
image

it is always a good idea to check if the NRF24 SPI connection is OK, e.g.

radio.begin();
  if (radio.isChipConnected())
    Serial.println("Receiver NF24 connected to SPI");
  else {
    Serial.println("NF24 is NOT connected to SPI");

Thanks for your suggestions. Will try your code later this evening. I see the article you linked also shows some other useful samples which I may also try to make sure all is configured correctly.

I tried the various code options. The test code to check pin allocations reported correctly as I have used them ie pins defined for ESP32-C3-MINI-1
Put a scope on the 3V3 rail and it did not deviate at all during initial startup of the module but MCU still reporting no connection with the module. So I will have to wait until the weekend to connect up my logic analyser to see whats happening on the pins as I will need to also create a simple piggyback board to attach all the probes. Will then compare the traces of the working unit with this one and see if I can see any differences.
Thanks again for all the suggestions/assistance.

Probably not surprising as I'd only expect large current draw from the radio while it's transmitting.

Do you see any activity on the SPI bus at all using a scope? If so, how's signal integrity look?

Not sure what it should be, but using scope:
CE pin remains low.
CSN pin is high, very short drop to 0 when querying the board, then back to high.
SCK pin: Not sure if this is correct. Getting very short spaced bursts of 11.8Mhz pulses ie a burst of 8 oscillations at 11.8Mhz, then a few uSec of nothing, then another burst. The pulses look untidy ie ramps up to 2.24V and then sawtooth oscillation between 1V and 2.24V for the 8 or so oscillations then decays back down to 0V. Zooming out I see a general pattern of a similar envelope to the MOSI signal. Thinking about it, this looks like its pulsing at the MCU clock speed.
MOSI: 0V , then 2 pulses @ 3V3, then about 6ms delay, then a series of pulses for around 3.5ms.
MISO: 0V constant.

if I run your code from post 1 (with no changes) on my ESP32-C3-MINI-1 the serial monitor displays

FIRST WITH THE DEFAULT ADDRESSES after power on
  Note that RF24 does NOT reset when Arduino resets - only when power is removed
  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
     communicating with the nRF24

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR		= 0xe7e7e7e7e7
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x4c
RF_SETUP	= 0x07
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 0


AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1
 and 250KBPS data rate

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0x4141417852
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR		= 0xe7e7e7e7e7
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x4c
RF_SETUP	= 0x21
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 250 KBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MIN
ARC		= 0

used default SPI connections

// ESP32-C3-MINI-1 connections using default SPI pins
// ESP32_C3 SCK pin GPIO4  to NRF24L10_pin SCK
// ESP32_C3 MISO pin GPIO5  to NRF24L10_pin MISO
// ESP32_C3 MOSI pin GPIO6  to NRF24L10_pin MOSI
// ESP32_C3 SS  pin GPIO7  not used
// ESP32_C3 pin GPIO10   to NRF24L10 CE
// ESP32_C3 pin GPIO9 to NRF24L10 CSN

what are your connections?
image

what ESP32C3 module are you using?
what is your serial monitor output?
upload a photo of your setup?

Sorry for delay, got a bit busy yesterday.
Here are the images/diagrams for the receiver:
The ESP32 C3 SuperMini MCU:

Schematic:

PCB Layout:

Photo:

The serial output is as stated in my first post.

your circuit look OK
it shows 3.3V power for the ESP32C3 and NRF24 - is this from the ESP32C3 3.3V pin (derived from USB 5V) or from an external power supply?
what does the serial monitor show?

The 3V3 rail is all off of the regulator on the PCB which is powered via an external supply.
It doesn't rely on the 5V coming in via the USB connection.

Serial output:

ESP-ROM:esp32c3-api1-20210207
CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
  Note that RF24 does NOT reset when Arduino resets - only when power is removed
  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
     communicating with the nRF24

SPI Speedz	= 10 Mhz
STATUS		= 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1	= 0x0000000000 0x0000000000
RX_ADDR_P2-5	= 0x00 0x00 0x00 0x00
TX_ADDR		= 0x0000000000
RX_PW_P0-6	= 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA		= 0x00
EN_RXADDR	= 0x00
RF_CH		= 0x00
RF_SETUP	= 0x00
CONFIG		= 0x00
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= Disabled
PA Power	= PA_MIN
ARC		= 0


AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1
 and 250KBPS data rate

SPI Speedz	= 10 Mhz
STATUS		= 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1	= 0x0000000000 0x0000000000
RX_ADDR_P2-5	= 0x00 0x00 0x00 0x00
TX_ADDR		= 0x0000000000
RX_PW_P0-6	= 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA		= 0x00
EN_RXADDR	= 0x00
RF_CH		= 0x00
RF_SETUP	= 0x00
CONFIG		= 0x00
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= Disabled
PA Power	= PA_MIN
ARC		= 0

looks like the ESP32C3 is not communicating with the NRF24 over SPI
have you a logic analyzer?

Try an SD, or any other SPI device.

Okay, so I took some data grabs using my Logic Analyser. In both tests I used the same NRF24 module to rule out the case of it being faulty. I also swapped out the ESP32 module, no change.

Channels:
0: N/A
1:SCK
2:N/A
3:MISO
4:MOSI
5:CE
6:CSN

Connected to an Arduino Mini MCU:
Zoomed to 100ms intervals:

Zoomed to 1ms intervals, intial packets:

Connected to ESP32 C3:
Zoomed to 100ms intervals:

Zoomed to 1ms invervals, intial packets:

The Mini works fine and the serial output is populated correctly ie communicates fine with the RF module.
On the ESP32, there is just no traffic/response on the MISO channel. I actually did the test on the ESP32 twice, once with the analyser connected to the pins of the ESP and the other to the pins of the RF module. In both cases, the logic pattern looked basically identical. Just wondering if there could be something holding the MISO down to ground somehow.

So just for fun, I wired (jumpered) the Arduino Mini into the board I made for the esp32 and got the following serial response:

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR		= 0xe7e7e7e7e7
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x4c
RF_SETUP	= 0x00
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MIN
ARC		= 0

which looks like it is talking to the RF module. So it looks like it may just be a coding issue or something with the ESP's SPI interface :frowning_face: