title: Raspberry Pi connection with Arduino over XRF continuous sensor monitoring
body: <p>I'm trying to make a system for monitoring sensor continuously including registering the time when the sensors are offline (not reachable by the server).</p>
  
  <p>The system is based on Raspberry Pi as server and Arduino Leonardo as node with sensors and the data is communicated from Arduino to Raspberry via XRF.</p>
  
  <p>I'm using Python script with pySerial for collecting data. My Python skills are poor and I need help to figure out how to continue monitoring when the connection between Arduino and Raspberry is lost and when the connection is re-established the sensor data could be collected again without restarting the script.</p>
  
  <p>the Python script follows:</p>
  
  <pre><code>import serial
  from datetime import datetime
  
  ser = serial.Serial('/dev/ttyAMA0', 9600)
  
  while True:
     #Arduino sends sensor analog reading when receiving the letter "k"
     ser.write('k') 
     datetime = str(datetime.now())
     print(datetime)
     print(ser.readline())
  </code></pre>
  
  <p>At the moment once the server looses connection to the client the script will stop.</p>