help with nRF24L01 and bareboard arduino

HY, sorry for my poor english.

I am fairly new to the arduino and electronics but i really like it.

I have a bareboard arduino working atmega 328p-pu (burned bootloader and used a ftdi cable to upload sketch) all is ok.

Now i try to connect a nrf24l01 module ( like this https://arduino-info.wikispaces.com/file/view/nRF24L01-3.jpg/243329431/nRF24L01-3.jpg ), on my arduino mega all works ok using this guide and the example sketch Getting Started with nRF24L01+ on Arduino | maniacbug , but on the bareboard all i see is zero, i double checked the connections it should be ok from what i understand :frowning:

Do i need some capacitors or something to connect the module to the bareboard ? sorry for this question but as i said i'm fairly new to electronics.

Thanks a lot for your time.

You may have to explain what your "bareboard Arduino" actually is a bit more.

Basically, the nRF24l01 boards connect to the SPI on the Arduino, and the SPI i/o pins are 5V tolerant, but the nRF24l01 board needs 3V3 for power on Vcc (5V will kill it).

So you need to either run the entire Arduino at 3V3, or run the Arduino at 5V and have a 3V3 supply available for the nRF24l01 board.

Do you have 3V3 going to the Vcc on your nRF24l01?

Hy, as i mentioned before i use a FTDI cable and it has an output of 5v and 3.3v via usb so i run the nRF24l01 board from there.

As for conections i atached a picture of a pinnout i found on web, i used that picture to connect the nRF24l01 board to my atmega like this :

nrf pin 1 -> gnd
nrf pin 2 -> 3v
nrf pin 3 -> atmega pin 15
nrf pin 4 -> atmega pin 16
nrf pin 5 -> atmega pin 19
nrf pin 6 -> atmega pin 17
nrf pin 7 -> atmega pin 18

can you please take a look and confirm me if i'm doing ok ?

thanks a lot.

atmega328-arduino-pinout.jpg

Those SPI connections look correct. Are you able to verify the 328 chip is working properly on a test sketch (e.g., blink)? How is the chip connected to the supporting external components (crystal, etc.)? Is the 328 chip powered at 3.3V or 5V from the FTDI board?

Hy, the chip is working corectly, i'm able to run the blink example, the chip is powered on 5v and its working on the internal 8mhz crystal (dont have a 16mhz one yet).

I have also tested the 328 pins 15-19 with blink example so they work.

Also tested the nRF24L01 on my mega and it works (bouth modules work on my mega)

It is weired, i might try with shoter cables ( now its like 9-10cm long ) and are wires from the cat5 ethernet cable, could this soufer any form of interference?

thanks

Long wires might be a problem. Have you tried varying the SPI clock speed? I'd try setting it at the slowest speed, since you are only using an 8MHz 328.

If all else fails, you could try bit-banging the SPI to see if you get a response that way.

thanks for the prompt answer, since i am new to this as i said before i have no idea how to change the SPI clock speed,

but i'l look into this becouse you might be right :slight_smile: i'l check it out and if i manage to get it working i'l update this post :slight_smile:

thanks

ps also have no idea how to "bit-banging" the SPI :wink: but i'l check google.

Assuming your SPI initialisation code looks something like this:

// initialize setup
void setup(){
  pinMode (CLKpin, OUTPUT); // set CLKpin as an output
  pinMode (MOSIpin, OUTPUT); // set MOSIpin as an output
  pinMode (MISOpin, INPUT); // set MISOpin as an input
  pinMode (SSpin, OUTPUT); // set SSpin as an output
  pinMode (CEpin, OUTPUT); // set CEpin as an output
  SPI.begin(); // initialize SPI
  
  SPI.setBitOrder(MSBFIRST); 
  SPI.setDataMode(SPI_MODE0); 
  SPI.setClockDivider(SPI_CLOCK_DIV128); 
}

the last line sets the clock speed. Try a larger number for the clock divider, e.g., if you are using SPI_CLOCK_DIV2, try SPI_CLOCK_DIV4 instead. I think SPI_CLOCK_DIV128 is the largest divider available (slowest clock rate).

"Bit-banging SPI" just means doing it all in software using digitalRead()/digitalWrite() functions or their equivalent to send/receive the bytes. It's slower than hardware SPI, but can be a useful backup method in a variety of situations. It's not difficult to implement, and there are plenty of code examples posted in these forums.

Hy again, this time i have setup a atmega 1284p at 16mhz to run the nrf24l01, used the pic in atach to connect the module like this

nrf pin 1 -> gnd
nrf pin 2 -> 3v
nrf pin 3 -> atmega pin PB4
nrf pin 4 -> atmega pin PB3
nrf pin 5 -> atmega pin PB7
nrf pin 6 -> atmega pin PB5
nrf pin 7 -> atmega pin PB6

the sketch was the "Getting Started" example from rf24 library wich again on my mega 1280 works perfectly (check the mega1280.jpg from atach)

and on my atmega 1284p not (check atmega1284.jpg from atach).

i also tryed to connect to switch PB4 with PB3 and the sketch looks like this

//
// Hardware configuration
//

// Set up nRF24L01 radio on SPI bus plus pins 9 & 10 

RF24 radio(4,3);

//
// Topology
//

again i switch radio 3,4 on each combination of connecting my nrlf to 1284

can any one please help me , tell me how to connect it if i'm doing something wrong or what do i have to modify to the code so this can work on my mega 1284.

thanks again and please excuse my poor english.

ATMEGA1284P-pinout.jpg

mega1280.jpg

atmega1284.jpg

hi LittleJ,

I' m having the same problem with my breadboarded Arduino. I 'm using Atmega328PU with 16Mhz .
I' hv tried the example from RF24 Lib, unfortunately i failed to get any communication. May be the SPI speed is the cause, i plan to change that to slower speed.

Jeen

Hy Jeen, if you succed please let me know also how to do it, how you connected your's and how to change the spi speed. Thanks

got it working !!!

it seemd that 3.3v suply from the FTDI cable wasnt working corectly...

as soon as i figured the mega 1284 pins corectly (for cs and cse) and powered from 5v works ok

RF24/examples/GettingStarted/
ROLE: Pong back
*** PRESS 'T' to begin transmitting to the other node
STATUS           = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0xf0f0f0f0e1 0xf0f0f0f0d2
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR          = 0xf0f0f0f0e1
RX_PW_P0-6       = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA            = 0x3f
EN_RXADDR        = 0x03
RF_CH            = 0x4c
RF_SETUP         = 0x07
CONFIG           = 0x0f
DYNPD/FEATURE    = 0x00 0x00
Data Rate        = 1MBPS
Model            = nRF24L01+
CRC Length       = 16 bits
PA Power         = PA_HIGH
*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK
Now sending 3500...ok...Got response 3500, round-trip delay: 22
Now sending 4524...ok...Got response 4524, round-trip delay: 23
Now sending 5549...ok...Got response 5549, round-trip delay: 23
Now sending 6574...ok...Got response 6574, round-trip delay: 22
Now sending 7598...ok...Got response 7598, round-trip delay: 23
Now sending 8623...ok...Got response 8623, round-trip delay: 23
*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK
Got payload 47191...Sent response.
Got payload 48216...Sent response.
Got payload 49240...Sent response.
Got payload 50264...Sent response.
Got payload 51288...Sent response.
Got payload 52312...Sent response.
Got payload 53336...Sent response.
Got payload 54360...Sent response.
Got payload 55384...Sent response.
Got payload 56408...Sent response.
Got payload 57366...Sent response.
Got payload 58390...Sent response.
Got payload 59414...Sent response.
Got payload 60438...Sent response.

with a minor glitch :wink: sometimes bouth modules initialize ok but if i switch one to transmit role all i get is timeout, if i go on the other module and switch it to transmit works ok, swap again and the other module works too on transmit... kinda weired got to look into this anyway :slight_smile:

later edit : its like this, all connected ok

module 1 (on mega1280) on transmit module 2 (on mega 1284) on recieve works fine for minutes now
if i reset module 2 i will get timeouts even afther its restarted
i switch module 2 on transmit and back on recieve (withouth doing anithing to module 1) they begin to work again:

Failed, response timed out.
Now sending 672739...failed.
Failed, response timed out.
Now sending 674015...failed.
Failed, response timed out.
Now sending 675290...failed.
Failed, response timed out.
Now sending 676564...ok...Failed, response timed out.
Now sending 677770...ok...Failed, response timed out.
Now sending 678974...ok...Got response 678974, round-trip delay: 24
Now sending 679999...ok...Got response 679999, round-trip delay: 24
Now sending 681024...ok...Got response 681024, round-trip delay: 24

if i reset module 1 and switch it back to transmit all works corectly :frowning: so its something with the module on atmega 1284 or my wiring or something i dont know if you can sugest something i would greatly apreciate it.