1

I am working on project in which I am getting data from Arduino serially and accessing them into Python.To access data from arduino I am using pyserial. After that I have to display that data on Python GUI. How can I do this?

I am getting this data in Arduino Serial Monitor....

2.00
2.64
3.28
3.92
4.56
5.20
5.84
6.48
7.12
7.76
8.40
9.04
9.68
10.00
9.69
16.59
23.50
30.40
37.31
44.21
51.11
58.02
64.92
71.82
78.73
82.18

And using pyserial I am getting this data as python output...

[2.0]
[2.0, 2.64]
[2.0, 2.64, 3.28]
[2.0, 2.64, 3.28, 3.92]
[2.0, 2.64, 3.28, 3.92, 4.56]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11, 58.02]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11, 58.02, 64.92]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11, 58.02, 64.92, 71.82]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11, 58.02, 64.92, 71.82, 78.73]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11, 58.02, 64.92, 71.82, 78.73, 82.18]

In python I have used this code to get Serial data....

import serial
arduino = serial.Serial('COM5', 9600, timeout = .1)
arduino_data = [] # declare a list
while True:
    data = arduino.readline()
    if data:
        arduino_data.append(float(data)) # Append a data to your declared list
        print arduino_data
5
  • 1
    What is the relevance of pyserial and arduino in your question, when it seems to be all about how to display data in python gui? Could you be a little more specific on how you want to display your data? Could you provide a data example? note: edit your question to add relevant information, don't use comments for that. Commented Feb 13, 2017 at 13:37
  • Great edit, upvoted. Now, what is the end result that you want to achieve? do you simply want to plot a live graph or you want an entire application around it? Commented Feb 14, 2017 at 7:13
  • @PatrickTrentin..Thanks for upvoting...Not live graph but can say entire application around it,i.e. just create a windows that can display serial data that I got in python shell.which I have displayed in myquestion as pyserial output. Commented Feb 14, 2017 at 7:46
  • Ok, then I think I am not able to help you on this. There are similar projects from which you could take inspiration, though. See this, this, this and this Commented Feb 14, 2017 at 7:51
  • @PatrickTrentin..Ok thanks. I will try on that links. Commented Feb 14, 2017 at 7:56

1 Answer 1

1
import serial
arduino = serial.Serial('COM3', 9600, timeout = .1)
arduino_data = [] # declare a list
i=0;
while i<5:
    data = arduino.readline()
    if data:
        #arduino_data.append(data) # Append a data to your declared list
        print data
        i=i+1;


#try this code mate, i am beginner but did this for you i think i will work for you please
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.