I have some sensors from each of which I need to - read a voltage - be able to switch them on. (They are powered by AC 220V power supply).

Distance to be covered is some 40 meters.

I don't want to use to many wires in order to achieve this.

Solutions I have been considering are as follows: - 1-wire protocol - it's quite simple but some people have reported quite a few problems;

  • rs422, works well over long distances, but it might be a pricy solution.

In case I chose 1-wire protocol, how would I get my sensors connected to a 1-wire interface?

If rs422 is not too complicated and expansive I would go with this option as I might consider extending the network over some 200-250 metres in the future.

How would I connect my sensors to an rs422 interface? How would I get my Arduino talking with RS22?Have you tested any RS422 chips? I have seen quite a few of them online, but I am not sure which to choose.

Would it be too complicated to make an RS22 cable myself? I have looked on ebay and found only wires not long enough and too expansive.

  • \$\begingroup\$ How expensive is "too" expensive? \$\endgroup\$ – Ignacio Vazquez-Abrams Nov 2 '14 at 22:37
  • \$\begingroup\$ I would go for RS485 rather than RS422 or one-wire. You can use any two-core shielded cable, you don't need anything special. Interface to RS485 is usually through UART (MAX485 chip or similar). Keep it half duplex for simplicity. Have a small MCU with each sensor to connect it to the network (ATTiny, PIC16, etc). \$\endgroup\$ – Majenko Nov 2 '14 at 22:38
  • \$\begingroup\$ I can't recommend 1-wire for 40m distance. 1-wire was intended for cheap short-distance communication. Having said that, I was surprised to find this application note by Maxim: Guidelines for Reliable Long Line 1-Wire Networks. \$\endgroup\$ – Nick Alexeev Nov 2 '14 at 22:51
  • \$\begingroup\$ @Majenko-notGoogle What are the advantages of rs485 over rs422? \$\endgroup\$ – geraldCelente Nov 2 '14 at 22:55
  • \$\begingroup\$ @geraldCelente See my answer. \$\endgroup\$ – Majenko Nov 2 '14 at 22:56

Personally I wouldn't go for either RS422 or 1-wire.

RS422 is really a point-to-point connection, like RS232 (and is usually used to extend RS232), and 1-wire is really only for local connections within a PCB.

Instead you should use RS485.

RS485 is like RS422 (RS232 with differential signalling), except it's designed to be point-to-multipoint, or fully peer-to-peer.

Communication is usually half duplex (though not always, but it's simplest to keep it half duplex), and you'd usually use a MAX485 (or similar) chip to convert a microcontroller's UART connection to RS485. A single GPIO pin is used to switch into transmit mode when you want to send data on the network, and otherwise it's in constant receive mode waiting for data to arrive.

You would need a small microcontroller with each sensor to connect it to the bus - something simple, like an ATTiny, or a PIC16 - something with a hardware UART preferably, and of course whatever facilities you need to communicate with your sensor.

You'd then write a protocol (or use an existing one) whereby the Arduino sends a message with an "address" identifier in it onto the bus, along with a command, and the sensor programmed with the corresponding address reacts to that command, possibly then sending back data to the Arduino (a typical "call-response" protocol).

As for cabling, you don't need anything special. Simple two-core shielded serial cable is fine, though that can be considered overkill - if it's not too noisy an environment then any two-core wire would do. The best, though of course is twisted pair, and absolute top quality best is shielded twisted pair. A good choice is CAT5 Ethernet cable. It's cheap, comes in 305m rolls, and has 4 twisted pairs. You only need 1 of those pairs of course, so the other three could be used for other things - carrying power for instance.

  • \$\begingroup\$ If you're not going to use (recommend) a twisted pair then why bother with differential signalling? \$\endgroup\$ – markt Nov 3 '14 at 7:03
  • \$\begingroup\$ Agree with @markt - twisted pair is better than sheilded. Also, FWIW, RS422 and RS485 use essentially the same hardware (MAX485 and family) just physically wired differently. \$\endgroup\$ – slebetman Nov 3 '14 at 7:12
  • \$\begingroup\$ Quite right, I was forgetting TP. \$\endgroup\$ – Majenko Nov 3 '14 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.