Hey folks, Im using a SHT40 humidity and temperature sensor for my project, to monitor the RH and T values at different points in a room. What is the maximum cable length i can have to get accurate sensor readings? i have tested it out with a 2-meter cable and it seems to be working fine however, my requirement is a minimum 5m. Also, are there any modules which can amplify the signal which can negate the length problem?
This sensor uses i2c bus, which was designed to connect chips on the same circuit board, so even 2m is a good result.
There are booster modules available to increase the range, check the Adafruit website.
You may need to remove the existing (4K7) pullup resistors from sensor boards if present.
Im using an ESP32 Wroom 32d board.
What is the maximum?
12 meters
heres the thing, i have 8 sht40 sensors whose sda and scl lines are connected to TCA9548A multiplexer. where should i connect the LTC4311? before the expander or one at beginning of each sht sensor?
I2C bus lenght specs:
Bus Data rate Length Length limiting factor Nodes Node number
(bits / sec) (meters) Typ.number limiting factor
I2C 400k 2 wiring capacitance 20 400pF max
I2C with buffer 400k 100 propagation delays any no limit
I2C high speed 3.4M 0.5 wiring capacitance 5 100pF max
Ref: AN10216-01 I2C Manual
The LTC4311 is useful where you have the long wires.
If you can manage to put the TCA9548A switch somewhere halfway, have it working on 5V VCC and use shielded and twisted (STP) cable you may not need the LTC4311.
Though I am not familiar with ESP32 and it's signal voltage tolerances.
Apparently nobody knows.
Before you spend a lot on money on things that may not work, why don’t you lower the clock rate.
Connect 4.7K pullup resistors between 3.3V and SCL and SDA at the ESP
Use setClock(10000)
Connect 12m of cable and see if it works.
If you are going long distances I will reccomend using 2 mcus on each end with CANBUS capabilities, this will highly increase the reliability of the system since CANBUS is already designed for long distance high interference environments.
But if you aren't mid-experienced with electronics I wouldn't reccomend doing what I suggested, instead stick to lower bitrates and try 12m cable like @jim-p said
Have you considered placing the I2C modules with the Arduino and running the wires to just the sensors.
Ordinary UART serial is much easier and more reliable for data transfer than I2C, and wire length is not a big problem (tens to hundreds of meters without special considerations). Consider using a tiny MCU board at sensor locations that handles the I2C, and transmits data back via UART serial. E.g. Adafruit ItsyBitsy 32u4 - 5V 16MHz : ID 3677 : Adafruit Industries, Unique & fun DIY electronics and kits or the even smaller Xiao modules from Seeed Studio.
@hmeijdam Its a storage room. All the electronics are placed at a designated place with only the cables connected to respective sensors extending out. I'm afraid it's not possible to place the multiplexer somewhere halfway. However, i had a 5m STP cable lying around and the sensors seem to be communicating with the board without any issues. Will try to use a longer STP cable and see what would be the maximum length i can give. @jim-p I'll try doing what you suggested...i have a few 4.7k resistors with me. Should i place them between the esp and the multiplexer?
@jremington, @asdfdsgtegb Sorry, but I'm not very familiar with electronics and IOT. I'm a mechanical engineer and this project is for monitoring the performance of a storage dehumidifier which we have built. I'm looking for a quick and easy solutions and would prefer to spend less time and resources for this. Thanks for the suggestions either way.
There is no quick and easy solution for long I2C connections. Forget that approach. It is a bad idea that usually does not work, because I2C was designed for chips to communicate on a single PCB.
is there really no other way? I have 9 sensors in total i can't place one mcu at each. it'll cost way too much. and besides even if i do how do i connect all 9 of them to the esp ?
There are complicated solutions, just no easy ones. Face it: you have set yourself up with a complicated problem, made some poor initial choices, and it will require some technical expertise and design work to solve.
Consider hiring someone to help. Also consider revising your sensor choices.
i can't place one mcu at each
Of course you can. An ATtiny costs around $1.
as @jremington states you have a complicated problem connecting 9 sensors to a ESP32 over some distance
consider connecting each sensor to a low cost microcontroller (e.g. Nano or Pro Mini) and connect the microcontrollers to the ESP32 using RS485
See post #10