I have a pi that controls and monitors stuff in the garden, in the house on different floors and such. Currently I have multicore cables running around but I am at the limit of my GPIO pins and I want to expand the system. So for instance I want 8 digital inputs (capable of 1kHz sampling) and 8 digital outputs at the end of the garden.

As I say currently the system is simple with little external digital electronics but I probably need to change this so that my data acquisition and control happens at the remote end of the cable and I just use the cable (ie, for instance, the cable to the end of the garden) for serial data rather than parallel control signals as it currently is.

So as an example, I have 8 water valves at the end of the garden controlled by the PI GPIO pins through relay boards which are at the PI end (at the house). And I have flow sensors which measure the water flow (and convert it to pulses) and report this back to the PI via optoisolators (the PI polls the relevant pins at 1kHz to check their state and calculates water flow from that).

So I want to make a remote IO port essentially (or several of them). I2C is difficult to electrically isolate and not good with long cable runs, SPI is also not in its comfort zone at long distances. I don't want to make a huge project of it electronically, and I have been mulling it over thinking one way is simple a shift register at the remote end (for the control requirements). So I would need to have a wire for each of: Clock (only pulsed when data is being sent to the shift register), output enable, data, and ground. When I want to change the state of any pin on the shift register I would have to pulse the clock wire a few times and use another GPIO pin to pulse the relevant data on to the data line. Easy to isolate electrically but it seems a bit messy (for instance, when I put the outputs into high impedance state when I write a new byte to the output chip, the pins would be pulled down to ground and I would get a glitch during the write which is not ideal).

Are there any other ways of doing this? Without resorting to programming my own PIC etc, I want to be able to convert this project from direct GPIO control to this new method quickly and without too much work. Seems there should be a chip more suited to the task, ideally one which has a few pins on it to set an address so that it watches for its own 'select' word on the data line and enables itself when it sees its identifier (reads the next data word and puts that on its outputs). Then I could bus several of these on the same wire. A UART seems the wrong choice to me because it seems to be designed for use by a microprocessor. But maybe I am missing something, hence asking here.

Also I need a solution for the return data (IE remote data acquisition - to report back to the PI the state of 8 pins at the end of the garden once again) - but it can be a different chip, I can have input and output using different wires. But I think maybe that once I know the best way to approach the control side of the problem the acquisition aspect might be a simple extension of that.

I only need to sample and control at a rate of 1kHz max.

  • Not sure if I understand what your looking for but if you need more inputs and outputs look up piface modules from Element14.
    – user31020
    Commented May 19, 2015 at 3:36
  • I would put a Pi next to every appliance and let them forward the data to a central Pi, either wireless or UTP. CONS: Indeed you'll spend extra for the Pi's and expansion boards PROS: you'll save on cabling, you'll even save more in the event of cable breakage, software design will be easier and your system will be easily expandable in the future. And if extra Pi's are too out of budget, a simple Arduino probably can do the same on the appliance side(s)
    – EDP
    Commented Aug 17, 2015 at 6:10

1 Answer 1


For longer distances I'd vote for a serial communication using RS 485 differential signals. As it is a bus it allows for the connection of multiple clients/slaves that are individually addressable. For wiring simple twisted pair cables could be used - phone lines or CAT-x network cables are a choice. A driver for this could be either attached to the UART of the Pi or to make it even simpler by using a USB-to-RS-485 adaptors.

I understand that you're not intending to go for a programmable solution (no microcontroller at the far end). Which I however would recommend to not dismiss from your list of options as it offers a highly flexible way at reasonable effort and quite cost effective (RS485 transceiver + small µC is probably less than $5). But I was hoping to come up with a solution without your own microcontroller.

Looking for "RS485 GPIO bridge" I find things as this one from NXP. But it is my understanding that this is not going to be of much use without some SPI/I2C connected logic there (aka microcontroller). So right now I cannot find a "RS485 GPIO expander" that comes integrated and ready-to-run.

But maybe we need to think simpler here. So lets combine the electrical characteristics of RS-485 with the desired shift register. Assume SPI for the register which leaves us with SCKL, MOSI, MISO and GND. Skip SS (slave select) if each slave is connected via its own wires. Three signals means three twisted pairs so CAT-x network cables will work out. However this approach requires three RS485 drivers/transceivers at each end of the line (or two if the write and read to the devices are separate). Making it less desirable given the cost and PCB footprint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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