0
\$\begingroup\$

I have the following circuit. It is a simple Arduino project to read analog data from a potentiometer 10K. Click here for video link if you're curious.

enter image description here

The circuit shown above is tested and working as of now.

Now the thing is, I want to extend the wires between the 10K potentiometer and the Arduino and I am planning to use a USB extension cord to achieve it.

USB extension cords have 4 (four) wires in it as seen below.

enter image description here

I am planning to do it like this.

enter image description here

I will have a male and female USB connected one to the potentiometer and one to the Arduino. The length of the USB extension will be about 2 meters.

I will use 3 wires of the USB extension to connect the 10K potentiometer and the Arduino.

Now the question is, will the circuit work as expected when I plugged in the female and male USB? Will it work or not?

I am asking this before I cut my USB extension into two.

\$\endgroup\$
7
  • \$\begingroup\$ What is the value of the potentiometer? Do you care if the cable introduces error into your measurements? \$\endgroup\$ – Elliot Alderson Jun 27 '19 at 12:39
  • 1
    \$\begingroup\$ You may want to connect the braided shield of the cut USB extension cable to the GND only at the Arduino side. \$\endgroup\$ – Huisman Jun 27 '19 at 12:40
  • \$\begingroup\$ The value of potentiometer is 10K while the power supply would be coming from Arduino 5V. I have updated the question. \$\endgroup\$ – dcangulo Jun 27 '19 at 12:41
  • \$\begingroup\$ @Huisman Does it mean that I will only use the GND from the Male USB while not connecting ground to the potentiometer and not using GND from the Female USB? \$\endgroup\$ – dcangulo Jun 27 '19 at 12:43
  • \$\begingroup\$ Put a small cap, about 0.1 uF, between the analog input and ground at the Arduino. You should be fine. \$\endgroup\$ – Mattman944 Jun 27 '19 at 12:44
1
\$\begingroup\$

As long as you connect the wires properly (correct pins on the potentiometer to the correct wires of the USB cable at both ends, correct pins on the Arduino) it should work properly.

USB extension cables are usually short enough that you shouldn't have any loss of your signal.

If you find the values "noisy" (vary a lot more than they did when the potetiometer was connected directly to the Arduino) then there's a couple of things you could do:

  1. Attach the ground (bare, braided wire) of the USB cable to the ground of the Arduino. This will shield the conductors within from (transmitted) noise from other circuits.
  2. Attach a capacitor from the wiper connection of the potentiometer to ground. A better way to say that is that you need a capacitor from the Arduino analog input to ground. Something like 100 nanofarad. This will short circuit noisy "spikes" to ground. A larger capacitor will make it smoother, but also slower to respond to real changes in the potentiometer setting.

You may find that the above doesn't do much for noise that occurs when you wiggle the wires.

Breadboards are notorious for poor connections, and most of your wires are stranded rather than solid as they should be to make good contact on a breadboard.

You could solder short pins of stiff wire to your stranded wires to make the breadboard connections better.

Better still, if you have a soldering iron just solder the connections and leave the breadboard out of it.

Be careful not to plug your cut USB cable into anything that expects a standard USB connection. You are misusing a standardized connector - there's no guarantee that other devices will "play nice" if they are connected to something they don't expect.

If it were me, I'd probably us the cable the other way around.

I'd use the end you normally plug into the PC on the potentiometer, and the other one on the Arduino.

The way you are going about it, you could potentially plug the Arduino into a USB host and "power it backwards." That could lead to damage of the host or the Arduino.

The way I suggest avoids that possibility.

\$\endgroup\$
6
  • \$\begingroup\$ I guess I can just switch the cut of the USB extension. I will use the female on Arduino and male on the potentiometer. \$\endgroup\$ – dcangulo Jun 27 '19 at 12:57
  • \$\begingroup\$ "Be careful not to plug your cut [male] USB cable into anything.. " But the DATA+ is connected to analog in of the Arduino. Would that hurt? \$\endgroup\$ – Huisman Jun 27 '19 at 13:00
  • \$\begingroup\$ The other way around would be a bad idea: If you connect the potentiometer part of the USB cable to a computer or other USB device, I can destroy the computer's USB / USB device. The potmeter is 1 or 2 meter away: mistake can easily be made. \$\endgroup\$ – Huisman Jun 27 '19 at 13:04
  • \$\begingroup\$ @Huisman: The DATA+ being connected to the ADC probably won't bother anything. Consider what happens to the V+, though. If the V+ voltage isn't the same between the Arduino and whatever other USB host you connect it to, then you will have problems. Depending on how much different, you could potentially destroy the regulator in the host - or the Arduino. \$\endgroup\$ – JRE Jun 27 '19 at 13:05
  • \$\begingroup\$ @JRE True, that's a potentional danger too. Conclusion: mark the male USB connector with tape to avoid plugging it in the wrong device \$\endgroup\$ – Huisman Jun 27 '19 at 13:07
1
\$\begingroup\$

Assuming you don't want a very accurate measurement (if so, you wouldn't use a breadboard), your proposal will work.
You may want to connect the braided shield of the cut USB extension cable (male part) to the GND only at the Arduino side to reduce noise.

I wondered if plugging the male part of the extended cable into a computer or other USB device would hurt, but it will not: DATA+ is connected to A1 which is analog in.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.