title: How to check if device is connected Pyserial
body: <p>I am connecting with my Arduino through a USB port and sending data to it by using PySerial module. At first I can check if the device is connected by using this code:</p>
  
  <pre><code>try:
      ser = serial.Serial("COM3", 9600)
  except serial.serialutil.SerialException:
      print "Arduino not connected"
  </code></pre>
  
  <p>Now what I want to do is to check periodically if the Arduino is still connected to the computer. I tried <code>ser.isOpen()</code> but this returns true even if the Arduino is disconnected. I would also like to know how to reconnect the device. I mean once you disconnect the device the program can no longer send any data to Arduino.</p>