I have 256 binary sensors (switches) which i don´t want to multiplex to the arduino. What are my other options rather than that, like connecting them to a I2C bus network. Id like also to know if its possible using ethernet protocols like RS-485 to receive the info of these switches.
Note: All the switches must be singularlly identified, since each one outputs a different thing.
Why do you not want to multiplex the signals ?
What kind of sensors are they, are they mechanical switches that can bounce ?
You can use cascaded shift-in registers: Arduino Playground - ShiftRegSN74HC165N
hi, the goal is to only drive 2 to 4 wires through a long distance. I cant use shift registers because they accounter the same problem since, i would only put them mounted near the location i will have the arduino (a bit far from the sensors). I´m looking now for RS-485 type switch sensors, but im not having a lot of luck. I also don´t know how i am going to receive the data from them to the arduino.
And yes they are mechanical switches.
Mutiplexing (matrix) is the easiest and most commonly used solution. You need just 32 pins (16x16) - if you don't have that many, that'd be a two PCF8575 or MCP23017 port expanders if you prefer I2C, or four shift registers. All switches are individually identifiable this way.
If you really don't want to multiplex:
8 PCF8575 and 8 MCP23017 port expanders (each set can handle 128 switches - no more of each as you run out of I2C addresses).
32 shift registers (it should be possible to daisy chain that many but you may run into scaling issues).
prokiller1800:
hi, the goal is to only drive 2 to 4 wires through a long distance.
Are those switches close together but far away from the Arduino? If so, a second Arduino may be the solution. It reads the switches locally, then sends the data over your long line (RS485 is an option indeed) to the other processor.
Even not knowing those sensors I can tell you: it depends on the details of the actual layout of your complete project, which you didn't describe in much detail, just that for some reason that huge number of buttons is "a long distance" (how long is long?) from the Arduino.
My friend wanted to monitor food amount (weight) in 400 feeders on one farm heh)
Your best bet is WiFi or BT or design non standard protocol translating and forwarding spi/i2c etc.
My other engineer friend designed some kind of device transferring data over one wire in large warehouses.
That was inhouse company job and I know it is some kind of common standard just look it up.
First there were 256 switches, now 400 feeders. Are you sure about what you want?
Anyway, let's assume you are. Now what output do those feeders produce? I assume they can tell how much food they dispensed?
Design a circuit for one such feeder, have it talk over RS485 (max 32 nodes normally). Bundle those together in groups, so you have 13 groups, and those in turn over a second RS485 bus communicate all their data to a central master.
Get it working, design a PCB, have it manufactured, test it very very thoroughly, produce 500 of the same (ask the factory to program the things for you). Use an ATtiny instead of ATmega to save a lot of cost. Install it all.
Make sure you have a big enough budget for this. You're going to spend a lot of time testing, writing software, testing, writing more software, installing, testing, trying another way of installation, fix wires that the cows ate, write more software, test again, etc.
Oh, and get some real expertise. This is not a beginner's project.