# USB Communication Problem on Reboot

**URL:** <https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450>\
**Category:** General\
**Created:** [11 August 2020 23:47 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450 "2020-08-11T23:47:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [11 August 2020 23:47 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/1 "2020-08-11T23:47:38Z")

</div>

Hi All,

I have been using Node-RED to control a variety of different devices (mostly Arduinos), and I have ran into the following issue. Every time when I reboot the main computer, all of the Arduino devices seem to be "connected" (showing a green light next to the serial port node), but I cannot communicate with them. In order to establish a proper connection, I have to unplug the USB and plug it back in. And then it works as usual. I already set up Udev rules for all devices, and they are all being recognized properly as far as I know.

One possible solution, that I'm really trying to avoid, is to get a programmable USB hub, where I can connect and disconnect the USB cables remotely. I was hoping that there could be a solution through NR.

Note: I have notices people had similar issues, but they manage to solve it by restarting the flow, which for me doesn't work.

Thanks!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 August 2020 07:46 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/2 "2020-08-12T07:46:58Z")

</div>

Does it help if you restart the Arduino?

When you say you cannot communicate do you mean you get an error of some sort or the Arduino does not reply? If the latter have you put some debug in the Arduino to see whether it is receiving anything?

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 13:17 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/3 "2020-08-12T13:17:05Z")

</div>

Hi Colin,

Yes I have put a debugger, and there is absolutely no communication. The Arduino doesn't send a reply. Usually when I send the following message:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2cf444f64a43962df7cf3a630496af0046766b7f.png) ,

I should get the following replay from the device. However, only physical disconnection, fixes the issue. As soon as I unplug and plug the USB back in, the communication works flawlessly.

Any idea what could be the issue? Some people suggested that the Arduino was counterfiet, but I tried it on an genuine one as well, and the issue remains. Thanks for your help!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 August 2020 14:15 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/4 "2020-08-12T14:15:19Z")

</div>

Is the Arduino receiving anything?  
You didn't say what happens if you restart the Arduino.

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 14:27 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/5 "2020-08-12T14:27:43Z")

</div>

Sorry about that. So the Arduino doesn't receive anything, at least nothing I can see in the debugger. When I press reset on the Arduino the serial port is disconnecting (of course) and then the error is: "Error resource temporarily unavailable cannot lock port." - so again zero communication. I tried to reset the arduino via exec command, but I encountered the same issue. Did I answer your question? Thanks!

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 14:42 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/6 "2020-08-12T14:42:15Z")

</div>

Update: if I press the reset button again, the issue is resolved. Now I have a command that can reset the arduino based on the bus and device number that is assigned to. But when I press restart the first time, the device number is changed, so I cannot execute the same command twice. For example:  
exe command 1: sudo ./usbreset /dev/bus/usb/001/007

but then if I want to do that again, the second number 007, is changing for the same device, so I cannot execute that again, unless I know what is the device number. Is there a way to reset all usb devices all? That might solve he problem

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 14:50 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/7 "2020-08-12T14:50:13Z")

</div>

Another update: even when I reset twice or three times, it is now connected, but still no communication. So I overcame the "port lock" issue, but it doesn't help me with the serial communication.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 August 2020 15:07 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/8 "2020-08-12T15:07:00Z")

</div>

> [@LiorBird](#):
>
> the second number 007, is changing for the same device,

I thought you had used udev to setup fixed device names.

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 15:11 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/9 "2020-08-12T15:11:27Z")

</div>

I have used it. I'm talking about "lsusb" comman. it keep switching device numbers. The device name remains the same, and connects automatically. However, still same issue where there is no communication unless I unplug the device physically. I'm trying right now to find a way to reset the arduino using a DTR pulse.

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 15:25 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/10 "2020-08-12T15:25:50Z")

</div>

DTR pulse doesn't work as well...

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 15:31 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/11 "2020-08-12T15:31:33Z")

</div>

Potential solution: I'm not sure if there is a way to do it, but if I press on reset 2-3 times, it finally works. Is there a way to mimic this action? Sorry for the mass messaging.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 August 2020 15:48 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/12 "2020-08-12T15:48:16Z")

</div>

What happens if you power down the arduino and up again obviously.

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 15:54 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/13 "2020-08-12T15:54:59Z")

</div>

I'm only using a micro-usb to power the arduino as well as to communicate with it. So if by powering down the arduino you mean "remove the power cable" which in my case is the usb, yes, the issue is resolved. Is there a way to power down the arduino via NR?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 August 2020 16:01 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/14 "2020-08-12T16:01:45Z")

</div>

Ah yes, so you can't power it down without disconnecting the usb.

I was attempting to identify whether the problem is with the arduino or the PC (or whatever it is).  
If you power down the main machine (which powers down everything I presume) and power it up does it work reliably then?

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 16:08 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/15 "2020-08-12T16:08:50Z")

</div>

Yes, if I shutdown the main PC, and turn it on again, the communication work properly.  
I can resolve that issue by sending a signal to a relay that will shut down the computer, than go back on, but it would be great if this can be avoided. Any ideas?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 August 2020 16:21 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/16 "2020-08-12T16:21:40Z")

</div>

> [@LiorBird](#):
>
> if I shutdown the main PC, and turn it on again, the communication work properly.

So shutting down the whole system and powering up again works, but just rebooting doesn't? I think that must mean that it is the Arduino that is in a confused state. Are you sure it is definitely listening on the serial port when you get to this state?

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 17:04 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/17 "2020-08-12T17:04:23Z")

</div>

yes I'm confident - shutdown the machine completely resolve the issue. I'm looking into a few possible solutions:

1. shutdown power to usbhub completely
2. connect a relay that I can control to shutdown the PC.
3. shutdown the PC and wakeup via LAN.

If there is a way to do it via NR it would be great, but I don't think there is a solution...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 August 2020 19:00 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/18 "2020-08-12T19:00:15Z")

</div>

You could use something like a Sonoff Basic with one of the alternative s/w packages such as Tasmota or ESPEasy, communicating with node-red via MQTT. Then in node-red you could initiate a sequence that runs in the sonoff which would wait a bit while node-red tells the PC to shutdown, then switches off the power to the PC and then switches it back on again. Have a look in the PC BIOS, you may be able to tell the PC to autorun when the power comes back on, rather than having to do a LAN wakeup.

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [12 August 2020 20:17 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/19 "2020-08-12T20:17:50Z")

</div>

I think this is the route I have to take - either a relay with a timer, or LAN wakeup. Couldn't find anything in BIOS that does autostart. Thanks for your help!

---

<div class="post-metadata">

**Author:** ![LiorBird](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LiorBird](https://discourse.nodered.org/u/LiorBird)\
**Post date:** [13 August 2020 16:09 UTC](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450/20 "2020-08-13T16:09:57Z")

</div>

My solution I ended up with:  
I splice the hot wire of the USB into a switch that is controlled from NR, and I just inject true after 5 seconds (when I reboot, it goes off, and then inject true automatically so I don't have to do worry about every time.) Thanks for your help again!

[Next page](https://discourse.nodered.org/t/usb-communication-problem-on-reboot/31450.md?page=2)
