40 foot shipping containers, sensors, and cable length.

Hello,

I'm working on a project to set up a 40 foot shipping container as a grow room and am planning which sensors to purchase. We're monitoring co2, tmp, and hum. We'd like multiple sensors per can for redundancy and also an average reading down the length of the can.

In my research for planning how to do this I'm now at the point where I 'm learning about the different interfaces different sensors us. In this case I'm seeing a lot of UART, I2C, Digital PWM, and analogue. What seems to be the deciding factor which sensors I will settle on will be which interface would best be suited for a 40 foot container?

The arduino would be located at one end and the maximum distance would be from one end to the other. So, accounting for routing length, a maximum of a 50 foot wire.

From this website I'm getting information that I should be fine past 50 feet with I2C: UART vs SPI vs I2C | Difference between UART,SPI and I2C

But then this post seems to contradict that: Maximum I2C Bus Length? - Electrical Engineering Stack Exchange

Will I just need to accept that I will need to compensate for resistance down each of the wires depending on length no matter what?

Which would be the most suitable interface for sensors that distance away?

Thanks!

It’s not just the resistance of the wire. Also think about the inductance and parasitic capacitance as well as the susceptibility of single-ended communications to noise.

IMO you should consider putting smaller modules doing sensor processing near each sensor (or cluster of sensors) and use, say, RS422 or RS485 or even Bluetooth to communicate to a master controller.

Immediately thought cable capacitance with data transfer speed and this link pretty much confirms it.

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

This blog article clearly explains the problems with I2C over long distances: Taking The Leap Off Board: An Introduction To I2C Over Long Wires | Hackaday

You really should use RS422 or RS485 for 40 foot (or more) distances, which requires the use of the appropriate interface modules.

Thanks for all the info everyone!

Had to look up RS485: What is RS485 and How it's used in Industrial Control Systems? - YouTube

Interesting. Good to know and definitely an option..... I'd like to keep it to a single micro controller if possible just for simplicity and cost. But only if possible and it makes sense.

Also found this video: Long distance I2C over Cat5 Cable - 50 feet / 15m - YouTube

So it seems that I can just use cat5 cable at 50 feet as an I2C long distance helper.

Cat5 isn't expensive so to me at first glance this seems like a very practical solution to the problem.

What about analogue and digital? Do they have the same problem as I2C for long distance?

You might consider establishing an ESP8266 WiFi network within the container, perhaps even running on batteries, thereby eliminating all this stuff about cables in one stroke. Derpending on the flexibility you may need, you may get by with one ESP8266 handling a local group of sensors - no Arduinos need, except perhaps for a base station handling local recording or display.

That also seems like an interesting idea. Definitely a rabbit hole I'd like to go down for future projects but probably not this one.

In addition, upon very brief inspection, it seems that the esp8266 uses only tcp/ip protocol and not UDP. Currently my arduino software is sending data back to a Pi master (this arduino is intended to be one of many attached to multiple 40foot cans) using udp.

This is my first real medium to large scale project like this and I'm trying not to get too distracted by all the cool and neat things I could incorporate. Maybe in the future as a future feature.

one cat 5 cable , 50 ft long
5 Arduino's $3 each
5 RS485 boards @ $1 each

The beauty of using multiple boards is that you make 4 identical boards, sensors, etc
and one master to monitor them all.

The longest sensor wire is 5 feet, plus the drop.

An UNO will fit inside of a plastic, double gang, plastic, water proof electrical box. and you can put water proof glands on them to secure the wires if you feel the need.
use a clear face and put a display behind.

alternately, one in the center and your longest runs are 20 feet, plus the drop.

AustinMorris:
Thanks for all the info everyone!

Had to look up RS485: What is RS485 and How it's used in Industrial Control Systems? - YouTube

Interesting. Good to know and definitely an option..... I'd like to keep it to a single micro controller if possible just for simplicity and cost. But only if possible and it makes sense.

Also found this video: Long distance I2C over Cat5 Cable - 50 feet / 15m - YouTube

So it seems that I can just use cat5 cable at 50 feet as an I2C long distance helper.

Anecdotal. It worked for him on the bench but he didn't show (or even know) the clock rate, didn't scope the SDA or SCL signals, expose it to RFI etc. You might find it'll work for you too, I just believe it'll be on the edge of reliability.

What about analogue and digital? Do they have the same problem as I2C for long distance?

Technically, I2C is digital. Interestingly, Over long distances and higher speeds, analogue characteristics begin to really matter in digital communications.

Anallogue is even more susceptible. With digital you're really just looking at two levels: High or low. With analogue signals you're taking a voltage from, say, 0-5V and trying to accurately discern 1024 individual levels. Most analogue outputs (and certainly inputs) are relatively high impedance which means they're even more susceptible to noise. As well, if you use a single micro and all the sensors are referenced relative to the ground there, the sensors 40 feet away may be at quite a different ground level (wire resistance, inductance, noise, fields from AC power lines and transformers etc) so that can cause additional noise in your system.

Give it a try. You can always add mitigation measures later if you want.

Give a thought to the communication between containers. Nearby lightning strikes will cause big voltages container-to-container. When your equipment is blown off the wall, make sure it doesn't set fire to the product.

The only sure way of avoiding this is fiber optic cables between the buildings (containers.) But wired connections are acceptable if you understand the risk.

Hi,

This:

Shows the DHT22 Temp/humidity sensor can operate over 20M distance.

And the DS18B20 type "1-wire" temperature sensors can operate over 100M+

What type of lighting are you going to be using in the containers and are there other sources of electrical noise like heating elements, cooling fans, water pumps that may reduce the quality of an I2C signal unless it’s shielded. Humidity may also play a part in signal quality.
If your placing multiple (same) I2C sensors on the same bus then you will need to ensure they have enough addresses to not cause conflicts.

If you suspect hugh Electro Magnetic Interferences nearby and/or within the container (Fluorescent lights
, Large motorized machinery, High powered cables, ...) and because you will have long wires, a good solution is a CAN bus for 3 main reasons:

  • A CAN bus is insentitive to EMI (this is a differential bus)
  • A CAN bus can be as long as you want (up to 1 Km)
  • The CAN protocol handles automatically its message repetitions whenever a message is received with the wrong CRC.

This thread has become a wealth of rabbit holes to go down and learn new things. I will look into 1Wire more for sure and CAN bus too.

To answer the question about lights: we're using low level LED's (mushroom grow room)

All of the other equipment is located outside the backend of the container with the arduino. So there wouldn't be any ambient noise directly along the length of the I2C signal over cat5.

I'm gonna run an experiment about this myself here either today or tomorrow to see if it really gives a reliable signal over a 50foot length.

About the lightning. Why exactly is this a concern? Sure I could expect some weird data from the sensors at the moment a lightning strike hits but why would things start "blowing off the walls"?

why would things start "blowing off the walls"?

When you get millions of Volts driving thousands of Amperes for extremely short periods of time, some pretty interesting things can happen!

What would be the solution to something like this? Ground the warehouse building and every container?

There is an entire industry built around lightning protection, so you should have no trouble getting information from the web.

That last photo even looks a little like an Arduino.

Now you know why your cable TV connection always has a box like this on the outside of your house. There will be a ground stake associated with this box to ensure the fire starts in the box and minimal energy is sent indoors.

One interesting design I saw once on a weather station was each incoming wire went to a PCB trace constructed as a spark gap. Any over-voltage would jump the gap and basically stop there. The idea is to protect the perimeter: let big zaps jump to a ground outside the container.

There is also a cost-benefit analysis: if thunderstorms are rare in your area or the installation only has a planned lifetime of 2 years then you would not spend a lot of time or money on this protection.

Cool info guys!

I know it's been a few days but I wanted to give an update.

So I got a 50foot cat5e cable, two 6inch cat5e lengths, and 2 tool-less keystone jacks. After wiring the keystones to a breadboard and connecting the arduino and SHT20 sensor to each end as specified in the video I have previously linked (VCC=blue, scl=green, sda=orange, & gnd=brown + all stripped wires).

I got a successful signal down the length of the cable. I even moved the 50ft length next to a high volt motor and an inline hvac fan to get no resulting interference. I then tried to see if it would work without using the striped wires and it did.

So what's up here? Did the guy in the video I mimicked do something redundant by connecting the striped wires to GND or am I missing something in my understanding of the tech?

When I search for I2C maximum length I get different results, but all basically state that it's not intended to be long distance. Wikipedia tells me that cat5 can't go longer than 100m.

If I2C is a digital signal, and a cat5 cable is carrying the signal, why wouldn't this reliably run to the full 100m?

Thanks everyone!

If I2C is a digital signal, and a cat5 cable is carrying the signal, why wouldn't this reliably run to the full 100m?

Reply #1, and links in replies #2 and #3. Why bother to post, if you ignore the responses?