title: Make a NodeJS server auto-detect a connected device through USB
body: <p>I did a web interface for a colorimeter using a NodeJS server which reads USB serial inputs using the <strong>serialport npm library</strong> and sends that info to a local web page. The colorimeter is basically a circuit using a microcontroller which is <strong>connected to my PC through USB</strong>, using an intermediate USB module.</p>
  
  <p>The web page has state messages like: <strong>"Device Detected"</strong> (if the page is started with the device already inserted in the USB), <strong>"Device Disconnected"</strong> (if I pull out the device from the USB). The message updates perfectly for scenarios like pulling out the device from the USB port but I can't make it autodetect when inserting it back in the USB, without doing a browser page refresh.</p>
  
  <p>Is there any workaround for making the Node server <strong>detect automatically when the USB device is inserted</strong> in the PC and update the state message?</p>
  
  <p>Server code: <a href="https://codepen.io/grazvan/pen/wdLGPZ?editors=0010#0" rel="nofollow noreferrer">https://codepen.io/grazvan/pen/wdLGPZ?editors=0010#0</a>
  Currently, I am doing it on Linux that's why the <code>boardPort = '/dev/ttyACM0';</code>. I am open for solutions in Windows or another programming language too.</p>