arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.2k stars 4.81k forks source link

I2c sensors work on some devices with extension cable and not on others #16882

Closed Rush56 closed 2 years ago

Rush56 commented 2 years ago

Hi everyone.

I'm pretty new to all this.

I have set up some sensors on modified Sonoff basic R2 and Sonoff 4CH R3 PRO. I have Tasmota flashed on them.

Now i'm making a housing for my controller and connected those sensors via 4-pole aux connectors and extension aux cables. Total lenght from sensor to device is around 3.5 meters.

On one Sonoff basic R2 and 4CH R3 PRO it works, but on another basic R2 it does not. It does however work without extension.

So i used original 2x 3m extension AUX cables on devices that work and made another cable, as the resistence was pretty high over 3m AUX cable (1.1 Ohm). As i only used connectors and swapped for 0.25mm cable wires i have gotten resistance down to 0.3-0.4 OHm.

That did not help.

I have another two Sonoffs basics R2 on reserve. Havent been in use, only flashed and setup.

I tryed on those two and it doesn't work either. I reduced cable to 2,5 meters. Still nothing.

I reduced again to around 2 meters. Still nothing.

Each time before reducing the cable i also tryed the same cable on devices that did work with original extension cable lenght and it worked. Just to make sure i didn't mess up something when wiring.

Are some devices just too weak or is there any setting i could change? Quick google threw out to reduce clock speed/frequency on i2c. Is that possible on tasmota?

What else can i do, without using some kind of i2c extenders?

If it weren't working on all devices it would be more logical..

close-issue-app[bot] commented 2 years ago

This issue has been automatically closed because the PROBLEM REPORT TEMPLATE is missing or incomplete. Filling the template is required so standard questions don't need to be asked again each time. Our ability to provide assistance is greatly hampered if few minutes are not taken to complete the issue template with the requested information. The details requested potentially affect which options to pursue. The small amount of time you will spend completing the template will also help the volunteers, providing assistance to you, to reduce the time required to help you. Please, could you be so kind on completing the PROBLEM REPORT TEMPLATE in order to have more information so as to properly help you? Thank you for taking the time to report, hopefully it can be resolved soon. Docs for more information. Discussions for Questions, Feature Requests and Projects. Chat for more users experience.
Please check the Code of Conduct and the Contributing Guideline and Policy

joba-1 commented 2 years ago

what you experience is pretty normal.

To understand what’s going on: https://www.i2c-bus.org/

To see what’s going on: any osci will do, e.g. Quimat 2.4 Inches DSO Shell TFT Digital Oscilloscope Kit with BNC Clip Cable Soldered Probe Open Source SMD and Housing (Ready-Assembled) https://amzn.eu/d/icVXKyN I use one like this, works, but you can easily spend more money (for more value).

Try and error might work as well and getting down resistance was a good start. Next could be shield lines, modify termination resistors, …

barbudor commented 2 years ago

4k7 pull ups if not already there may help ESP internal pull ups are too weak

sfromis commented 2 years ago

3.5 or 2 meter is excessively long for I2C, not surprising with reliability issues. The bus is designed for a board bus within one device, something like up to 20-30 cm.

Rush56 commented 2 years ago

Thank you guys.

So before seeing your replays, i have already tryed putting up 4.7k resistor. Now it works up to around 2 meters.

Now i see two options: -shielded wires or -smaller resistor, maybe, 2.2k or something?

barbudor commented 2 years ago

Shielded cable may help if the problem is from electric parasites But it may be only line length Smaller pull up may help, as well as very small resistor in series but experiments with oscilloscope may be needed

Rush56 commented 2 years ago

Thanks guys.

Probably i'll be okay with these 2 meters for one device. Yesterday i was testing it, then i soldered aux connectors back to cable which increased lenght for 30-40cm.

That was enough for the signal to get lost again.

Then it came to my mind to power up i2c display i have for these sensors, as someone somewhere mentioned that with more devices you need smaller pull-up.

As soon as i connected display, the sensor started working again. I have them in parallel. Why is that?

sfromis commented 2 years ago

The display may have pullup resistors too, leading to a total stronger pullup (lower resistance). By badly exceeding I2C specs, you are walking around in a mine field of unreliability.

Rush56 commented 2 years ago

Well, I've been testing these sensors for 2 days now, 2 with 3 meter cables and one with a bit over 2 meter. They work normally, checking temp and humidity history in HA i can see they are working constantly, not loosing data/connection.

The thing is I did not know about lenght problem of i2c as i have already made a controller for mushroom tent and it all worked with shorter cables. Then i decided to make a box and make everything nice, so it was one of last parts of controller box building, everything else have i already set up.

Now i could go with 3 wire sensors, but none i have tryed can compete with this sensors i use now. They are so fast, accurate. These are SHT30 in housing. The housing keeps them working even in humidity I have in mushroom tent that ranges from 85-97%. Others condensed and froze at value. Then i had rain inside tent and mold.

Even other i2c sensors i tryed can't compete with this one. So i really dont wanna change that :)

sfromis commented 2 years ago

Simplest solution may be more ESP chips, and shorter I2C cables, not at all expensive. Your setup is basically why there are I2C extenders on the market, but you did not want such. You could also use good deal of time on fiddling with pullup resistors and voltages to see if you can hit a sweet spot with "tolerable reliability". Looking deeper with an oscilloscope may be helpful to understand how digital signals are badly malformed by analog effects, like when wires get long, and see how mitigation strategies change things.

Rush56 commented 2 years ago

Well i looked into i2c extenders. But didn't research enough.

Will look into it, this would be useful if these can be close to ESP or directly at i2c ports, so i could hide them in the box. Need to research it.

However i think that the current setup will work fine as it seems. The way i have it set now it works flowlessly.

Probably i dont need to extend that cable anymore on the device which now works with good 2m cable. Alternatively i can just get that cables through tent's plastic. However this is less desired for reasons like cleaning and stuff.

Thanks for all help!

Rush56 commented 2 years ago

€ 1,36 21%OFF | diymore CJMCU-9515 I2C Module PCA9515A 2 Channel 2Bit I2C Repeater SMBus 400KHz Dual Bidirectional Repeater Module for Arduino https://a.aliexpress.com/_mqN12qc

Is this of any use? Not sure what to look into exactly.

I guess it should do, here is the description: https://www.ti.com/product/PCA9515A#description

barbudor commented 2 years ago

Adafruit has this which seems to act as a booster You can look if AliExpress has equivalent https://www.adafruit.com/product/4756