Hi everyone

I am Wilmer C, i am trying to plot some data which come from a serial port 
(I send it through Bluetooth using an Bluetooth HC05 and an arduino), but 
my code doesn't work. 

I am trying to plot in in real time, the frecuency of the data is about 
800Hz, I design an easy function which take the data from the serial port 
and send it to the update funcion whics is in charge to plot, but sometime 
the graph just doesn't plot nothing and sometimes it plot something but get 
block when are more than 20000 points.

I receive the data from the serial port in a string form as: "S1: 34 S2: 
345 S3: 245", for this reason i make the things that appear in the function

I leave the program here, and if something can help me, please don't 
hesitate.


from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
from pyqtgraph.ptime import time
import serial

app = QtGui.QApplication([])

p = pg.plot()
p.setWindowTitle('live plot from serial')
curve = p.plot()

data = [0]
raw=serial.Serial("COM8",115200)
def leer():
    while True:
        line = raw.readline()
        line=str(line)
        line=line.split(' ')
        if len(line)>4:
            line=line[2]
            line=int(line)
            return(line)
        else:
            continue
    
def update():
    global curve, data
    data.append(int(line))
    xdata = np.array(data, dtype='float64')
    curve.setData(xdata)
    app.processEvents()

timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(0)

if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
raw.close()


Thank you so much!

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/998c60d2-1cab-4aaf-8e3c-06ceb9ebc42d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to