I'm trying to optimize the communication (minimize wires) on a project where I can control a motor and toggle some 230V devices by using RS485 and I2C.

On this project, I'm using an Arduino (Mega) for the control panel (buttons, potmeters, LED segment display (I2C) etc.).

I'm using the RS485 protocol (Modbus RTU) to control an inverter by using a MAX485 TTL converter. Now I also have a relay board (8 channel) to be able to toggle some lightning and sound devices. Both the inverter and the relay board, as well as the power supply, are located in another box, which I call the power box. Between the control panel and the power box will be a cable.

[Control Panel (with arduino mega)] <--cable--> [power box (with inverter, 8 channel relay board and 230V devices)]

I've got the following requirements:

  • The cable should have a minimum amount of wires (5V, Ground, 485+(A) and 485-(B) for sure)
  • The total length of the cable varies from 1 to 3 meters.
  • The signal should be reliable.

Now the relay board uses 8 channels. I've bought an I2C expander (PCF8574) to minimize that to 2 wires (SDA, SCL).

I'm thinking of using the existing 485 lines to control the inverter AND the relay board. So no additional wires are required. But theoretically I can't get it to work. So before I try to invent it.

  1. Can I do I2C communication over the RS485 as well somehow by putting another converter?

  2. If you recommand to just go with 6 wires (power, RS485 and I2C), how reliable is my I2C line going to be on 3 meters? What pull-up values do you recommand? (24AWG wire in mind, but also using a close-by LED segment display, so 2 I2C devices on different distances). I've read posts saying:

The rule of thumb is maximum 50 cm for a normal 100 kHz to 400 kHz I2C bus.

Or can I use some other protocol/trick? Either minimalize wires, or boost signal by a I2C buffer? (recommendations?)

  • I2C needs two signals referenced to ground and RS485 needs a twisted pair. This is very different. By the time you convert the signal you might have found it would have been easier to just throw away your I2C peripherals and buy new RS485 peripherals. I2C, SPI and other similar protocols were meant to reduce the pins on peripheral chips normally located on the same PCB. They are not meant to go long distances. You may find you need to drop the speed on the I2C bus. And to debug problems you likely will have to use an oscilloscope. – st2000 May 29 '18 at 4:24
  • 3
    add a small arduino as a RS485 to I2C converter or connect the relays to it – Juraj May 29 '18 at 5:15
  • An oscilloscope is too expensive for me. How badly is it to not use a twisted pair for rs485 on a length of 3 meters? – Matthijs van Hest May 29 '18 at 9:49
  • And what if i did use twisted pair, can the 5v and gnd line be used on a twisted pair? Or will that create a voltage drop? – Matthijs van Hest May 29 '18 at 9:55
  • Twisted pair is designed to work over longer distances. Because it is a twisted pair, any noise picked up by one wire is canceled out at the far end by the complimentary noise picked up by the other wire. That is why it is used. The reason it is not always used: Because twisted pair requires extra hardware to transmit it and extra hardware to receive it. Adding to the cost of the product. You can not simply connect a 5v digital signal and ground to a twisted pair. To take advantage of the noise immunity you need to drive the twisted pair with equal but opposite voltages. Like USB or Ethernet. – st2000 May 29 '18 at 12:12

I2C and RS485 are such vastly different protocols with such vastly different signalling needs that they cannot share the same cables.

Further, I2C is not designed for connecting with long cables - it's meant for use between chips on a PCB.

The simplest "Arduino" solution would be to create a new RS485 device on your RS485 bus using another MAX485 and a small Arduino (micro, nano, etc) that responds to MODBUS RTU instructions and controls the relay board for you.

  • I was afraid so. But when i think about 'simple maintainence' i actually want to avoid another micro controller with software. The best solution would be just a swap of standard components. Anything you can think of? – Matthijs van Hest May 29 '18 at 9:53
  • I know of nothing. Ask Google for a MODBUS RTU compatible relay controller. Be prepared to pay lots. – Majenko May 29 '18 at 9:55
  • Mhm, true. Industrial.. Always expensive. What about keep using i2c with a buffer/booster? I also read some posts saying they can have up to 20 meters with a slow rate and the correct resistors and such? – Matthijs van Hest May 29 '18 at 10:01
  • You're starting to enter the hacky and unreliable (and probably not working at all) area. If you're going to hack something together at least do it within the framework of your existing protocol. Just use an Arduino at the remote end like I suggested. That's by far the best low-cost option. Anything hacked together to try and force two protocols down one set of wires will be far worse in the long run, if it's even possible. – Majenko May 29 '18 at 10:02
  • I meant when using 6 wires (own pair for i2c) but doing it on a longer distance. But yes, probably right, better use another microcontroller on the 485 bus then. I can lose the i2c completely. – Matthijs van Hest May 29 '18 at 10:09

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.