Live Plot data by reading COM port data
-
Hi all,
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.Cheers,
ThomasP -
@thomasp said in Live Plot data by reading COM port data:
So I guess while Atom is using the port Spyder can't access to it ? Am I right ?
Close Atom, when you want to read form the serial port on the PC. You may also use a WiFi connection and sockets.
-
That was quick.
I just wanted to make sure I was doing it properly.
Works great. Thank you.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login