Go Down

Topic: How to capture data from arduino and graph (Read 18781 times) previous topic - next topic


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


"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


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! :)


FWIW I did this yesterday with python-gnuplot.

$ python go.py /dev/tty/USB01
Code: [Select]
#!/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


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


In arduino:

Code: [Select]

float time;
int reading;

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

void setup()

void loop()


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?


Jun 24, 2009, 05:39 pm Last Edit: Jun 24, 2009, 05:45 pm by Schwarzfuss Reason: 1
Sorry to hijack this thread, but after days of searching...
I think the best solution that works for me is something like this:
Code: [Select]
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

save as "plot.sh", call with:
Code: [Select]
./plot.sh | gnuplot



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

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



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).



Go Up