nRF24 / RF24

OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
https://nrf24.github.io/RF24
GNU General Public License v2.0
2.2k stars 1.01k forks source link

Is this compatible with the ATSAMD21 Processor? [Question] #897

Closed AceSimulations closed 1 year ago

AceSimulations commented 1 year ago

I am trying to get the gettingStarted working on a Adafruit feather M0 processor but it will say "radio hardware not responding". I have tested this same code on a feather 32u4 and it works flawlessly. I have verified the CE and CSN pins are correct and am fairly certain that the MO, MI, SCK pins are also correct considering they are labeled on the board. I have done tons of searching and it seems like this has been an issue in the past but it does not seem to be resolved.

The pinout for the M0 is here - https://cdn-learn.adafruit.com/assets/assets/000/107/293/original/adafruit_products_Adafruit_Feather_M0_Adalogger_Pinout.png?1639414889

VCC - 3.3 GND - GND CE - 11 CSN - 12 SCK - SCK MOSI - MOSI MISO - MISO

2bndy5 commented 1 year ago

I can vouch that this works for the ATSAMD21. In fact, I've added enough code to make printDetails() work on that chip if using the Adafruit Core for their M0 boards. Its worth noting that I always have to change the CE & CSN pin numbers specified (via RF24::RF24(ce_pin, csn_pin)) in the examples to get them working on my various ATSAMD21 boards...

Looking at your pinout link, I want to be clear that when you say 11 & 12, you really mean D11 & D12 (not the 11 & 12 outlined in green).

I have done tons of searching and it seems like this has been an issue in the past but it does not seem to be resolved.

I'm not sure what you're referring to here.

2bndy5 commented 1 year ago

What radio module are you using? PA/LNA?

Sometimes I have to lower the SPI speed to 4000000 (3rd arg in c'tor) if my wires are a bit lengthy.

AceSimulations commented 1 year ago

I tried D11 and D12 but it claims that it is undefined. So I have instead tried 0 and 3 but that has not worked either. I am not sure what I am doing wrong and am rather lost. // instantiate an object for the nRF24L01 transceiver RF24 radio(D11, D12); // using pin 7 for the CE pin, and pin 8 for the CSN pin I am using the NRF24L01+ PA module.

Thank you for the quick reply.

2bndy5 commented 1 year ago

The only board (that I know of) that actually has pins defined they way they are written in the silkscreen is the NodeMCU (ESP8266).

RF24 radio = RF24(11, 12);

The way you are declaring the pins should be correct. I wish I could ensure confidence there, but the pin definitions in the Arduino core are rather convoluted.

Have you tried lowering the SPI speed? Some boards have higher impedance than others, and I usually run into this with an ATSAMD21 based Adafruit board.

AceSimulations commented 1 year ago

I lowered the SPI speed quite a bit and still no luck. I have tried basically every pin combination on the board. I know the board and transceiver are functioning. I even swapped transceivers and still nothing. Is there a way I can define every pin I am using instead of just CE and CSN? (Ex. MOSI, MISO, SCK, CE, CSN) The Adafruit feather M0 uses GPIO 24/23/22 for SCK/MOSI/MISO.

AceSimulations commented 1 year ago

Update: I did something I am not sure what and now it is working. I believe it was using RF24 radio(5, 6, 4000000);. I am not sure why it is now working but my guess is my wires were barely too long for the SPI speed I was testing it at.

2bndy5 commented 1 year ago

Is there a way I can define every pin I am using instead of just CE and CSN? (Ex. MOSI, MISO, SCK, CE, CSN)

Technically yes, but that technique is meant for using a board's non-default SPI bus. More info is in the RF24 docs' Arduino page. I didn't add an example for the ATSAMD21 because many boards don't usually have the required GPIO pins exposed.

If you were trying to refer to software-implemented SPI, then that may be possible via the DigitalIO library (required for SoftSPI in RF24). There might be some arch limitations in DigitalIO though.

not sure why it is now working but my guess is my wires were barely too long for the SPI speed I was testing it at

In my experience the wires don't have to be very long (happens with 5-6 inch jumpers for me).


FWIW, I also tend to use A0 & A1 on my QtPy boards (1 of which has the ATSAMD21):

radio = RF24(0, 1);

I'll close this now that you're back on track. 🎉