Detecting Neighbour Arduino

Hello!
Im trying to connect arduinos togheter.
Im aware of i2c communicatons that will allow many arduinos being hooked togheter on two lines.
Thats all fine and dandy to send and recive data to a specific unit via address.

But need to connect arduinos in a mesh style where one arduino is connected to max four other.
And then a master being able to ask this arduino for the ids of the neighbour to this arduino.

The ideal way is if i could ask all the slave arduinos there respective neighbours address or id or similar.

Here is a basic image:

Also the IDs could change..
So i could never know beforehand where in the chain a certain ID would be.

So in short, i want to create a node network with the nodes being able to communicate who they are connected to

Any help would be very useful, or ill just continue to pull my hair.

THX! :slight_smile:

Seems like quite a difficult project. Have you written any networking code before?

No not that much.
In regards to the arduino ive only done basic stuff.

But im interested in if this actually is possible.
And in theory how it could work.

While im working through more simpler learning projects.

From my limited understanding i dont think i can use IC2 to get this to work.
Since it would never know who is connected to who.

Been looking at SPI but that would require the master having one pin for each SS line. right?
So if i had 50connections i would need 3+50 digital pins so not sure about that.

But im not sure if im just having the wrong idea about this whole thing.

Maybe you need a processor with 2 hardware serial ports ('1284P). One port lets a sub-master report to the master, the 2nd lets each sub-master talk to its slaves. Just change you architecture a little bit, with what is ID7 now being the master, ID3 and ID9 being two possible submasters, and ID1, 2, and 5 being slaves to those sub-masters.
Use RS485 buffering to achieve fast 2-way communication between the master and submasters, and between the sub-masters and slaves.
http://www.digikey.com/product-detail/en/texas-instruments/SN75C1167N/296-6961-5-ND/371584

I offer '1284P cards in different form factors, this one has prototyping area for plugging in a dual RS485 chip to create the 2 networks for the master and submasters
http://www.digikey.com/product-detail/en/texas-instruments/SN75C1167N/296-6961-5-ND/371584

Sounds interesting, not sure i fully understand.
But the diagram only shows one possible way of connection, every single node could be a "submaster".

For example node ID:1 could have another node attached on L4.

Basicly i want to be able to add nodes "in runtime" or create diffrent node patterns.
Then having the software recreate the node hierarchy later on.

So i would need to know who was connected to who to be able to recreate it in software.

I have heard some one did a library, but I can't remember...
But if you have some plan in the future to use a cheap 433MHz transeivers, you may consider use PJON library ! GitHub - gioblu/PJON: PJON (Padded Jittering Operative Network) is an experimental, arduino-compatible, multi-master, multi-media network protocol.

rmartins:
I have heard some one did a library, but I can’t remember…
But if you have some plan in the future to use a cheap 433MHz transeivers, you may consider use PJON library ! GitHub - gioblu/PJON: With PJON you build networks of devices for free with no need of a cloud service or a centralized platform you don’t fully control.

I remember! You can use the PJON with 2 wires too ! There’s the PJON that is wired and PJON_ASK for wireless!
You can download directly from your Arduino IDE by search on library for PJON !

rmartins:
I remember! You can use the PJON with 2 wires too ! There's the PJON that is wired and PJON_ASK for wireless!
You can download directly from your Arduino IDE by search on library for PJON !

Sounds like a great way to communicate!
Would this be able to help me detect neighbouring connections tho?
Was looking at the PJON wiki and it said something like this: "Broadcast functionality to contact all connected devices"
And that sound interesting for sure, but im not sure what they mean with all connected devices, maybe every single one in the chain.

Gobaz:
Basicly i want to be able to add nodes "in runtime" or create diffrent node patterns.
Then having the software recreate the node hierarchy later on.

So i would need to know who was connected to who to be able to recreate it in software.

I understand the idea of being able to add nodes at different locations and without knowing in advance what is the address of a particular node.

However I don't understand what you mean by the 3rd sentence above. My concept of Arduino software is that it is all created at compile time - i.e. long before any nodes are connected.

I have not experimented with I2C so this may be a mad idea ...
Suppose you have a list of all the possible addresses. Then a node could iterate through the list and if it gets a response it knows the address of the node at the other end and can make a note of it. From that point onwards it does not need to waste time going through the list.

...R

Gobaz:
Sounds like a great way to communicate!
Would this be able to help me detect neighbouring connections tho?
Was looking at the PJON wiki and it said something like this: "Broadcast functionality to contact all connected devices"
And that sound interesting for sure, but im not sure what they mean with all connected devices, maybe every single one in the chain.

I never have tested this before, but maybe it's a great opportunity for you to get started!

Robin2:
I understand the idea of being able to add nodes at different locations and without knowing in advance what is the address of a particular node.

However I don't understand what you mean by the 3rd sentence above. My concept of Arduino software is that it is all created at compile time - i.e. long before any nodes are connected.

I have not experimented with I2C so this may be a mad idea ...
Suppose you have a list of all the possible addresses. Then a node could iterate through the list and if it gets a response it knows the address of the node at the other end and can make a note of it. From that point onwards it does not need to waste time going through the list.

...R

Yes your correct the arduino would have its compiled code in chip checking sensors and whatnot.
Then ill use "COM programming" to recive data from the master.
While the master is connected via com.
For example asking the master what nodes are connected right now.
And the master would check the chain of connections and relay the information.
Anyways thats the idea.

Not sure how you mean.
But if using I2C wouldent all the nodes be able to see all the nodes at all times?
There by i wouldent able to get the correct hierarchy.
But to be honest im not sure how just one signal cable could recreate the entire hierarchy.

Hi,
First, Why I2C?? It has limited distance.

Do you need great speed?

A multi-drop RS-485 network might be a lot easier… And you can go hundreds or 1000’s of feet, depending on speed…

Tell us more about your whole physical setup and what speeds are needed…

terryking228:
Hi,
First, Why I2C?? It has limited distance.

Do you need great speed?

A multi-drop RS-485 network might be a lot easier.. And you can go hundreds or 1000's of feet, depending on speed..

Tell us more about your whole physical setup and what speeds are needed...

To be honest i dont know to much about network communications.
So i just got the impression I2C was the main way to go.
Only reason is i dont know enough to know what setup would be better.

I dont need great speed at all!
I would not even need great distances.
Every node would be connected close the the next one.

The setup would be blocks connected in various ways to form diffrent shapes, like legos.
But i need to know the exact connections between all the pieces.
To be able to use COM to recreate a representation of the shape in software.

No multidrop topology can determine what node is "next to" another.

I wrote a spec for a ring network that did this my asking the network for a "map" of the used addresses then taking a free one. But this was a peer-to-peer network with each node knowing the details of its neighbour.

If you have a master just ask it for an address when you add a new node.

If the new node has an address of say 0xFE, every now and then the master polls that address and if something is found a transaction is performed that allocates the new node an address.

But AFAIK there no possible way to determine the physical "shape" of the nodes, that's an entirely different problem to networking.

Graynomad:
No multidrop topology can determine what node is "next to" another.

I wrote a spec for a ring network that did this my asking the network for a "map" of the used addresses then taking a free one. But this was a peer-to-peer network with each node knowing the details of its neighbour.

If you have a master just ask it for an address when you add a new node.

If the new node has an address of say 0xFE, every now and then the master polls that address and if something is found a transaction is performed that allocates the new node an address.

But AFAIK there no possible way to determine the physical "shape" of the nodes, that's an entirely different problem to networking.

But then the master would have to be connected to the computer while connecting nodes, right?
I was thinking it be nice you create the network and then you plug in the master to the pc, like when ur done.

It wouldent need to know the physical shape only what side its connected to.

Oh i forgot you can connect it to an external power source, doh :stuck_out_tongue:
So that could work.

Why would the master need a PC, it has a brain of it’s own, albeit smaller. It can do all the mapping then just tell the PC when you plug it in.

But I still don’t think it’s possible to do what you want with any multi-drop topology, the drawing in the OP is not multi drop and I2C et al are.

BUT

If your network is a string of point-to-point nodes with two or more comms ports on each node then it should be easy(ish) to do.

Haha yeh i know arduino is smart ;D
No i was just thinking about the powersource.
But yeh batteries exists i guess.

Hmm you dont think I2C could work with that?
I feel like it could work.
Maybe if each side of the shape had a pushbutton of some sort.
Then the new node connected would just tell the master what side it was connected.

How do you mean?
Using micro-usb -> micro-usb?

But could one 9v battery power multiple arduinos?
Say 100 in a chain?