I would like to read from the USB serial port from time to time in a loop. I can open the port and read data with:
import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
while 1 : ser.readline()
An Arduino Uno is connected to the USB port of the RPi. The Arduino acts as a sensor and it will constantly produce readings.
I need some help in adding timing features to the above code. I want to open the port and read from it for a certain period of time. After that period of time, the port closes and the received data will be analysed. After a pause of several minutes, the port will reopen and the RPi will read data from it again. This continues in a loop. Any help is much appreciated.