I2C or Wireless ?

Hi,

So I have a new project coming up and I'm collecting info on what to use, how and why, I need I2C or Wireless connection as came in my mind to connect more arduinos together they gonna be like Single Master and many slaves only a single direction communication.

My question now is should I use I2C or Wireless?

(If you want to follow my other topic : http://forum.arduino.cc/index.php?topic=409536.0) I'm talking about using I2C.

But I kinda changed my mind for few reasons so I need some ideas or suggestion I2C or Wireless (nRF24L01).

One reason I kinda changed my mind is I need to use a lot of shielded thick cable and long which i will need to use I2C externders and a lot of cables hanging around. On the other side we got Wireless communication I chose nRF24L01 because I'm familiar with it and I done some projects in the past, no cables hanging around, less circuits, wireless communication and range up to 10 meters indoor walls..etc and out up to 50~100~140 meters.

But I didn't talked about my project, so It gonna be a Master and more than 5~10 arduinos connected and master only talking / sending data to slaves.

Ideas/suggestion/reasons? I'd like to hear your opinions.

D.60

Or how about some other kind of wired serial (lowercase 's') communication. I'd say it depends on the complexity of each path. The simplest wins.

Domino60: Hi,

So I have a new project coming up and I'm collecting info on what to use, how and why, I need I2C or Wireless connection as came in my mind to connect more arduinos together they gonna be like Single Master and many slaves only a single direction communication.

My question now is should I use I2C or Wireless?

(If you want to follow my other topic : http://forum.arduino.cc/index.php?topic=409536.0) I'm talking about using I2C.

But I kinda changed my mind for few reasons so I need some ideas or suggestion I2C or Wireless (nRF24L01).

One reason I kinda changed my mind is I need to use a lot of shielded thick cable and long which i will need to use I2C externders and a lot of cables hanging around. On the other side we got Wireless communication I chose nRF24L01 because I'm familiar with it and I done some projects in the past, no cables hanging around, less circuits, wireless communication and range up to 10 meters indoor walls..etc and out up to 50~100~140 meters.

But I didn't talked about my project, so It gonna be a Master and more than 5~10 arduinos connected and master only talking / sending data to slaves.

Ideas/suggestion/reasons? I'd like to hear your opinions.

D.60

You mention you've used the wireless modules before. Does that also include a topography as you describe here, with one master and multiple slaves?

You should probably start by writing code that defines a common data exchange interface for your application, which encapsulates the differences related to transport medium, if possible. Your main application should not necessarily need to know how the data exchange works, or even if it's using i2c, rs232, rs485, cabled or wireless.

Wireless sounds promising, and I think may in many cases be an important factor contributing to a completed project actually being used, not having to bother with physical cables. After all, we have become used to everything being wireless these days! :-)

But it depends of course on the complexities, reliability and requirements. Addressing multiple targets on a single i2c or some serial bus as mentioned by ChrisTenone is probably more reliable, at least initially, and may help you develop the application logic, while simulatenously you can work on the spesifics of wireless communication, and switch between the two, to ensure same functionality regardless of comm. medium.

this is the heart of an XY problem. you have made multiple choices, and are asking us to make a choice between two things without knowing what is occurring.

are you data logging and transferring the information so you can store 10,000 sensors readings a second ? are you monitoring how often your cat comes in and out the doors of the house ?

are you monitoring PIR sensor in each space of a 20 acre warehouse ?

this is the heart of an XY problem. you have made multiple choices, and are asking us to make a choice between two things without knowing what is occurring.

As all my projects I can't tell exactly what I'm trying to build I can tell only how and few parts I just ask for suggestions here to see what to use and what is better to use, as I said I'm gonna use ONE Master [only] and many slaves and it gonna be only in a single direction communication.

You mention you've used the wireless modules before. Does that also include a topography as you describe here, with one master and multiple slaves?

You should probably start by writing code that defines a common data exchange interface for your application, which encapsulates the differences related to transport medium, if possible. Your main application should not necessarily need to know how the data exchange works, or even if it's using i2c, rs232, rs485, cabled or wireless.

Wireless sounds promising, and I think may in many cases be an important factor contributing to a completed project actually being used, not having to bother with physical cables. After all, we have become used to everything being wireless these days! :-)

But it depends of course on the complexities, reliability and requirements. Addressing multiple targets on a single i2c or some serial bus as mentioned by ChrisTenone is probably more reliable, at least initially, and may help you develop the application logic, while simulatenously you can work on the spesifics of wireless communication, and switch between the two, to ensure same functionality regardless of comm. medium.

I used I2C with multiple slaves but not wireless with multiple slaves the idea is the same for wireless and I got an idea how it will work in code, the code is not the problem here I can handle it and everything will work for sure.

The idea of this topic and project is what to use what's the advantages and disatvantages of wired and wireless communication.

I can use I2C but I need a lot of cables shielded cables to remove the noise as well for 1~2meters+ and as I will have like 5 + slaves you can understand that I need a lot of cables. In the other side I can use wireless no cables needed ..etc but I'm afraid of the freq. noise or jammers that may block my communication.

The project needs to be a secure/protected system, if someone jam/hack the wireless system that system will not work but as well I don't like the idea of using a lot of cables.

D.60

If wireless works the nRF24s should be a great deal simpler and probably cheaper than any wired solution.

A “master” nRF24 can transmit to a large number of listening “slave” nRF24s. If there is no need for an acknowledgement then the same message can be picked up by all slaves listening on the same address. If you need to get an acknowledgement then I suspect the simplest thing is to give each slave a different address and send a message to each in rotation.

…R

A "master" nRF24 can transmit to a large number of listening "slave" nRF24s. If there is no need for an acknowledgement then the same message can be picked up by all slaves listening on the same address.

That's exactly my idea but I don't think a 32b packet will be enough for all slaves I will need at least to separate them in 2 groups and give them different addresses and send 2 packets one for each address.

But as I said I'm scared about the noise nRF use 2.4Ghz as wifi does and many mobile phones or portable modems nowadays if the signal gets weak or jammed then project will kinda fail.

D.60

Domino60: But as I said I'm scared about the noise nRF use 2.4Ghz as wifi does and many mobile phones or portable modems nowadays if the signal gets weak or jammed then project will kinda fail.

That is something that can only be determined by a test at the site where you plan to use them.

I would not expect problems. They are specifically designed to work within the crowded 2.4GHz band. For example they have no trouble distinguishing two addresses one digit apart.

You can write code to fail gracefully or provide suitable warnings. For example the code I have for my model trains will stop the train if 8 successive messages are missed (about 1 second).

...R

Robin2

I never tested to see if a nRF24 is a different address than the one that transmits, can a random nRF receive data?

What I want to say is that I'm worry about security on my nRF's. I don't want a random person come up to my project and modify or see my data that I'm sending.

D.60

Domino60: I never tested to see if a nRF24 is a different address than the one that transmits, can a random nRF receive data?

I have a feeling this means the exact opposite of what I was trying to say. I have made 4 pairs of wireless units and each pair has a different address nnnnn nnnnn+1 nnnnn+2 etc and they can quite happily work alongside each other without one pair getting the data from another pair.

What I want to say is that I'm worry about security on my nRF's. I don't want a random person come up to my project and modify or see my data that I'm sending.

To intercept your signals with another nRF24 (or to send malicious signals to your system) the other person would need to use the same channel, the same data rate and the same address. The address is a 40 bit number - so if you take care not chose anything obvious like "12345" it would be very difficult to figure it out.

Of course I have no idea how easily the CIA or GCHQ could figure out your stuff - but that would not worry me.

...R

To intercept your signals with another nRF24 (or to send malicious signals to your system) the other person would need to use the same channel, the same data rate and the same address. The address is a 40 bit number - so if you take care not chose anything obvious like "12345" it would be very difficult to figure it out.

So the address can by anything in Dec or hex but no more than 40bit? I read on internet that choosing addresses 40bit it may cause a problem and some people suggest to use 32bit ..etc

Can you give me an quick example of how you pick an address on the nRF, Like what's the 1st Hex middle and what is the meaning of the LL (Long Long).

D.60

This applies to the obsolete nRF2401 protocol/device, not to the nRF24L01!

The nRF24 has a variable address size, both sender and receiver must be configured for the same size (number of bits). For simple coding without too much bit fiddling a multiple of 8 bits (= 1 byte) should be chosen. The remaining bits in the 256 bit (32 byte) packages is payload and CRC (if enabled). When you create a struct for the packages, it can look like

struct MyPackage {
 byte addr[5]; //40 bit = 5 bytes
 int data1; //16 bit = 2 bytes
 float data2;
 ...
};

Instead of [u]byte addr[5][/u] you can chose [u]long addr/u, if you like, to get rid of the array. Or you choose an odd bit size, to confuse possible intruders.

Domino60: Can you give me an quick example of how you pick an address on the nRF, Like what's the 1st Hex middle and what is the meaning of the LL (Long Long).

In my demo code an address is specified as

const uint64_t   deviceID = 0xE8E8F0F0E1LL;

which is copied closely from other demo code

If you look closely that is just 5 bytes E8 E8 F0 F0 E1

LL signifies a Long Long or a 64 bit integer.

In another program I have been writing I have specified the same address as

byte deviceID[5] = {0xE1, 0xF0, 0xF0, 0xE8, 0xE8};

The order is reversed because of the way the data is sent to the nRF24 in my other program.


I am a little confused by Reply #11. The address is not part of the 32byte data packet.

...R

Robin2: I am a little confused by Reply #11. The address is not part of the 32byte data packet.

It is, see the description of DATAx_W.

My question is how exactly do you chose the Hex Address is there a limit or I can choose any 5 byte hex?

Looking the table : http://www.rapidtables.com/convert/number/hex-to-ascii.htm I found in this URL there is a table from hex in binary and ascii, for nRF I can chose any hex value?

That's where i get confused.

D.60

DrDiettrich:
It is, see the description of DATAx_W.

Where is that description.

In the nRF24 code that I have been using the address is quite separate from the data that I want to send.

…R

I found it in nRF2401rev1_1.pdf, page 20.

If the library expects separate input of the address and payload, the total size of a data package (including CRC) still can not exceed 32 bytes.

Thanks. You document describes the older and obsolete nRLF2401. The newer nRF24L01+ does not have that limitation.

...R

Thanks, I was not aware of these dramatically different versions :-(

So could someone tell me, can you use any 5byte hex address value or there is specific ones that need to be chosen ?

D.60