0
\$\begingroup\$

My end goal is to read information from an nRF24l01 module connected to my Arduino UNO R3 and generate an interrupt while doing that.

I have read that for hardware interrupts, only pins D2 and D3 can be used to generate interrupts. However, while connecting the MISO line, I saw that here it was mentioned that

On some Arduino boards (see table above), pins MOSI, MISO and SCK are the same pins as digital pin 11, 12 and 13, respectively. That is why many tutorials instruct you to hook up the target to these pins.

On every website I have searched, MISO is always connected to 12. Is there any way to change the MISO line from 12 to 3, or will I have to resort to using pin change interrupts?

Another way I can think of to bypass this is to connect D12 to D3, but I'm afraid this may cause complications in the circuit.

\$\endgroup\$
9
  • \$\begingroup\$ You would have to initiate the communication to nRF24l01 though? \$\endgroup\$
    – Ralph
    Jun 24, 2023 at 5:24
  • \$\begingroup\$ I did, using the RF24 library @Ralph \$\endgroup\$ Jun 24, 2023 at 5:38
  • 1
    \$\begingroup\$ If you are actively reading from the module, why do you need an interrupt, when you know in the Arduino code exactly when you are doing the read? nRF24l01 has a separate interrupt pin to let the master know when data is available, but it cannot automatically start sending it to the master. \$\endgroup\$
    – Ralph
    Jun 24, 2023 at 5:48
  • \$\begingroup\$ The project is to make a car, which will immediately change direction when a new signal is sent to it via a transmitter nRF module. In order to implement the "immediately" portion, I need interrupts. \$\endgroup\$ Jun 24, 2023 at 6:01
  • 2
    \$\begingroup\$ no you don't need inteerupt for that, just be fast enough that no-one notices, \$\endgroup\$ Jun 24, 2023 at 9:16

1 Answer 1

2
\$\begingroup\$

Connect nRF24l01 module IRQ pin to Arduino Uno pin 3 to raise an interrupt when data is received by the nRF24l01 module.

In the interrupt function, perform a SPI read or set a flag for the main loop to perform a read, to keep interrupts simple.

With SPI the master device needs to read the nRF24l01 module, the module cannot automatically send data over SPI.

To answer the actual question, which don't achieve what you trying to do though:

There's no way to change HW SPI MISO to pin 3 on an Arduino Uno, but you could bit bang SPI through any GPIO.

You could connect Arduino pin 12 to pin 3 to raise an interrupt every time the master is reading SPI devices.

\$\endgroup\$
5
  • \$\begingroup\$ So I'll still read through the MISO(12) right? \$\endgroup\$ Jun 24, 2023 at 7:18
  • 1
    \$\begingroup\$ Yes, that's the hardware SPI. Otherwise you would need to implement SPI in your code. nRF24l01 only sends data to MISO when the master requests so and gives clock pulses in the SPI clock. \$\endgroup\$
    – Ralph
    Jun 24, 2023 at 7:21
  • \$\begingroup\$ Thanks a lot. You saved my day! \$\endgroup\$ Jun 24, 2023 at 7:32
  • \$\begingroup\$ Hi @Ralph, hope you don't mind one last question: if I write if(radio.available()) radio.read(msg, 8*sizeof(char));, does msg have to be initialised as an empty string, or can I run this in a loop and msg will be successively overwritten? Thanks \$\endgroup\$ Jun 24, 2023 at 10:54
  • 1
    \$\begingroup\$ It will be overwritten, no problem, as long as you know which section was the old message and which is new. And make sure you know if the read has failed to fetch anything. \$\endgroup\$
    – Ralph
    Jun 24, 2023 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.