yesterday night it worked and I wired it up the same but it was not the same sketch.
Here is my 'Is it there sketch', it will tell you if the NRF24L01 is there, change the code for the correct pin number for CSN_PIN;
/*******************************************************************************************************
Program Operation - This program is stand alone, it is not necessary to install a NRF2401 library to
check the NRF2401 can be written to and read from over the SPI bus.
The contents of the NRF2401 registers from 0x00 to 0x1F are read and printed to the serial monitor.
If the connections are OK then the printout should look like this;
57_NRF24L01_Is_It_There ?
Print registers 0x00 to 0x1F
Reg 0 1 2 3 4 5 6 7 8 9 A B C D E F
0x00 00 3F 02 03 5F 4C 27 42 00 00 E7 52 C3 C4 C5 C6
0x10 E7 00 20 00 00 00 00 12 00 00 FF FF FF FF FF FF
Note that this is just a 'is it there' type check, the CE pin is not used or needed for this simple check.
If the device is faulty, not present or wired incorrectly the register contents will likely be all 00s or
FFs. The program makes no attempt to turn on the RF transmitter or receiver.
Serial monitor baud rate is set at 9600.
*******************************************************************************************************/
#include <SPI.h>
#define CSN_PIN 10
#define NUM_REGISTERS 26
#define CMD_R_REGISTER 0x00
#define CMD_W_REGISTER 0x20
void loop()
{
Serial.println(F("Print registers 0x00 to 0x1F"));
printRegisters(0, 0x1F);
Serial.println();
delay(5000);
}
void printRegisters(uint16_t Start, uint16_t End)
{
uint16_t Loopv1, Loopv2, RegData;
Serial.print(F("Reg 0 1 2 3 4 5 6 7 8 9 A B C D E F"));
Serial.println();
for (Loopv1 = Start; Loopv1 <= End;) //32 lines
{
Serial.print(F("0x"));
if (Loopv1 < 0x10)
{
Serial.print(F("0"));
}
Serial.print((Loopv1), HEX); //print the register number
Serial.print(F(" "));
for (Loopv2 = 0; Loopv2 <= 15; Loopv2++)
{
RegData = readRegister(Loopv1);
if (RegData < 0x10)
{
Serial.print(F("0"));
}
Serial.print(RegData, HEX); //print the register number
Serial.print(F(" "));
Loopv1++;
}
Serial.println();
}
}
uint8_t readRegister(uint8_t reg)
{
uint8_t result = 0xFF;
if (reg < NUM_REGISTERS) {
digitalWrite(CSN_PIN, LOW);
SPI.transfer(CMD_R_REGISTER | reg);
result = SPI.transfer(0xff);
digitalWrite(CSN_PIN, HIGH);
}
return result;
}
void setup()
{
Serial.begin(9600);
pinMode(CSN_PIN, OUTPUT);
Serial.println();
Serial.println(F("57_NRF24L01_Is_It_There ?"));
Serial.println();
SPI.begin();
}
how should I use it should i upload it to both or what...
sorry to ask.
just upload to one, it's a sketch checking the registers of your hardware
so if it can't read the register it means there is an issue with accessing the hardware
First I did not get any thing at all. Then I saw that void setup() was at the bottom I moved it to the top and I got this. Is it correct???
Sorry but I do not know how to use a register. ![]()
The postion of void setup() in the code should not make any difference.
However, its not reading correctly from the nrf24L01, although the point at which the register reads return 0xFF, at register 0x1A, matches the normal pattern but the other registers are returning invalid values.
Did you buy the devices from a trusted source ?
sorry can not get good photo of plane and remote
yes
I always buy from there.
there is a hardware issue clearly. So it can be
- power
- wiring
- faulty unit
post a picture of how things are wired.
If you get this output;
Print registers 0x00 to 0x1F
Reg 0 1 2 3 4 5 6 7 8 9 A B C D E F
0x00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF FF
Then the CSN_PIN is not connected or defined correctly.
I cannot get good photo of wiring but I Wired it as following on uno and nano. I did some research and found that the uno and nano has the same pins.
Vcc - 3.3v
Gnd - gnd
Mi - D12
Mo - D11
Sck - D13
Csn - D10
Ce - D9
try connecting CSN somewhere else (10 is SPI SS, it might conflict)
I will try later my father is using the computer right now(I am using my mother's phone to reply). But in the example it sed to wire it like that.
I will reply to you as soon as I tested it and I will tell you if it works.
What pins should I try?
that's what I use in my test code I shared earlier
const byte CEPin = 8;
const byte CSNPin = 7;
RF24 radio(CEPin, CSNPin);
Can you please send that code I do not think I saw it. Can you check it on my connections
