Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I need to plot Serial Data from Arduino.

I require support for:

  1. Various data formats (e.g. signed, unsigned, 8 bits, 16 bits);
  2. Plots several data on the same axes;
  3. Exports / Imports file data.

As plotting Serial Data from Arduino is a common need, my question is: What Programs/Utilities are available for plotting Serial Data from Arduino that meet the needs above? What are the advantages / disadvantages of the method you have suggested?

share|improve this question
    
I decided to reopen with your last edit. As this question stands, it seems to be on topic because it's specific. I'll be clear to anyone (since there's not a lot of these types of questions): if this gets too off topic, I may have to step in. However, the likelihood of that happening is rare. :) @JRobert If GnuPlot meets the requirements in the question, post it. –  Annonomus Penguin Apr 17 at 20:47
    
The "Interfacing with Other Software" page on the Arduino Playground shows a bunch of ways to plot serial data from an Arduino to an iPhone, a Windows PC, a Linux PC, etc. –  David Cary Sep 24 at 22:18

7 Answers 7

I use Matplotlib for any plotting I need to do.

It's not arduino specific in any way, but it is a very excellent Python plotting toolkit.

I've built a number of applications that plot data from a variety of microcontrollers in real-time to a graph, but that was really more of a two-step process: 1. Get data from device into computer, 2. plot realtime data.

Really, I think you should break your question into two parts:

  • How do you get data from an Arduino/Any serial device into a computer easily.
  • What is a good plotting library that is easy to use.
share|improve this answer
    
+1. Does the "Arduino real time plot Matlab"[youtube.com/watch?v=ntHZsLmNkgw] video use that same technique? –  David Cary Sep 24 at 21:27
    
Yep. It uses a call that reads the arduino data into a matlab variable, and then a call that updates the matlab plot with the matlab variable. –  Connor Wolf Sep 25 at 0:12

GnuPlot

Advantages: It's very flexible, scriptable, and freely available.

Disadvantages: A bit complex to learn (but I figured out how to get started in a few minutes, and quite functional in an hour or two), runs in a terminal window (if you consider that a disadvantage).

Something I found very useful was to script it to reload my terminal program's logfile periodically so i got a dynamic graph as my experiment progressed.

Image of GnuPlot



Edit: Here is the GnuPlot script that plots it:

#!/usr/local/bin/gnuplot -rv
# Note reverse video here ^^^   til I find a way to put it in the script

# gpFanCtl - Plots DiffThermo fan controller data (aloft, alow, Tdiff, fan-state).
# $Id: gpFanCtl,v 1.8 2014-04-28 09:40:51-04 jrobert Exp jrobert $

set terminal x11 1 noraise
set xtics 3600
set mxtics 4
set xdata time

set ytics 1 nomirror
set mytics 2

set y2range [0:3]
set y2tics 1
set my2tics 4

set grid
set ylabel 'Temperature, degC'
set y2label 'Tdiff, degC' textcolor rgb '#00CD63'

cd '/Users/jrobert/Desktop'
plot "Logfile.txt" using ($0*4):1 title "Aloft" with lines lc rgb "red",\
     "Logfile.txt" using ($0*4):2 title "Alow" with lines lc rgb "#3982FF",\
     "Logfile.txt" using ($0*4):3 title "Tdiff" with lines lc rgb "#00CD63" axis x1y2,\
     "Logfile.txt" using ($0*4):4 title "Fan" with lines lc rgb "orange" axis x1y2;
pause 4
refresh
reread
share|improve this answer
    
This looks great. Could you add some demo code? –  geometrikal Sep 25 at 5:01

Responding to my own question here.. I use Bridge Control Panel as mentioned.

Advantages: Lots of Features.

Disadvantages: Tricky to setup and very poor syntax/error reporting.

To use: You need to write the Arduino Data over the Serial Port one byte at a time. For an int data type that would look as follows:

// RX8 [h=43] @1Key1 @0Key1
Serial.print("C");
Serial.write(data>>8);
Serial.write(data&0xff);

In Bridge the command to Read Data is:

RX8 [h=43] @1Key1 @0Key1

RX8 is the read command [h=43] means the next valid byte is "C" in ASCII then the High Byte of Key1 then the Low Byte of Key1

It looks like this in Bridge:

enter image description here

enter image description here

share|improve this answer

You can try serialchart. It's pretty strait forward program. It does exactly what you asked. The only disadvantage is that it requires data in CSV format (does not meet first point).

Screenshot from project page:

example

share|improve this answer

I made an equivalent tool in python that print real time data from ADXL345 accelerometer. https://github.com/mba7/SerialPort-RealTime-Data-Plotter

may be it will be helpful for someone

enter image description here

Just choose the serial com and speed and sent a serial data on the following format:

  • 3 inputs, every input is a 2 bytes (Two's complement )
  • 6 bytes seperated by a space
  • the packet is a string terminated by '\n'

Could be easily adapted to change this format

share|improve this answer
    
Can you explain how to use this, and what the advantages and disadvantages of this are? –  The Guy with The Hat Sep 21 at 23:17

While I haven't used it myself, "rqt_plot" running on the PC seems to be a popular way to plot data on a PC that comes over a serial port from an Arduino running a sketch that includes the rosserial_arduino library or the ros_arduino_bridge library.

share|improve this answer

you can use matlab student edition, this can save your time for further analysis, too. you can just open the COM port in matlab and plot the received signal and/or save the signal in the workspace or whatever. matlab makes everything easy!!

share|improve this answer
2  
Welcome to Arduino SE! Can you please edit your answer to add more information describing how it fits the OP's needs and maybe a little other information like a link or a photo? Thanks! –  Annonomus Penguin Jul 31 at 13:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.