8 evnironment sensors SHT31 via I2C Multiplexer, cablelength

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ice77
Normal user
Posts: 18
Joined: 05 Apr 2020, 05:47

8 evnironment sensors SHT31 via I2C Multiplexer, cablelength

#1 Post by ice77 » 18 Jan 2021, 06:05

I thought about to wire up 8 SHT31 sensors (SHT35 cost 3 times as much as the 31 and are a little bit more accurate) on a I2C multiplexer Tca9548a on a D1 mini Pro.

I think that could run safely. Now my question. Could 1 wire it up with an cat7 cable from the Multiplexer to each single SHT31... with 5-8m cablelength.
So it could be possible to attach up to 8 rooms to one ESP8266.

What do you think... could it run or is the cable TO LONG from the ESP/MULTIPLEXER to each SHT31?
Would it be better using an ESP32 instead of the ESP8266?

If someone has already tried such an scenario... let us know :-).

Wiring it up as described I don't need an ESP in each room, but only one each 1-8 rooms.
Then I would also attach 10-15 DS18b20 sensors on the heating return lines.
All that stuff on an ESP8266? we will see if it will be possible. The limitation to 12 devices in ESPeasy will be a "problem" to be solved. eventually in a custom compiled version...

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: 8 evnironment sensors SHT31 via I2C Multiplexer, cablelength

#2 Post by Ath » 18 Jan 2021, 08:01

ice77 wrote: 18 Jan 2021, 06:05 Now my question. Could 1 wire it up with an cat7 cable from the Multiplexer to each single SHT31... with 5-8m cablelength.
With careful layout of the wiring, not close to mains lines, cut off excessive length, etc., that could work. Just be sure to use the proper pull-up resistors (required by Tca9548a) on all lines. (Some sensors come with pull-ups already installed, don't know if the SHT31 has 'm)
ice77 wrote: 18 Jan 2021, 06:05 Would it be better using an ESP32 instead of the ESP8266?
Not necessarily, but the performance of an ESP32 is much better, and I'd expect you to have quite some rules to be processed, so extra performance that would be 'nice to have'. And also the 32 devices 'limit' could be helpful...
ice77 wrote: 18 Jan 2021, 06:05 Then I would also attach 10-15 DS18b20 sensors on the heating return lines.
All that stuff on an ESP8266? we will see if it will be possible. The limitation to 12 devices in ESPeasy will be a "problem" to be solved. eventually in a custom compiled version...
The DS18b20 plugin currently supports up to 4 sensors handled per task, you just won't be able to 'automatically' send the values to Domoticz, if you're using that, as they don't support multiple temperatures in 1 device AFAIK. But an ESP8266 in default configuration (12 tasks) can handle your combination of 8 SHT31's and then up to 4x4 DS18b20's (good quality devices can all be on 1 GPIO, but it could cause trouble > 3 on 1 wire, so separate GPIO's may be required, especially with long wiring) if desired (but then it's completely filled 8-))
If multiple GPIO's are needed, an ESP32 would be a good choice.

Looking at the long wiring for all those devices, you could try to plan in using 2 ESP's, located as 'close' to a group of sensors as possible.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: 8 evnironment sensors SHT31 via I2C Multiplexer, cablelength

#3 Post by TD-er » 18 Jan 2021, 14:04

The limit for Domoticz as mentioned by Ton is just when you send it directly from the task to a controller.
If you need to use upto 4 Dallas sensors per task to make ends meet, you can still send them one by one to Domoticz via rules. (preferrably via the Domoticz MQTT as those are placed in a queue)

About the wire length...
If you use a multiplexer, you can consider each channel as a separate I2C bus.
This means you can tune the pull-up resistors (which are needed per channel !!) to match the cable length and I2C clock frequency.

Twisted pair is mainly meant to be used on balanced signals, but it will also help out a bit on reducing noise on signals relative to a ground.
So you should use GND & SDA on a pair and GND & SCL on a pair.
In practice the pairs of an UTP cable are not of equal length, so wiring it like this will introduce a difference in timing for clock and data, but given the relative low frequency I don't expect this to be an issue for I2C.
What will become an issue however is the capacitance of the cable, which will limit the max. frequency you can use.
This can be reduced a bit by using stronger pull-up resistors (e.g. 2k7), but I think you still need to lower the I2C clock frequency.
In theory you can lower the clock frequency almost to DC, but that will take way too long to process. I suggest to start at 100 kHz and lower the clock speed if needed.
And start testing with a multiplexer, as this allows to use a bit stronger currents compared to the ESP pins.
So just test it with a 30m long UTP cable to see if it still works and remember to use pull-up resistors per multiplexer channel.

ice77
Normal user
Posts: 18
Joined: 05 Apr 2020, 05:47

Re: 8 evnironment sensors SHT31 via I2C Multiplexer, cablelength

#4 Post by ice77 » 19 Jan 2021, 06:08

hello guys,

thank you VERY MUCH for you posts! That helps me really a lot.
I am using iobroker, which gets all the sensor data via MQTT from the ESP8266 nodes. That runs perfectly. I save the data in an influxDB and the graphs are made from grafana. Thats perfect for me.

Here you can see an graph from various rooms, where I have placed an ESP8266 with only one environment sensor... just to do the first steps with various sensors.
grafanaTemp.png
grafanaTemp.png (61.32 KiB) Viewed 10696 times
Later on I want to reduce the number of ESP devices to an absolute minimum. For this reason, I have an additional option in every room to place an ESP in the wall or to connect the sensor via the Cat7 cable in the underfloor heating distributor on a central ESP8266.

I have D1 mini pro (ESP8266) and 2 ESP32 to get the things done. But I want to try to get it done with the old ones (ESP8266), because the ESP32 I till now I did never flash... so I'm not familiar with, and I think that the old ones do need less energy than the esp32 (but this I think but do not really know).

The next step will be to get 2-3 multiplexer boards from china and a few SHT31 sensors to do a tests and let you know how far I can go with the hardware I have.

to reduce the load it would be ok, if each sensor sends his data every 2-3 minutes. That's enough.
The long wiring will be only for the Temp/humidity sensors. The DS18b20 have max 50cm wire. In the next days I can take a few photos so you have an idea how I planned it and at which points the wires come out of the wall :-)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: 8 evnironment sensors SHT31 via I2C Multiplexer, cablelength

#5 Post by TD-er » 19 Jan 2021, 15:11

I don't think the load of an ESP8266 is something to worry about.
Sending data to MQTT is optimized very well.
I was able to send upto 10 messages per second to a MQTT broker running on a Pi.

Collecting data from the Dallas sensors is also not that hard.
When using 4 Dallas sensors in a single task, those sensors will be read at the same time.
- Start reading for all 4 sensors
- Schedule a read to read all 4 sensors

In between, another task collecting data from 4 Dallas sensors can be executed.
So roughly 12 - 16 sensors can be read at 1 reading per second (at 12 bit) before you're running into timing issues.

Reading data from a BME280 is also non-blocking, so you can have multiple instances perform a reading at the same moment.
However reading the BME280 continuously may heat up the sensor causing inaccurate readings.

ice77
Normal user
Posts: 18
Joined: 05 Apr 2020, 05:47

Re: 8 evnironment sensors SHT31 via I2C Multiplexer, cablelength

#6 Post by ice77 » 20 Jan 2021, 18:15

Here we go with the pictures
IMG-20210120-WA0040.jpg
IMG-20210120-WA0040.jpg (238.78 KiB) Viewed 10623 times
IMG-20210120-WA0041.jpg
IMG-20210120-WA0041.jpg (95.6 KiB) Viewed 10623 times
IMG-20210120-WA0045.jpg
IMG-20210120-WA0045.jpg (178.62 KiB) Viewed 10623 times
IMG-20210120-WA0046.jpg
IMG-20210120-WA0046.jpg (203.32 KiB) Viewed 10623 times
IMG-20210120-WA0043.jpg
IMG-20210120-WA0043.jpg (207.4 KiB) Viewed 10623 times
in every room I have the light switch at 1,2m and at 1,5m I have cat7 cable, 230V and KNX cable for maximum flexibility.

Now I could install in every room at 1,5m one ESP with an environmental Sensor or I can connect this sensor directly at the Cat 7 cable which goes to the underfloor heating distributer Box. The cable length of each cat7 cable is roundabout 3 to maximum 8 meters.

The ds10b20 will be attached only to the return lines of the heating Box with extreme short cable lengths with Max 1m.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: 8 evnironment sensors SHT31 via I2C Multiplexer, cablelength

#7 Post by TD-er » 20 Jan 2021, 19:53

Just to be sure...
You don't have low voltage cables along with the mains power lines in the same PVC tube, right?
The Dutch NEN1010 regulations do not allow to have low voltage and mains lines in the same tube.
I can imagine other countries have similar regulations and I also would like to keep our users alive and kicking :)

Don't forget the needed resistor for the Dallas sensors.
A single one is enough and with a longer cable you may want to place the resistor at the far end of the cable (not close to the ESP) to make it a bit more resistant to noise.

ice77
Normal user
Posts: 18
Joined: 05 Apr 2020, 05:47

Re: 8 evnironment sensors SHT31 via I2C Multiplexer, cablelength

#8 Post by ice77 » 20 Jan 2021, 20:49

You are absolutely right.

The 230V goes from 1,20m (light switch) to 1,5m without being connected. It will be connected in future if there is needed 230V.

In my case i use 230V OR the Ethernet cable that also isn't attached. The KNX cable the same. Only piece of wire going into the light switch that also has KNX. If needed it will be wired if not it's only nice to have.

:-)

This is my method to be absolutely flexible in the next twenty or thirty years. After this period of time i don't think that i need that stuff anymore. Getting old your interests will be completely different :-)).

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 25 guests