Hi. I just got into microcontrollers and started working on my first project, an transmitter and receiver. I have two nrf24 modules, an esp32 s3 and an esp32 c3. But, unfortunately, nothing is working. This is the code for the transmitter (esp32 s3):
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
void begin(int8_t sck =12, int8_t miso =13, int8_t mosi =11, int8_t ss =10);
RF24 radio(10, 19); // 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 this is the code for the receiver (esp32 c3) :
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
void begin(int8_t sck =4, int8_t miso =5, int8_t mosi =6, int8_t ss =7);
RF24 radio(7, 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);
}
}
It's probably a programming issue, but I cant seem to find it.
Welcome to the forum
The begin() function seems to be missing from your sketches as does a call to it
1 Like
Hi,
The begin() function is from the SPI library. The support team from where I bought the board recommended that I use this function. The esp32 s3 doesn't have dedicated pins for SPI, and I need a way to declare them.
The begin() function that you declare in the sketch has no definition and in any case is not the function called by wire.begin()
1 Like
srnet
July 7, 2024, 12:11pm
5
And the way to address it is with;
SPI .begin();
There are default SPI pins set in the Arduino core for ESP32S3.
To start SPI on an ESP32S3 Dev kit board I can use;
SPI.begin();
1 Like
horace
July 7, 2024, 12:42pm
6
the SPI pins I used on a ESP32_S3_DevKit_1 are
// ESP32_S3_DevKit_1 connections
// ESP32_S3 SCK pin GPIO12 to NRF24L01_pin SCK
// ESP32_S3 MISO pin GPIO13 to NRF24L01_pin MISO
// ESP32_S3 MOSI pin GPIO11 to NRF24L01_pin MOSI
// ESP32_S3 SS pin GPIO 10 to NRF24L01 SS
// ESP32_S3 pin GPIO 9 to NRF24L01 CSN
RF24 radio(10, 9); // CE, CSN pins
void setup()
{
Serial.begin(115200);
Serial.println("\n\nESP32 > NRF24L01 transmit test");
radio.begin();
if (radio.isChipConnected())
Serial.println("Transmitter NF24 connected to SPI");
else Serial.println("\n\nNF24 is NOT connected to SPI");
1 Like
Thank you so much! It's working now. I really appreciate your help. Props to all of you for helping me out!
system
Closed
January 3, 2025, 1:20pm
8
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.