Sending i2c over 7 meters

Thread Starter

gkeep

Joined Oct 21, 2017
33
Hi guys,

I have an issue where I'm trying to send i2c data over about 7 meters with 1 x master (esp32) and 3 x slaves (VL53LOX). I was wondering if it would be possible to simply make some 19V (its the voltage of a motor im using in the same project) logic level shifters for each node. I'm kinda new at electronics, teaching myself for the past 4 years. Any help would be appreciated.
 

Joël Huser

Joined Jun 30, 2019
42
gkeep, you'd better transmit your signal via RS485 for such a distance. With RS485, you can easily drive 3 slaves.

https://en.wikipedia.org/wiki/RS-485
"RS-485 supports inexpensive local networks and multidrop communications links, using the same differential signaling over twisted pair as RS-422. It is generally accepted that RS-485 can be used with data rates up to 10 Mbit/s or, at lower speeds, distances up to 1,200 m (4,000 ft). As a rule of thumb, the speed in bit/s multiplied by the length in metres should not exceed 108. Thus a 50-meter cable should not signal faster than 2 Mbit/s."

RS485 is everywhere.... for example, DMX signals are based on R485.
 
Last edited:

bertus

Joined Apr 5, 2008
20,449
Hello,

Read this page:
http://www.mosaic-industries.com/embedded-systems/sbc-single-board-computers/freescale-hcs12-9s12-c-language/instrument-control/i2c-bus-specifications

On the page this is given:
For reference, shielded 22 AWG twisted pair cables have capacitance in the range of 100-240 pF/m. So the maximum bus length of an I2C link is about 1 meter at 100 Kbaud, or 10 meters at 10 Kbaud. Unshielded cable typically has much less capacitance, but should only be used within an otherwise shielded enclosure.

Bertus
 

Thread Starter

gkeep

Joined Oct 21, 2017
33
Datasheet says VL53LOX takes 3.6V max. When you apply 19V to it, you will fry it.
glhf
The 19V was for the bus only. The issue of short communication lines is the wire's capacitance, by placing the transistors near the nodes it allows current to flow faster. I was just wondering if anyone had tried it.
 

shteii01

Joined Feb 19, 2010
4,644
The 19V was for the bus only.
From datasheet of VL53LOX:
i2c interface, voltage input, low level (digital zero) 0.6V maximum
i2c interface, voltage input, high level (digital 1) iovdd+0.5 the iovdd maximum is 3.5V therefore iovdd+0.5=3.5+0.5=4V maximum

If you use 19V for the bus, you will damage/destroy the sda and scl circuits (that are in the ic).
 

Thread Starter

gkeep

Joined Oct 21, 2017
33
Someone pointed me in this direction.

https://www.ebay.com.au/itm/RJ45-Differential-I2C-Long-Cable-Extender-PCA9600-with-Boost-Converter-Arduino/121765222831?hash=item1c59c5d9af:g:dTcAAOSwVL1V~oP8

It is basically what I was talking about. High voltage was for the bus ONLY. then dropping the voltage back down for the nodes. I do realise there is much more going on in this device than meets the eye. I probably will use RS485 becuase its much cheaper.

Thanks everyone especially Joël Huser, bertus and danadak. You were most helpful.
 

Thread Starter

gkeep

Joined Oct 21, 2017
33

Does anyone know if generating a differential signal on an impedance matched twisted pair like in the above video will work for i2c?
 

ebeowulf17

Joined Aug 12, 2014
3,274

Does anyone know if generating a differential signal on an impedance matched twisted pair like in the above video will work for i2c?
I could be wrong, but I think the key difference is bidirectional transformations, because the same wire is used for signals in both directions.

With SPI the MOSI and MISO signals each only travel in one direction, so building circuits to encode and decode them as differential signals is pretty straightforward.

With I2C, the SDA line is used for sending data in both directions, which means sometimes the master is driving the line, and at other times it's "listening" to the line (and vice versa for the slaves.) So, you'd need to build a circuit on the master side that "knows" when it should take data from the master and drive the differential lines with that data vs. when it should receive differential data and send it to the master... and do that same thing on the slave end as well.

If you've got a spare pin on the controllers on each end, and if you're writing your own I2C code yourself (not relying on existing libraries and such) then you could perhaps have your code trigger a "direction" pin output to tell your differential conversion circuit which mode to be in at any given time. Although, if you have that much control over both ends, it would be much easier to skip the I2C and go straight to RS485 or something similar.
 

Thread Starter

gkeep

Joined Oct 21, 2017
33
Thanks, thats just what i was thinking regarding single tx/rx line. I would dive in and use RS485, but ive heard there is some timing problem using them with ESP32s.

Not sure how to proceed. :(
 

ebeowulf17

Joined Aug 12, 2014
3,274
Thanks, thats just what i was thinking regarding single tx/rx line. I would dive in and use RS485, but ive heard there is some timing problem using them with ESP32s.

Not sure how to proceed. :(
Interesting - hadn't heard of ESP32 timing problems.

RS485 itself only specifies hardware protocols, not data types, timing, etc. I've only used it in conjunction with hardware UART serial com at speeds up to 115,200 bit/s, which I think is a pretty common usage for it.

Does the ESP32 have problems with basic serial communication in general? If so, that seems like a really glaring flaw. If not, I'm not sure why RS485 would be troublesome.

As a side note, I was sleepy when I posted last night, but I think all the hardware I described last night already exists in the form of RS485 transceiver ICs. They have direction pins (tx/rx select,) so the hardware side of balanced serial communication is pretty straightforward - it's just the software decisions you've got to work through.
 

Thread Starter

gkeep

Joined Oct 21, 2017
33
Sorry about my references being always in video format. But here is the problem with esp32 and rs485 modules. It's a general library problem maybe.


Anyway, I've though about the tx/rd problem.

How about for each of the sda scl lines having logical not gates and running pre and post 'not' signal over a twisted pair on a cat5e cable (for differential transmission). Then on the receiving node end having a differential opamp configuration with a 1K resistor on the opamps output, so the slave can still pull low against the opamps output high. Then having the same running back in the opposite direction to the master.
 

ebeowulf17

Joined Aug 12, 2014
3,274
Sorry about my references being always in video format. But here is the problem with esp32 and rs485 modules. It's a general library problem maybe.


Anyway, I've though about the tx/rd problem.

How about for each of the sda scl lines having logical not gates and running pre and post 'not' signal over a twisted pair on a cat5e cable (for differential transmission). Then on the receiving node end having a differential opamp configuration with a 1K resistor on the opamps output, so the slave can still pull low against the opamps output high. Then having the same running back in the opposite direction to the master.
Ok, I see the problem they're describing, and it's specific to MODBUS, not RS485. As I said earlier, RS485 doesn't describe the communication protocol, just the physical hardware specs. MODBUS defines communication protocols as well. So, you can modify Arduino MODBUS libraries as shown in the second video, or just make your own communication system using RS485 hardware and regular serial communication (Serial.write and Serial.read, nothing to do with MODBUS.)

Perhaps we should back up a step. Does the device on the other end need I2C? What is the device on the other end? Is it a microcontroller that you can program, or something that already has a fixed communication protocol you must follow?

As for your logic gate idea, it sounds intriguing and may well be a good idea, but I have to admit I didn't follow the concept based on your description. Maybe if I had a little time to sketch it out I would get it, but I just got to work, so I can't take the time right now.
 

Thread Starter

gkeep

Joined Oct 21, 2017
33
Hey,

Thanks for the quick replies. I see what you mean about the protocol and hardware being different. I'm not that good with encoding protocol libraries. The project involves 1 x master (esp32) and 3 x slaves (VL53LOX). Unfortunately the expressly use I2C. I was considering putting an Arduino nano on each of the LV53OX devices then use RS485, but I feel like, logic 'NOT' gates and opamps transmitting I2C would be more elegant, smaller and easier.

Sorry about the slow reply, I'm in Australia and sent the last message at my bed time.

I've drawn a rough diagram of what I was talking about. Let me know what you think. Sorry, I couldn't find NOT gates so I've tied the 2 inputs of some NAND gates to make them functional NOT gates.

extended I2C.jpg
 
Top