2

I have been researching related questions to this one for a while but decided I needed to ask this myself, as no one seems to be having quite the same issue and I am not knowledgeable enough yet to extrapolate an answer based on related discussions on this (and other) forums.

I am trying to use my RPi 3B to receive data from a I2C device (BME280 mudule) and a UART device (MH-Z19B). Due to logistical constraints, these two devices must be located in the same spot, approximately 25 ft away from the Pi. I have purchased a 50-foot (15.2 m) cat6 ethernet cable and a pair of surface mount boxes (see links below) for the purpose of connecting the two devices to the Pi.

What I've read so far seems to indicate that both I2C and UART struggle to send data reliably over a distance of more than a few inches, and that if I want to send them over this 50-foot cable, I will need a P82B715 bus extender for I2C and a RS232 (or RS485) for UART.

SO my question is, what is the best way for me to wire both of these devices, as well as the necessary drivers/extenders, through my cat6 cable? I am aware that one must be careful which signals are assigned to twisted pairs, so as to avoid crosstalk.

Equipment I've purchased:

-BME280 module: https://www.amazon.com/gp/product/B0118XCKTG/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

-MH-Z19B module: https://www.amazon.com/gp/product/B083YXFSDM/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

-Cat6 ethernet cable: https://www.amazon.com/gp/product/B0134QJH4G/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

-Surface mount boxes (x2): https://www.amazon.com/gp/product/B005E2Y9WY/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

5
  • #FishInTheDesert, Welcome and nice to meet you. Ah let me see. Your question is interesting and well presented. Some two years ago, I played with Rpi3B+ and more than a couple of UART/serial and I2C sensors and actuators. For UART/serial at 9k68n1, 5V TTL, using dsub 9 pin, double sealed cables, usually you can do up to 30 meters without any problem. (2) For I2C, at 100kHz, usually you can easily talk reliably up to 2 meters. I did use P82B715 and CAT5 to do "a little bit" longer, if not overloading the I2C bus with too many devices, exceeding 400pF impedance limit. (3) / to continue, ....
    – tlfong01
    Feb 2, 2021 at 3:50
  • You can search rpi.org.forum for more details: (4) Search query "I2C, tlfong01" found 180 matches: raspberrypi.org/forums/search.php?keywords=I2C+tlfong01 (5) Search query "P82B715, tlfong01" found 18 matches: raspberrypi.org/forums/search.php?keywords=P82B715+tlfong01
    – tlfong01
    Feb 2, 2021 at 3:57
  • You can also search RpiSE forum my other answers for I2C sensors. For example, (6) Rpi3 BMP180 Barometer Sensor Interface Problem - SO, Asked 11 months ago Active 8 months ago Viewed 757 times stackoverflow.com/questions/60274562/… (7) How can Rpi interface BME180/BMP280 pressure and humidity sensor? - Rpi SE, Asked 7 months ago Active 7 months ago Viewed 533 times raspberrypi.stackexchange.com/questions/113646/…. Have a nice project. Cheers.
    – tlfong01
    Feb 2, 2021 at 4:06
  • Ah, sorry, I should have said 9k6bd8n1, meaning 9,600 baud, 8 bits, no parity, 1 stop bit. This is the most popular default serial standard.
    – tlfong01
    Feb 4, 2021 at 1:57
  • #FishInTheDesert, You are welcome. Have a great project. Cheers.
    – tlfong01
    Feb 5, 2021 at 0:49

2 Answers 2

2

I²C is designed to operate over short distances, typically on the same board.

Attempting to use over long distances is unlikely to succeed.

The application to UART is rather less clear.

The RS232 specification uses ±15V bipolar and is supposed to work over 1000', although this was very conservative. No modern systems actually implement this; ±12V was common in the 1980s, but most modern systems (if you can find one that implements serial) use 0/5V unipolar.

These work over reasonable distances, as does the 0/3.3V unipolar on the Pi (which also differs in polarity from RS232).

The problem with serial is that it requires a common Gnd (this is more critical with unipolar) and is dependent on layout. You could get away with 50-foot (subject to layout) but I would use buffers to drive the signals.

I used to use 20mA current loop (which has its ancestry in telex) and can operate over thousands of km (with 50V drive) and is easily implemented with opto-isolators to avoid Gnd problems.

Probably the easiest and most reliable would be to use Ethernet, which is inherently galvanically isolated and uses balanced common mode signalling.

1
  • 1
    Thanks for your answer! This may be a simple/vague question, but what do you mean by "use Ethernet"? I plan to use an Ethernet cable to connect my sensors to my RPi, but are you referring to some specific protocol or some specific way of wiring the cable? Feb 3, 2021 at 15:27
2

I used I2C sensors on appx. 3M cable (with ESP8266) in my weather station for few months without any problem, that was normal sensor data cable, no twisted wires etc. With Cat 6 successs should be higher. It is reliable and based on your cable lenght connection speed will be affected, not signal. If possible, try using smaller pullup resistors on SDA and SCL lines, (like 1k) and desolder any voltage regulator if there is any presented on sensor, since there will be voltage drop in the cable itself OR you can use higher voltage input so sensor will recieve enough voltage at the end. If you have cable available, just try and see for yourself.

Your Answer

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

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