Go Down

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

sms007

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

AWOL

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

AlphaBeta

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


rFree

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

   readings.append(reading)

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

   g.plot(readings)


In arduino:

Code: [Select]
#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);
}

Schwarzfuss

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

skatun

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


sms007

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?

Schwarzfuss

#7
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]
#!/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:
Code: [Select]
./plot.sh | gnuplot
Thanks!
Gruß Peter

Igor R

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%C3%B3n%20con%20Arduino%20v2.xls?download


[media]http://www.youtube.com/watch?v=4uxvAf0iLMM[/media]


Regards,


Igor R.

MikMo

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

http://mikmo.dk/gobetwino.html


Go Up