Note that there are some explanatory texts on larger screens.

plurals
  1. POlanguage and toolkit for fast plotting of live data from serial port
    primarykey
    data
    text
    <p>i'm trying to plot live data from the serial port (sent from an arduino board) and i just can't find anything that works. i've been onto this for a couple of days, tried a lot and never succeeded. i manages to read data from the port using cat, C and python with very strange results on all of them. yesterday cat printed the data nicely to the terminal, today it only shows one line or two each time i run it. in C the data comes very dirty. in python it seems ok. while not perfect, the reading part is not the problem. i tried to plot the data from python with matplotlib, which worked with a ever increasing delay, that made the plot useless. i couldn't get C and gtk to work. i tried python + chaco but i don't get how chaco works. i found myself jumping between different languages and modules to get this to work, but as i got none of them to work i keep jumping without getting to any solutions.</p> <p>now, my question is: which language, modules, gui-toolkit etc. would you recommend to use for this?</p> <p>i know this a general question, and it is preferred to ask for specific things, but i'm really lost on this. thanks.</p> <p>Update: i choose python, pyserial and pyqtgraph. serial is working, but the graphing isn't. Update: GOT IT! this example is working.</p> <pre><code>#!/usr/bin/python # -*- coding: utf-8 -*- 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("/dev/ttyACM0",9600) raw.open() ptr = 0 def update(): global curve, data, ptr line = raw.readline() data.append(int(line)) xdata = np.array(data, dtype='float64') print xdata curve.setData(xdata) ptr += 1 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_() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload