More on RF communications ...

Still playing with Nordic's nRF2401L+ modules here. I'm wondering if this is feasible, or if someone might have a better solution. The goal of the project is to have one single RF module send information to a bunch of "slave" ones who are listening. In order for this to happen in some organized chaos, each "slave" module has a specific receiving address (which gets set using Mirf.setRADDR() ). This has to be done in code. So for each slave, I need to modify the code and upload. I'm trying to figure out a better way of not doing that.

So here's what I'm wondering: Since the transmitter has a fixed address (again, set in code), is it possible to have the slaves request an address, as opposed to me having to manually set it in code each time? I'm thinking of something like this:

transmitter = master (it's address is set from a grounded pin)
slave boots up with a temporary address (derived from a random number)
slave transmits that address to the master and requests a new address
master then checks a builtin array for what's available and responds with that new address
slave then reconfigures itself with that new address

It would mean calling the transmit and receive address routines a few times during this handshake, but theoretically it should be possible, yes? Anyone see a problem with this, or has a better solution?

or has a better solution?

A better solution, yes. Write a simple sketch that stores an ID in EEPROM. Set the value to write, and upload that sketch. The value (that modules unique ID) into EEPROM.

Then, load the real sketch which, in setup, reads the ID from EEPROM. Each module will then know its ID.

The master needs to know the slaves IDs, so that it can address the correct slave.

Hmmm, nifty ... didn't think of that ... I'll go have some fun now.

Nice. Now that I have that under control, it makes things easier when I need to update all the modules. Question though, going back to my original post, does that seem doable? It's no longer a requirement for this project now that I'm storing the ID in EEPROM, but I'm curious whether it could also be done that way.

slave boots up with a temporary address (derived from a random number)
slave transmits that address to the master and requests a new address

There would be nothing to prevent two slaves from booting with the same random number.

A slave, by definition, should not be initiating communication with the master.

If you allow for this one time "Give me an ID" message, the master might end up responding to two slaves, giving them the same real address.

Careful programming would be required to handle to incoming messages with the same ID.

I don't think that this is a good idea. If you allow a slave to initiate communications, you have no way of preventing two slaves from talking at the same time.

Gotcha. Random isn't perfect ... :slight_smile:

One thing I did notice early on was that if I have two slaves with the same ID, it didn't seem to make any difference. Now, I say that, however keep in mind I am referring strictly to what I am doing. For others it might very well be a problem. But in my case, I'm just having the master send out a double digit number. The slaves pick that up and react accordingly. All the slaves do the same exact thing. In a situation where they each do something different, then having a unique ID will be important.

And ideally, I want to write portable code, so if in the future I end up doing something where I need a one-to-one communication path, I don't have to re-invent the wheel again. So your EEPROM solution is by far the best way to go.