Live Plot data by reading COM port data
I'm using LoPy with Pysense connected to the Pc via USB.
Is there a way to read the accelerometer data sent by the Pysense and plot it with Spyder for example ?
I would like to use matplotlib library and use the data from the COM port to make a live plot.
This is the code I use :
import serial import time ser=serial.Serial(port='COM4',baudrate=9600) while True: print("try") time.sleep(10) s=ser.read(100) #reading up to 100 bytes print(s) ser.close()
And I get "access denied". When the Pysense is sending data, I can't read it because the port is already in use.
SerialException: could not open port 'COM4': PermissionError(13, 'Access denied.', None, 5)
So I guess while Atom is using the port Spyder can't access to it ? Am I right ?
How should I do that ?
Is there an easier way to print data ? I don't have SD card and I don't want to use one.
That was quick.
I just wanted to make sure I was doing it properly.
Works great. Thank you.
robert-hh last edited by