How to capture data from arduino and graph

I try to find a way to read analog data from Arduino and show the data on a time chart. What is the best approach to do this. I am new to the arduino. Any suggestion is appreciated. Thank you

http://www.arduino.cc/playground/Interfacing/Processing

I try to find a way to read analog data from Arduino and show the data on a time chart.

This is an example doing just that! :slight_smile:

FWIW I did this yesterday with python-gnuplot.

$ python go.py /dev/tty/USB01

#!/usr/bin/env python2.5

import Gnuplot
import serial
import sys

ser = serial.Serial(sys.argv[1], 9600)

readings = []
g = Gnuplot.Gnuplot()
g.title("Thermistor readings")
g('set data style lines')
g('set yrange [-5:105]')

while 1:
    reading = ser.readline().split()
    print reading

    readings.append(reading)

    if len(readings) > 100:
        readings = readings[-10:]

    g.plot(readings)

In arduino:

#define REPORTING_INTERVAL 1

float time;
int reading;

void read_pin(char pin)
{
    while (1) {
        time = 0.001 * millis();
        reading = analogRead(pin);
        Serial.print(time);
        Serial.print(' ');
        Serial.println(reading);
        delay(1000*REPORTING_INTERVAL);
    }
}

void setup()
{
    Serial.begin(9600);
    delay(100);
}


void loop()
{
    read_pin(4);
}

thanks rFree for this great python-script,
but perhaps someone can tell me how to do the the same with
bash-scripting and gnuplot?

Matlab is a great tool for making plots, runs on all platforms and is easy to use, since u can manipulate ur graphs interactively

Hello efree,

I like your code in phyton.
My original thinking is to capture the data from arduino and save it as a text file or something similar and later on, use a program like excel to grapgh the data.

Do you have suggestion how to save the data to plot at a later date?

Sorry to hijack this thread, but after days of searching...
I think the best solution that works for me is something like this:

#!/bin/sh
stty -F /dev/ttyUSB0 115200 -raw -hup
echo -n "" > data #file for data
  sleep 1
while true; do
  cat "/dev/ttyUSB0" | sed q >> data
  #dd if=/dev/ttyUSB0 count=1 2>/dev/null >>data
  echo set yrange [0:300]
  echo set xlabel \"time\"
  echo set ylabel \"temp\"
  echo plot \"data\" with lines
  sleep 1
done

save as "plot.sh", call with:

./plot.sh | gnuplot

Thanks!

Hi,

Another method is use windows hyperterminal or a free terminal which can save into a file.

If you send data from Arduino as csv format(example semicolon separated), you can open this file with Excel directly and use its graphs....


Also it´s easy to do something in Excel with VBA and Netcomm
http://home.comcast.net/~hardandsoftware/NETCommOCX.htm

I´ve done an example: http://yqezpq.blu.livefilestore.com/y1plxKnMriMftb6U4LjMkuFyvIxfDmHMJ53KkprvNIDj2bZN2274uXlUUVqvrs7fS9a3xtWWcA2mrkuyFJd5vlJZA/Comunicación%20con%20Arduino%20v2.xls?download

Regards,

Igor R.

GoBetwino will let you dump data directly from Arduino into Excel, or log it to a txt file first (and a lot of other thins too).

MikMo, good job!! Cool!

:wink: