5
\$\begingroup\$

I am new to Arduino and Raspberry Pi, and I have no eletronics knowledge outside of this. I have a good programming background.

I just learned how to solder (basic), got my LCD working, my rain sensor, external temperature sensor, barometric sensor and camera working. They are connected and logging data.

Now I want to put this thing outside. I'll need long wires for my rain sensor and temperature sensor. Can I dismantle a network cable (Furukawa Cat 6) and use the pairs inside?

I'll need two wires for the rain sensor and three for the temperature sensor. One network cable has more than enough pairs, so I'll just need to pass one cable.

I plan to dismantle both ends and solder.

Is this okay? What is the maximum distance?

The distance would be about 20 meters.

The protocols and interface - I don't know, but I'll look into the datasheets. The barometric pressure sensor is Bmp180, the temperature sensor is the DS18B20 and the rain sensor is the YL-83.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ How long is "long"? What protocols are we talking about? \$\endgroup\$ Commented Aug 22, 2015 at 21:16
  • 1
    \$\begingroup\$ You have to tell us which kind of interface you have to the sensors (analog, digital and even there are different protocols) each protocol / interface has it's own requirements. \$\endgroup\$
    – Arsenal
    Commented Aug 22, 2015 at 21:18
  • \$\begingroup\$ Whatevere you do, don't use a twisted pair for the I2C clock & data lines. If need be, twist clock with ground and data with power. \$\endgroup\$ Commented Aug 23, 2015 at 7:13

3 Answers 3

9
\$\begingroup\$

Ok, so you have:

  • BMP180 = I2C
  • DS18B20 = 1-Wire
  • YL-83 = Analogue Voltage

Over 20m, all of these are tricky (though not impossible)

  • I2C is designed for short interconnects (inter-intergrated circuit!) not long runs. It is especially problematic over twisted pair as the crosstalk between lines will completely kill it. There is a method called dI2C or differential I2C, using the PCA9615 chip, but that is only rated for about 3 metres.

  • Analogue will be terrible unless you buffer it (and probably even if you do) - voltage drop across the wire from any load imparted by the ADC, and more crucially noise caused by crosstalk with the digital lines amongst other things.

  • 1-wire has similar limitations of I2C. Though having re-familiarised myself with the specification, this may be the only one of the three which would could reliably interface over 20 metres as long as you are careful with crosstalk and noise. As per this Maxim application note, 1-wire should be possible (thanks @Passerby for point that out) over that length with some care.

My suggestion then would be to add an MCU at the end of the cable to interface with all of the sensors. Something like the ATTiny85 would be quite compact being only an 8-pin package, but you would have to look at how many I/O pins are required. You would need at least 4-pins for your inputs (1 is an ADC, 2 for the I2C interface, and 1 for the 1-wire bus). But then you would also need an interface through the cable. The ATTiny85 has only 6 I/O pins, so you would have 2 left to interface with the other end of the cable.

I would suggest something like RS-485 to do this as it is designed to be a differential I/O standard and should work fine with a CAT6 cable - you would have to make termination \$100\Omega\$ otherwise signal reflections would be quite problematic. In this setup you would have half-duplex communication. You would have two (maybe more) options for doing this:

  1. Implement RS-485 directly using the 2 free I/O pins of the MCU - this should be do-able from an electrical standpoint, and is not that difficult to implement in software. Plus it means you don't need an external driver.

  2. Use a driver chip such as the MAX481. You would tie the DE and !RE pins together and to one I/O pin (transmit/receive mode select), and tie the DI/RO pins together to the other free I/O pin which would be a bidirectional data-in/data-out line.

For both options you could for example sit in receive mode until instructed to transmit by a master at the other end of the cable. At which point you collect and send information about the sensor values. Once you send the response, you switch back into RX mode and await further instructions by the master.


In any case if you combine the sensors together you would only have one interface. Given that there is not high volumes of data here, reducing the transfer speed would help over this distance - you could for example use dI2C or 1-wire to interface the MCU over the cable as long as you run the bus slowly (10kHz maybe) to allow signals to propagate and settle.

\$\endgroup\$
7
  • \$\begingroup\$ One Wire is not as limited as i2c in range. \$\endgroup\$
    – Passerby
    Commented Aug 22, 2015 at 22:42
  • \$\begingroup\$ @Passerby It can probably go further, but I think 20m is still pushing it unless you go really slow - given that you only have the drive strength of a pull-up resistor. You would also have to connect to a twisted pair which I suppose would not be terrible if you connected both as the 1-wire line, but would not work if you had any other signal on the other half of the pair (signal coupling/capacitance would kill the signal). \$\endgroup\$ Commented Aug 22, 2015 at 22:44
  • 1
    \$\begingroup\$ 60m round trip on cat 5 utp. maximintegrated.com/en/app-notes/index.mvp/id/148 \$\endgroup\$
    – Passerby
    Commented Aug 22, 2015 at 22:49
  • 1
    \$\begingroup\$ @Passerby was just reading that through. This does seem to be the only protocol of the three sensors which would stand a chance on its own. It's been a while since I looked into 1-wire and hadn't realised it could go that far. \$\endgroup\$ Commented Aug 22, 2015 at 22:52
  • \$\begingroup\$ Especially with those temp sensors, the most common one wire device setup. They are very durable in long range. 6e STP increases it more. \$\endgroup\$
    – Passerby
    Commented Aug 22, 2015 at 22:58
4
\$\begingroup\$

Okay based on the sensors you are using you have the following interfaces:

BMP180 - I²C

DS18B20 - Onewire

YL-83 - erm just a digital it rains / it doesn't rain pin? - or an analogue voltage output (how much does it rain)

For Onewire there is an application note available which describes the operation over long distances, I'm not entirely sure if that principle can be applied to the said sensor, but I guess 20 meter should be doable, they are able to get 200 meter out of that. It might be that you have to adapt the software or change the pull-up resistor to cope with the longer cable.

The digital output of the rain sensor should pose no problem, it has a high drive strength and as it is a simple high / low push pull output. Can't really tell what the limit of the cable length would be.

If you want to use the analog output of the rain sensor, things get tricky. Based on the best schematic ever, the analogue output is not buffered. Actually it's just a simple resistor divider formed by the 10kOhm resistor and whatever resistance the raindrops produce. To get that signal even remotely usable over the 20 meter you need at least an op-amp voltage follower. I don't have experience with this, someone else will have to tell you what would work best.

My approach would be to get a small microcontroller in there which would handle the analog digital conversion, also reading the value from the temperature sensor and then send the data back over the 20m cable using a low baudrate UART (4800 baud works fine over longer distances as well).


This was before I realized you won't actually place the BMP180 outside (or will you?), so I'll just leave it here as a bonus information...

I²C over a 20 meter twisted pair cable, I know it is possible if you really do messy stuff and bend the protocol to extremes. Don't do it. It's not supposed to cover that distances.

The main problem you are facing with these cable lengths is the capacitance of the cable will change the signals. As I²C and Onewire are both using pull-up resistors and open-drain transistors the capacitance of the bus is limited. For example the specification of I²C by NXP limits it to a maximum of 550pF.

Now a normal cable will have something around 120pF/m capacitance (I haven't tested that on an ethernet cable) so if you are lucky you could get maybe 3 to 4 meters without "special treatment".

If you want to place your I²C sensor there, I'd suggest to use a small microcontroller to read the sensor via I²C and send the data over the long wire using something more usable, like a low baudrate UART or even something differential for added noise immunity.

\$\endgroup\$
2
  • \$\begingroup\$ The rain sensor has both digital and analog output though \$\endgroup\$
    – Passerby
    Commented Aug 22, 2015 at 22:37
  • \$\begingroup\$ Ugh I totally missed that on the splendid shop page I ended up. \$\endgroup\$
    – Arsenal
    Commented Aug 22, 2015 at 22:41
3
\$\begingroup\$

Since you haven't mentioned how you are going to use the sensor information, I am going to assume that you are able to interface with the arduino over ethernet. I'd suggest switching your thinking and place the ardunio in a weatherproof housing along with the sensors(or short signal cable runs to them). Add a poe etherenet shield to the ardunino and power/infereface to it over it over the 20m etherenet run. This means everything will be working within their specifications too and i suspect may be more within your skillset?

\$\endgroup\$
2
  • \$\begingroup\$ I think @ddutra's plan was to disassemble the network cable and use it as general purpose weatherproof cable as opposed to Ethernet. An Arduino + Ethernet Sheild (doesn't even need to be an Arduino), is indeed a possible solution but it seems overkill in terms of cost for 3 sensors. \$\endgroup\$ Commented Aug 22, 2015 at 23:11
  • \$\begingroup\$ Good point Tom. However I assumed he was already using the arduino. So I am simply suggesting moving it from inside to outside. But I agee with you and upvoted your answer. Ideally using a small micro at the sensor end is the most elegant solution. \$\endgroup\$
    – BenG
    Commented Aug 22, 2015 at 23:15

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.