I've created a custom PCB with an 328p and NRF24L01+, unfortunately it's not sending anything and I'm out of ideas.
What I've tried so far:
breadboard setup with a generic NRF24 module and Arduino Pro Mini: working
my PCB with identical software: not working
no data is received, and nothing is detected with a NRF24 scanner ("spectrum scanner")
all signals to the NRF look good and identical to the breadboard setup (MOSI, MISO, CS, CSN, SCK)
the 16mhz clock of the NRF is oscillating correctly
-> The HF part (NRF24 chip and all surrounding components) were assembled by JLCPCB
-> The NRF layout is pretty much identical to the reference from the datasheet
-> An antenna is connected
Here's the link to the project:
in my infinite wisdom, I've allocated pin 0 and 1 as CS and CSN. Therefore I can't simultaneously communicate with the NRF24 and have a serial connection for debugging.
I can try to use the LEDs as indicator, but it's a bit difficult to read anything from it.
Ok. You can probably use software serial and an external USB/ UART adaptor. Use say pins pb1 abd pb2 and try to grab these at say U1.
Otherwise, debugging is not going to be easy. I tend to litter all my boards, where I am using unfamiliar chips, with jumpers so I can isolate parts. Then I sometimes omit the full integrated breadboard testing stage.
Serial works now (although not on pin 14 for some reason).
Anyway, the example code you mentioned doesn't work properly with software serial it seems.
I modified it to use mySerial.println instead of Serial.println, but the radio.printDetails() function uses the normal Serial output instead of software serial it seems. Not sure how to amend the library to fix that.
This is my code:
// 18 Mar 2018 - simple program to verify connection between Arduino
// and nRF24L01+
// This program does NOT attempt any communication with another nRF24
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
#define CE_PIN 1
#define CSN_PIN 0
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() {
mySerial.begin(9600);
printf_begin();
mySerial.println("CheckConnection Starting");
mySerial.println();
mySerial.println("FIRST WITH THE DEFAULT ADDRESSES after power on");
mySerial.println(" Note that RF24 does NOT reset when Arduino resets - only when power is removed");
mySerial.println(" If the numbers are mostly 0x00 or 0xff it means that the Arduino is not");
mySerial.println(" communicating with the nRF24");
mySerial.println();
radio.begin();
radio.printDetails();
mySerial.println();
mySerial.println();
mySerial.println("AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1");
mySerial.println(" and 250KBPS data rate");
mySerial.println();
radio.openReadingPipe(1, thisSlaveAddress);
radio.setDataRate( RF24_250KBPS );
radio.printDetails();
mySerial.println();
mySerial.println();
}
void loop() {
}
and this is the output:
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
AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1
and 250KBPS data rate
Whoops. So you've really no idea if its a genuine chip or if the matching networks are correct tuned/matched?
Why not use the nRF24L01 modules which avoid all such issues as well as being certified EMI compliant?
[ For microwave stuff like this you really need RF test equipment to commission your prototype PCBs - a VNA and SA are pretty much required equipment up at 2.4GHz as the layout and PCB material have large effects on stray impedances. For instance the capacitors in an antenna matching network like this might be a couple of pF only, so stray capacitance around them, or a change in size from 0603 to 0402 has a large effect. ]