Pages: [1]   Go Down
Author Topic: How to capture data from arduino and graph  (Read 8888 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 303
Posts: 26350
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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! smiley

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

FWIW I did this yesterday with python-gnuplot.

$ python go.py /dev/tty/USB01
Code:
#!/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:
#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);
}
Logged

MK (D)
Offline Offline
Full Member
***
Karma: 8
Posts: 170
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Gruß Peter

0
Offline Offline
Full Member
***
Karma: 0
Posts: 140
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

MK (D)
Offline Offline
Full Member
***
Karma: 8
Posts: 170
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry to hijack this thread, but after days of searching...
I think the best solution that works for me is something like this:
Code:
#!/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:
./plot.sh | gnuplot
Thanks!
« Last Edit: June 24, 2009, 10:45:36 am by Schwarzfuss » Logged

Gruß Peter

0
Offline Offline
Edison Member
*
Karma: 16
Posts: 1579
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Edison Member
*
Karma: 16
Posts: 1579
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

MikMo, good job!! Cool!

 smiley-wink
Logged


Pages: [1]   Go Up
Jump to: