I have been trying to come up with a method of communicating with my arduino in a cheap manner, at distaces of around 10 meters.
I originally was going to use i2c or TWI, but I have heard that is really unreliable beyond 2m. I've heard the same problem from SPI.
I thought ethernet would be a nice way to go, but then realized that it will cost more than $20 per ethernet controller, let alone the cost of the arduino.
XBee is also too expensive, but I do plan on using it in the future for places that I can't run a hard wire to.
Is there no good solution? The end goal is to have my home computer plugged into the Arduino. It will give the Arduino commands to turn on/off lights, HVAC, etc, as well as return sensor data TO the computer from the arduino, so it needs to be two-way communication.
Ordinary RS-232 will do that sort of distance, and with a MAX232 chip, you can make an Arduino interface. Does your PC have a serial port (COM1:)? If not, you can add an inexpensive USB-to-serial converter gadget.
I had considered ordinary serial as a method as well, but will I run into a 'max serial outputs' issue on the computer? Lets say I have 15 arduinos controlled by one computer. Will 15 serial ports out of the computer be an issue? I could obviously not have one Arduino controlling all of the 15 'sub-duinos', but could a computer do it cleanly?
Sounds like a classic scenario for RS-485 and some kind of master/multi-slave protocol like MODBUS.
Advantages: cheap hardware, long cable runs, potentially many devices on "network"
Disadvantages: Steep learning curve, not a common interface or protocol (except in industrial control) so there's not much to build on from the Arduino community.
I know there are RS-485 to RS-232 converter boxes which are relatively cheap. Could I simply use a few of those?
The "physical" connection isn't really the challenge. It's the communication protocol for a shared bus on the same wires that's the hard part.
You could use a RS-232/RS-485 converter for the connection to the PC (as the "master) and then use a MAX485 (or one it's many clones) transceivers for the Arduino ends (to get TTL-level output). You might also need to invert the signal - not sure how RS-485 is "oriented" vs. RS-232 vs. TTL serial. But all this will get you is a long connection that is capable of handling serial data and having more than 2 devices connected to the same "cable" (because of the way RS-485 works). You still have to figure out how to make all of the devices talk to each other in a controlled manner.
It's doable, but it will be a long uphill battle.
Another probably better solution would be to go with I2C (since you get the multi-device support) and use a I2C Bus Extender. This little guy is supposedly good for 50 meters of cable length.
Will 15 serial ports out of the computer be an issue?
Ah! You didn't mention the need for 15 Arduinos in the original post! And yes, having 15 separate serial ports and cables would get a bit out of hand.
Will 15 serial ports out of the computer be an issue?
Probably not from a software point of view: I think just about everything that runs on modern versions of Windoze supports lots of COM ports.
Otoh, 15 serial ports would require about 5 hubs, and gobs of dongles and cables, making you the only person on the planet with a PC setup messier than mine ;D
RS-485 is not really that horrible. You do need to come up with a "message-based" protocol to make sure only one party is talking at a time, and that that party knows when to shut off its transmit driver. But it doesn't have to be as complex or robust as the industrial control protocols.
What kind of data do you want to transmit?
Do the 15 Arduinos have to send or do they only have to listen?
I use different communication protocols with the LumiNet boards, RS232 is a good idea and cheap. Or for simple LED applications with a low communication speed I use a bio-inspired protocol. If you tell us details about your setup or your idea then it would be easier to name the right communication interface. I mean, you could also use MIDI or Ethernet... it depends
Ok, lots of stuff to read, I'll have to get back to the couple of posters who posted the pdfs :) I'm excited!
I'm basically going to have a distributed network of Arduinos, each no more than 10m from a central PC which will communicate with the Arduinos. Many of the arduinos will be doing on/off/dim type controls for a lightswitch. Others would be controlling vents from the HVAC, getting temperature readings, or various other data.
So the data has to be two-way, but it doesn't have to be fast. Probably 1 Hz would be plenty. And the throughput would be low. Maybe a few bytes each time; basically just status data for the main computer. The Arduino's may not even talk unless the master tells them to 'wake up' and 'do something'.... Still working on that part.
Thanks again everyone for your help!
Are Arduinos even necessary at the end where the light switching etc. is done? Look I am like a total newbie and I may be wrong about this.
How about, you use some kind of RF setup. At each node, you can have an RF transciever module ( or an Rx/Tx set .. really cheap these days ), which is connected to a decoder like the HT12D. Each node will use a unique address for decoding ( see the datasheet of the HT12D or see this page http://multyremotes.com/four-channel-IR-remote.htm ). The output pulses from the decoder can then be used to switch things using relays or transistors or whatever.
If the node needs to send data, it will use an encoder like HT12E to encode the data using the same address and then send it using the RF Transmitter module.
Now at the computer end, you can have an arduino connected to an encoder/decoder setup and an RF transciever.
The address lines of the encoder will have to be controllable by the arduino. You may either connect all 8 pins directly to the arduino or use some shiftOut shift register setup.
Each time the PC part needs to send data to a node, it would set the appropriate address to the HT12E and send the data required.
For receiving the data, the arduino would need to somehow manually take the serial data from the RF receiver. Compare the first 8 bits ( the address ) of the recieved data with that of each node and decide which node the input is coming from, and do whatever is necessary.
What I have tried to do is to make the most of the processing power available. I think you don't really need one arduino at EACH node to do something really simple like switching on/off a device according to input or to send back some sensor data to a master control device.
I hope that was useful. :)