Can two Arduinos share one NRF24L01 module?

Hi all-

As a starting point, is there any reason that I cannot have two breadboarded Atmega328Ps sharing a single NRF24L01 module? I've tried a couple of variations on having their SPI pins connected in parallel with no success. That doesn't surprise me, since it seems likely that connecting two clock signals together is not a very good idea! But I'm not sure if conceptually this should be able to work.

I could elaborate on why I want to do this, but it's a little involved so I thought I'd begin with the basic question and go from there. Thanks in advance!

regards,
Patrick

It really would be better if you explained what you are trying to achieve. For instance the 2 Arduinos could communicate with one another using a serial interface and use the RF24 module attached to one of them

Conceptually, as standard, it wont work, since as you suggested the two clock outs would conflict.

It could potentially be made to work, with enough effort to customise libraries and hardware, but I would suggest there would need to be a very worthwhile reason to do so.

Yet another "X-Y" problem...

Can I suggest the real problem is not how to get 2 Arduinos to share one nrf module. The real problem is getting one Arduino to do whatever it is you are trying to do with 2 Arduinos. Let us help you with that.

Now that's a good suggestion, Bob! I'm not sure why it didn't occur to me to connect things in a L instead of a T! I think I can manage to do that.

To put it simply, I am making a wireless pulse generator for my cnc. A single Arduino doesn't have enough IO for the 4x4 keypad, buttons, pots, encoder and radio.

So I currently have everything crammed into ( hanging off of?) a single 1284P, and it works....almost! I find that I get missed pulses (ie. machine jitter) every once in a while when cranking the encoder wheel. I've tried an awful lot of tweaks here and there to get around this, without success. I have a feeling that I'm at a point where the time/effort spent in tracking down the offending interrupt (or whatever) is a lot more than the 'divide and conquer' strategy!
Not that I'm opposed to expanding my knowledge, but ya gotta pick your battles!

I'll post back a little later with my results. Thanks again!

Patrick

A Mega does not have enough pins ?

Sorry, I meant an Atmega328P (on a breadboard).

To any beginners coming across this topic: a single Arduino, even an atmega328, does have enough I/O for all those things. It's just that @pferrick did not design his circuit carefully from the beginning. It's too late for him, but not too late for you!

Hi again-

I'm not so far along with my project that I cannot make revisions, and as I said I am not opposed to learning new microcontroller tricks....so! By my count a '328 has 20 pins available for IO. Here's what I need to connect to one and their pin requirements:

encoder - 2
4x4 keypad - 8
radio module - 5
a/d inputs - 2
hw serial - 2
direct input (Estop etc) - 2

which is 21 pins. I believe with the creative use of shift registers, this could be brought under 20. But that's still a pretty full house, and my experiments with a 1284P suggest that for everything to work without any lags or gaps in the transmitted data will require some fancy analysis and subtle configuration. A fair bit above my current skill level, in other words!

I haven'y put it together yet but I'm 99.9% sure that the UKBob's suggestion is going to work just fine,

thanks again to all
Patrick

Ok, let's have a think.

encoder - 2

One of these needs to be a hardware interrupt pin, so that's either pin 2 or 3 on the '328. The other can be any old digital pin, but can't be made part of a key matrix because the 2 encoder pins share a common pin, normally that's grounded. Perhaps pin 4, to keep the other hardware interrupt pin available for future use.

4x4 keypad - 8

This is the big pin-hog in the circuit. I would suggest an I/o extender. These connect to either the i2c or SPI bus. As the radio module also uses SPI, the I/o extender could share 3 of the same pins, so would only need one more pin for its exclusive use, as it's chip select pin, perhaps pin 9. MCP23S08 could do that. If you went for i2c bus, MCP23008 or PCF8574 would suit and would use pins A4, A5.

radio module - 5

This will need to be the HW SPI pins MISO, MOSI, SCK, SS, which are pins 10 to 13. Plus one other digital pin, e.g. pin 8.

a/d inputs - 2

Obviously those need to be analog pins. I would avoid using A3, A4 as you might want to use i2c bus. So let's assume A0, A1.

hw serial - 2

This has to be pins 0, 1.

direct input (Estop etc) - 2

Are these buttons or signal inputs from something? If buttons, they can potentially be made part of the keypad matrix, extending it to 5x4, which would only require one more pin. If digital signal inputs, where are the signals from and frequency/duration? Do they need to be interrupt pins, ordinary digital pins or could they be pins on an I/o extender?

So I think an 8-bit I/o extender would be my suggestion, dedicated to the keypad. This would leave you with a few spare pins on the '328 (3, 5-7, A3, at least). For future expansion you can add more I/o expander chips, with 8 or 16 I/o pins.

Finally, are you using an external crystal with the '328? If you don't need the 16MHz speed (few projects actually do) then you may be able to use the internal 8MHz oscillator, freeing up 2 pins which can be used as digital I/o pins.