I've got 8 slaves running from a master and would like to be able to have some sort of auto sensing.
Comminication is via RS485 and the slaves are approx 5 meters apart.
The slaves all does the same function and I/O's are the same.
So instead of manually set an address, I would like to be able to just plug the boards in and the master knows where the slave is.
So I figure that master talks to slave1 and slave1 talks to slave2 etc
I have looked around on the site for sample code but have't found any.
possible using the wrong seach terms, but I have tried a few name variations
You can not have a slave talking to a slave, because to talk you have to be a master, or at least to initiate speaking.
I sounds like you need something like DMX or an RS485 protocol where you can send a broadcast message asking devices to respond with their address. You need a collision detection / avoidance protocol for this to work.
I read that I2C is good for 20 to 30m with an I2C bus extender.
I read a bit about DMX, but don't see how this could be satify.
I would like the addresses to be set automatically, if feasible.
This way I can simply swap the slaves around and room_1 will always be room_1 no matter what slave I connect and without doing any addresssing apart from a power down/up.
The above may require that I run a another wire between each slave and each slave is initialiased in a set order, ie
when slave_1 is up and running and master has given it an address, the an output goes high to the Slave_2 which then get initilaised.
I am a bit puzzled as to what you want exactly. You can not implement a variable address on an I2C system it uses fixed addresses.
If you do have a variable address and a bus discovery mechanism how do you know what you are talking to?
The 1 wire bus implements a unique address built into every device and is used for things like temperature sensors. So you can quiz the bus and find out what is hung onto it.
However, you then need to have some information as to where that device is measuring temperature to make any sense of it.