Page 1 of 1

ESP32 nrf24

Posted: Sun Jul 07, 2024 11:25 am
by ittech890
Hi. I just got into microcontrollers and started working on my first project, a 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):

Code: Select all

#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) :

Code: Select all

#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.