1
\$\begingroup\$

I have some projects with Arduino and a separate battery power source and I'm tired of plugging and un-plugging my usb cable when to program the arduino using my laptop USB. Sometimes it even broke the tiny micro USB connector in the Arduino.

So I want to put a on-off switch on the USB cable. When I'm about to program the arduino I disconnect the battery and turn on the cable, and when I want to test the programmed Arduino and circuit, I turn off the cable, and just connect the battery. The USB cable would always be connected in both Arduino and laptop.

So I want to do this. Put a LED in parallel with the 5V and GND to tell me when the cable is "On" or "Off", so I don't mess with plugging the battery with the cable "ON"

Which would be the best setup? How do the data lines behave, if they are always connected between the laptop and arduino (when powered by a 7.4V battery)? Will the data lines be turned off also, if USB supply line is cut?

Is it best, or safer, to cut the power by the putting the switch in the 5V line (A) or in the GND line (B)?

Could and Arduino (or any clone that has an USB programming/power port), if connected to a battery (but still connected to this USB cable in an OFF switch position) be able to light the LED, by "supplying" current to the cable? Even if the connection with the computer is cut?

Thanks!

ON OFF USB Cable

\$\endgroup\$
1
  • 4
    \$\begingroup\$ I would never ever cut the ground wire between two devices. If there is a ground loop that already connects the grounds via some other route, cutting the ground won't do anything, on the contrary, excessive current could flow via a wrong route, instead of the intended route. \$\endgroup\$
    – Justme
    Commented Aug 14, 2020 at 21:20

1 Answer 1

1
\$\begingroup\$

For at least most of the Arduino's and Arduino clones: If you power the Arduino through the DC power input or VIN, you can leave the USB cable connected, if you don't mind it get's powered up through USB when the battery can't supply.

If you still do want to cut power from USB:

Will the data lines be turned off also, if USB supply line is cut?

Yes. USB 5 V is connected directly to Atmega32U4 UVCC, which is the power supply for the USB hardware on the chip. Atmega32U4 is what communicates to the PC via USB. On Leonardo, it's also the main MCU.

Cutting the 5 V will disable the Atmega32U4 USB interface, therefore you wouldn't receive debug messages.

You should be able to supply

Is it best, or safer, to cut the power by the putting the switch in the 5V line (A) or in the GND line (B)?

If one needs to be cut, it's better to cut the 5V. Cutting GND might result in strange behavior, depending on your grounding setup and what voltage levels the signal pins might present.

Could and Arduino (or any clone that has an USB programming/power port), if connected to a battery (but still connected to this USB cable in an OFF switch position) be able to light the LED, by "supplying" current to the cable? Even if the connection with the computer is cut?

No, there's a circuit to prevent that if the other power supply is connected via the DC power plug or VIN signal.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ I just leave all connected, it works fine on the Nano and Uno devices. The isolation circuit is there for that reason, it does not backfeed into the laptop. In my units the power is all drawn from the external power supply as the Vf of the diode places the 5V to about 4.5V Note: I power via Vin, not the 5V pin. \$\endgroup\$
    – Gil
    Commented Mar 13, 2021 at 4:33
  • \$\begingroup\$ Yea, it just doesn't get powered off when battery is removed. \$\endgroup\$
    – Ralph
    Commented yesterday
  • \$\begingroup\$ It will still be powered via the USB \$\endgroup\$
    – Gil
    Commented yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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