Connecting with multiple distance sensors far away

Hello people.
I have the crazy idea to build a parcel dimensions measuring cell using an Arduino board and 3-5 distance sensors positioned in a metal frame about 3 meters across (half the distance of an ultrasonic distance finder).
I am thinking of using a set of ultrasonic distance finders from this set: Ultrasonic Range Finder - LV-MaxSonar-EZ4 - SEN-08504 - SparkFun Electronics
The frame is already there, now a few questions...
How should I connect to these sensors? The distance is not a few inches, so I suppose special cabling should be considered... I even thought of having an Arduino coupled with a sensor for each side of the box, but that might be over-kill.
I'm visualizing something like this:
The sensors allow RS232 connection. Maybe that can help me?

The sensors allow RS232 connection. Maybe that can help me?

That is the option I would go for but due to the lack of serial ports on a standard arduino you can either use an Arduino Mega or use the soft serial library.
Remember if your sensors have a true RS232 output you will need a Max232 chip on each serial port to translate the voltages to TTL levels.

Maaan... That was fast... You replied before I could finish my message :slight_smile:

I was thinking of using Soft Serial to communicate with the sensors via the RS232.
What's that about the Max232? Any reading about that?

And this is for a commercial application?

Airports and Postal distribution centers use the same method for measuring packages, with the addition of a weight sensor.

Might pay to check the USPO if you plan on selling them = )

Just google MAX232 and get the data sheet. Alternatively google "RS232 level translators", it's all standard stuff.

That was fast

You got lucky :wink:

Quoting is really hard here.

  1. This is a semi-commercial project, meaning I'll be using it at work, but it's not developed for sale.

  2. The reason I'm not putting a ranger on the bottom is because there is an electronic scale on the bottom of the cage.

  3. Mike: I think the sensor will not output RS232 levels, since it's powered by 2.5-5.5V and the RS232 says it's 0-Vcc. and 9600 bps.

Quoting is really hard here.

There's a button on the toolbar for it. (Although maybe I shouldn't mention that, having seen people go way overboard with it on other systems :wink: )

If you look at the datasheet, it says that the sensor is putting out 0-Vcc, but it's inverted so it looks like RS-232 with a limited voltage swing. You'll need an inverter to feed it into a UART.

Given that you're probably going to want to take lots of readings over time from the sensors*, and that you're not doing this for mass production, I'd strongly recommend going with the Mega: the time savings of not screwing around with bit-banging the serial interfaces will almost certainly pay for the extra cost of the board. If you were planning to make hundreds or thousands of them, the extra coding time to reduce hardware cost would be worth it. But not for one, or a few.


  • You need to watch the sensors for a while to figure out when the person setting down the box has moved away, and average at least a few readings after they've stabilized because there's probably a margin of error on the sensor.

There's a button on the toolbar for it

It doesn't actually quote, just adds tags. I have to manually copy-paste the content.

Now... I don't WANT to make LOTS of readings, because my use-case is pro-active, meaning that reading the measurements will be invoked by the user (by scanning a barcode to the connected computer). So i'll be sufficiently happy if I can do a reading (all sensors) per second. But your note about the averaging is probably very up-to-the-point.

It's not for mass-production, probably up to a dozen.
How is the MEGA going to help me do that? Is Soft Serial bit-banging?

However for the first step I am worried as to whether I can put the sensors on a 9 meter cable and still get signal... There will be some WiFi APs in proximity, a computer, probably some other electronics...

You know... you probably don't need to talk to them all at once. Maybe you could stick with the single RS232 port on the arduino and then create an RS232 switch that selects each device one at a time under arduino control.

If you stick with RS232 level converters... I've had 4800 Baud work going through 1 mile of copper cable.

According to the description…

but the PWM and Analog interfaces will allow any micro to listen easily enough
Analog Output - 10mV/inch
PWM Output - 147uS/inch

Wouldn’t it be easier to use something other than RS232? Like pulseIn?

  • Brian

You know... you probably don't need to talk to them all at once.

Oh... That's for sure... Otherwise sensors might interfere with each other since they're in close proximity... However an RS232 switch might be beyond my miserable qualifications.

If you stick with RS232 level converters

Well... I'll have to do that both at the Arduino side, and all the sensors (since they don't have RS232 levels).

Wouldn't it be easier to use something other than RS232? Like pulseIn?

You know... You might be right... I drifted towards RS232 based on prejudice. Maybe pulsing will be more stable since pulse length should be easier to maintain than voltage over long links, right? Thanks for the pointer.

voltage over long links

By "long links" do you mean about 3 meters? Do you plan to have one Arduino control all the measuring-boxes or one Arduino per measuring-box?

  • Brian

After reading a bit more about your plans, I have some suggestions for you.

  1. You're not going to get dependable clean power down that 9m cable. Plan on feeding 9-12V into it at the Arduino end, and using a local 5V regulator.

  2. RS-422 transceiver chips are relatively cheap, and will greatly improve reliability. My recommendation is to use Cat5 cable, and assign one pair each to power and the digital signals going to and from the sensor. If you cross the wires on the serial data transmitter, you get the inversion you'll need to feed the UART for free.

  3. Check the timer resolution of whatever micro they've put on the sensor board. If the Arduino's is better, send the PWM signal down the cable, instead of the serial data.

  4. Use a multiplexer to select the sensor input (whether it's serial or PWM). It's easy, and there are examples in the Playground area of the website. You can use something like the 74HC138 to select the sensor (the HC138 has an active-low output, but you can cross the wires on that RS-422 transmitter to get the inversion to active high for free, too).

You can probably find RS-422 chips with more than one driver and receiver per package to reduce wiring. I can't recommend any, offhand, because all the systems I've done have only had one RS-422 or RS-485 interface, so I've never researched multi-driver chips.


Thanks all...

By "long links" do you mean about 3 meters

More... The cell itself is 3 or 4 meters wide, high and long. The sensors have an active range of 512 inches. I don't want any wires going through the box. There is probably a better way to wire that, but I thought of having the Arduino on the lower-right-forward of the cell, with wires going to the sensors around the box edges.

Do you plan to have one Arduino control all the measuring-boxes or one Arduino per measuring-box?

Thought of both ways. I would like to have one Arduino for all the sensors.


  1. That does make sense. I was planning on using RJ-45 or RJ-11 with a CAT5e cable for connection. That reminded me of PoE, but I am not sure whether I can rectify an unknown power (12-30 V) effectively, I actively dislike low-efficiency stuff, and the linear regulators definitely fall in that category.

  2. Haven't been formerly introduced to RS422. I will have to read more on that.

  3. I couldn't find the Arduino's pulse resolution. The docs say it's microseconds with minimum of 10us. The device puts 147us for every inch read, that seems well within measuring. However a 512 inch distance (max available) will require 75ms+ pulse, which means I can do no more than 15 measurements per second. Still enough.

  4. I will consider it, but I'll need 3 wires for the multiplexer, one for RX, one for TX, total of 5 pins instead of 10, which is considerable, but not a target.

The project however seems to be coming to a stall, since I am slowly becoming aware as to how much I don't understand this stuff at all :-/.
Also the cell design has a serious draw-back: if I have a sensor on every wall where will I be able to put stuff through?

It seems I'll have to drop that and recommend a belt conveyor with integrated weight and dimensions measuring.

Just to throw a suggestion.
Do those boards qualify: