I don't know what it is, I'm using this tutorial
from howtomechatronics, it's the best one I could find yet, but the communication doesn't work. I also did make sure i used the correct SPI pins of the ESP32 but still it doesn't work. Can anyone help?
I moved your topic to an appropriate forum category @thephoenix49 .
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
How are the radio modules powered ?
which pins did you use?
For an ESP32 I tend to use
// 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
in the startup code it is worth checking that the SPI is connected OK
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("ESP32 > 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)
;
}
Show your sketch please
i use the 3v3 pin and a decoupling capacitor of 10uF.
i get this message here:
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4832
load:0x40078000,len:16460
load:0x40080400,len:4
load:0x40080404,len:3504
entry 0x400805cc
ESP32 > NRF24L01 Receive text
Receiver NF24 connected to SPI
if you press reset (RST) what happens - does it go into a reset loop?
no it just types this once. here's my code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(4, 5); // CE, CSN
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("ESP32 > 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)
;
}
}
void loop(){
}
i tried this code
Receiver:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(4, 5); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
delay(1000);
Serial.println("ESP32 > 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.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);
}
}
Transmitter:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(4, 5); // CE, CSN
const byte address[6] = "00001";
void setup() {
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
delay(1000);
}
and i see this in console when i reset the receiver:
����B.�1P�3�ESP32 > NRF24L01 Receive text
Receiver NF24 connected to SPI
after that no more things get written in console, no more lines, nothing, like the esp would have crashed or something.
try changing transmitter to display information when it transmits
void loop() {
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
Serial.print("transmitting ");
Serial.println(text);
delay(1000);
}
then what is the transmitter serial output?
esp32-pinout-reference-gpios state that pin 5 is a "strapping pin" which " outputs PWM signal at boot, strapping pin" - maybe causing problems?
how far apart of the NRF24 modules - if too close the transmitter can overload the receiver
@horace
i tried distances between a centimeter and a meter.
did not work
@horace i switched from gpio pin 5 to 21, which it says is safe, it still doesn't show any received data in serial monitor.
I tried using an other esp32 and it still didn't work. someone help pls.
using ESP32 pins
// 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
// NRF24L10 VCC to 3.3V
transmitter code
// esp32 > NRF24L01 transmitter test using a text string
// RP2040 connections
// RP2040 SPIO_SCK pin GP18 goes to NRF24L10_pin SCK
// RP2040 SPIO_RX pin GP16 goes to NRF24L10_pin MISO
// RP2040 SPIO_TX pin GP19 goes to NRF24L10_pin MOSI
// RP2040 pin SPIO_CSn GP17 to NRF24L10 CSN
// RP2040 pin GP20 to NRF24L10 CE
// RP2040 GND and 3.3V to NRF24L10 GND and VCC
// Leonardo connections ???
// Leonardo ICSP SCK pin 15 to NRF24L10_pin SCK
// Leonardo ICSP MISO pin 14 to NRF24L10_pin MISO
// Leonardo ICSP MOSI pin 16 to NRF24L10_pin MOSI
// Leonardo pin 10 to NRF24L10 CSN
// Leonardo pin 9 to NRF24L10 CE
// Leonardo GND and 3.3V to NRF24L10 GND and VCC
// ESP8266 connections
// ESP8266 SCK pin GPIO14 goes to NRF24L10_pin SCK
// ESP8266 MISO pin GPIO12 goes to NRF24L10_pin MI
// ESP8266 MOSI pin GPIO13 goes to NRF24L10_pin MO
// NRF24L10 CE to ESP8266 pin GPIO4
// NRF24L10 CSN to ESP8266 pin GPIO5
// UNO/Nano connections
// arduino MOSI pin 11 goes to NRF24L10_pin MOSI
// arduino MISO pin 12 goes to NRF24L10_pin MI
// arduino SCK pin 13 goes to NRF24L10_pin SCK
// NRF24L10 CE to arduino pin 9
// NRF24L10 CSN to arduino pin10
// NRF24L10 VCC to 3.3V and GND to GND
// for ESP32-CAM
//#define SCK 14
//#define MISO 12
//#define MOSI 13
//#define CS 15
// 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
#include <SPI.h>
#include "RF24.h"
#define CE_PIN 4
#define CSN_PIN 5
bool radioNumber = 0;
RF24 radio(CE_PIN, CSN_PIN);
byte addresses[][6] = { "1Node", "2Node" };
void setup() {
Serial.begin(115200);
delay(2000);
Serial.println("\n\nESP32> NRF24L01 transmit text");
radio.begin();
if (radio.isChipConnected())
Serial.println("Transmitter NF24 connected to SPI");
else {
Serial.println("NF24 is NOT connected to SPI");
while (1)
;
}
radio.setChannel(125);
radio.setPALevel(RF24_PA_MIN);
radio.powerUp();
radio.setDataRate(RF24_1MBPS);
//radio.setDataRate(RF24_250KBPS);
if (radioNumber) {
radio.openWritingPipe(addresses[1]);
radio.openReadingPipe(1, addresses[0]);
} else {
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1, addresses[1]);
}
radio.stopListening();
//radio.setPayloadSize(sizeof(Struct1));
}
// loop transmiting data packet
void loop() {
static char testString[10] = "text 0";
radio.write(testString, sizeof(testString));
Serial.print("transmit ");
Serial.println(testString);
delay(1000);
testString[5]++;
}
receiver code
// ESP32 > 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
#include <SPI.h>
#include <RF24.h>
#define CE_PIN 4
#define CSN_PIN 5
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("ESP32 > 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);
}
}
transmitter serial monitor output
ESP32> NRF24L01 transmit text
Transmitter NF24 connected to SPI
transmit text 0
transmit text 1
transmit text 2
transmit text 3
transmit text 4
transmit text 5
transmit text 6
transmit text 7
transmit text 8
transmit text 9
transmit text :
transmit text ;
transmit text <
transmit text =
transmit text >
transmit text ?
transmit text @
transmit text A
transmit text B
receiver
ESP32 > 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 = 0x65646f4e32 0x65646f4e31
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x65646f4e32
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
Test string: text 1
Test string: text 2
Test string: text 3
Test string: text 4
Test string: text 5
Test string: text 6
Test string: text 7
Test string: text 8
Test string: text 9
Test string: text :
Test string: text ;
Test string: text <
Test string: text =
Test string: text >
Test string: text ?
Test string: text @
Test string: text A
Test string: text B
Test string: text C
Test string: text D
Test string: text E
Test string: text F
in the diagram on post 16 have you got MOSI and SCK the wrong way around?
the pinout I use is MOSI GPIO23 and SCK GPIO18
is the pinout for your NRF24 the same?
it is the same pinout, I messed up in the diagram, but in real life I didn't.