Hello,
i have a transmitter with a couple of joysticks, the wiring is correct on that one because i used it before and that works.
here is the transmitter code:
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
#define CE_PIN 7
#define CSN_PIN 6
RF24 radio(CE_PIN, CSN_PIN);
const byte Address[6] = "00001";
const byte joystickPins[] = {A6, A2, A3, A5};
const byte joysticksCount = sizeof joystickPins / sizeof * joystickPins;
struct __attribute__ ((packed)) t_message {
int16_t rawValues[joysticksCount];
} payload, previousPayload;
void setup() {
pinMode(10, OUTPUT);
radio.begin();
Serial.begin(9600);
radio.openWritingPipe(Address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
// read the joysticks
for (byte i = 0; i < joysticksCount; i++) {
payload.rawValues[i] = analogRead(joystickPins[i]);
payload.rawValues[i] = analogRead(joystickPins[i]) & 0xFFFD; // two reads for stability, dropping the 2 LSb to filter out instability
}
// broadcast the data if it has changed
if (memcmp(&payload, &previousPayload, sizeof(t_message)) != 0) { // returns 0 when they match, https://cplusplus.com/reference/cstring/memcmp/
radio.write(&payload, sizeof(payload));
previousPayload = payload;
for (int i = 0; i < 4; i++) {
Serial.print(payload.rawValues[i]);
Serial.print("\t"); }
}
Serial.println();
delay(50);
}
this is wired to arduino nano (old bootloader).
when i move the joysticks i get serial data so that should declare that transmitting works.
but at my receiving end, wired to an ESP32 S3, i dont get any serial data:
here is the code:
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
//void begin(int8_t sck =12, int8_t miso =13, int8_t mosi =11, int8_t ss =10);
RF24 radio(10, 9); //CE, CSN
const byte Address[6] = "00001";
// Define the same struct used in the transmitter to store joystick data
struct __attribute__ ((packed)) t_message {
int16_t rawValues[4]; // Adjust size to match the number of joysticks
} payload;
void setup() {
Serial.begin(115200);
// Initialize the nRF24L01 module
radio.begin();
//SPI.begin(int8_t sck =12, int8_t miso =13, int8_t mosi =11, int8_t ss =10);
radio.openReadingPipe(0, Address); // Set the address to listen on
radio.setPALevel(RF24_PA_MIN); // Set power level
radio.startListening(); // Set module to receive mode
}
void loop() {
// Check if data is available from the transmitter
if (radio.available()) {
radio.read(&payload, sizeof(payload)); // Read the data into the payload struct
// Print the joystick data to Serial Monitor
Serial.println("Joystick Data Received:");
for (int i = 0; i < 4; i++) {
Serial.print("Joystick ");
Serial.print(i + 1);
Serial.print(": ");
Serial.println(payload.rawValues[i]);
}
Serial.println("--------------");
}
delay(50); // Small delay to prevent flooding the Serial Monitor
}
the SPI pin declaration left out was just for testing, i did try it without.
is there anyting i did wrong.
i have the NRF24L01 wired to the 3.3V and GND of my ESP with a 10μF capacitor in parralel, also on my transmittr but then my nano
after adding this in my setup:
if (radio.isChipConnected())
Serial.println("Transmitter NF24 connected to SPI");
else Serial.println("\n\nNF24 is NOT connected to SPI");
for my receiver i get is Connected
but for my transmitter i get is NOT Connected
after trying this code from ChatGPT on my transmitter i get the Check wiring message but it is fixed to a PCB so that is strange.
#include <SPI.h>
#include <RF24.h>
#define CE_PIN 7
#define CSN_PIN 6
RF24 radio(CE_PIN, CSN_PIN);
void setup() {
Serial.begin(115200);
if (!radio.begin()) {
Serial.println("nRF24L01 module not responding. Check wiring.");
} else {
Serial.println("nRF24L01 module connected successfully!");
}
}
void loop() {
// This loop does nothing in this test code
}
but i will charge my 3s Li-ion powering it. because it has been lying untouched for atleast 1.5 years, so that could aslo be an issue. but i didn't think of that because my nano does turn on.





