loading

Make graphs on Qt and plot your arduino measurements

Picture of Make graphs on Qt and plot your arduino measurements
As promised I come in my second instructable to explain you how to program graphs on Qt. This will allow you to monitor measurements from a probe plug on your arduino. At the end of this instructable you will be able to program Labview-like software for free.

In this instructable you will learn :
how to receive data from your arduino
how to plot them on a graph

To do this I use Qt (say cute) which I already presented in my former instructable :
Control your arduino from your PC with the Qt Gui

To start to write your programs you will need to:
install Qt (sounds obvious ;) ) : https://qt.nokia.com/products/
install the additional library to read the port com : see my former instructable
install the additional library to put graphs in your programs : see the next step.



PS : As you probably notice it, I am not a native English speaker. I would be please if you can correct me.

 
Remove these adsRemove these ads by Signing Up

Step 1: Installation of QWT

Picture of Installation of QWT
compilling.png
Qwt is a additional library which allows you to add graph in your qt program.

I assume that you have already installed Qt, and you have basic skills in programming in C/C++.

First you need to get qwt from source-forge : http://sourceforge.net/projects/qwt/

Then you extract the files.

Here comes the tricky part. The files you downloaded are not compiled.
So you must compiled them. To do so you must start the Qt prompt console.
You can find it on Windows in :
start menu,
Qt SDK,
Desktop,
Qt 4.7.3 for Desktop (MinGW)

Then send the command that are on picture 2.

Congratulation, you perfectly compiled the library!

Step 2: Let's program

Picture of Let's program
Now you have installed all the library you need (qwt and qextserialport) your are ready to program.

I join a little example of a program (see the video in the introduction) which show data send from an arduino. In the next step I give a little program for your arduino to play with this progrme. If you want to do more complicated graphs you can have a look to the folder "examples" of the qwt lib.

All the description are into the program.

If when compiling you have the error n°1073741515 (or maybe another) that mean that you need to put the qextserialportd.dll into your .exe folder. Don't forget to also add the qwt.dll.

Step 3: Program your arduino

Picture of Program your arduino
Here is the program to send data.
It send only random data, up to you to improve it and add real probes.

void setup()
{
Serial.begin(9600); //initialisation of the port
randomSeed(analogRead(0)); //randomise the random function
}


int randNumber;

void loop()
{
randNumber = random(255); //generation of a new random number
Serial.print(randNumber, BYTE); //sending of the number
delay(1000); //wait 1 second
}

Step 4: Conclusion

Picture of Conclusion
I hope this instructable helps you to develop your own project.
The arduino is not the only device which uses the rs232 communication. This instructable can also be useful, for example in my job, to communicate  with vacuum probes, micro quartz scale, ...

Fill free to ask questions if you fill lost.
mba710 months ago

I made an equivalent tool in python that print real time data from ADXL345 accelerometer.

https://github.com/mba7/SerialPort-RealTime-Data-P...

may be it will be helpful for someone

Hi, great demo! Could you send the Qt source code?

I am not having success with the data plotting (Qwt).

mlroloff@yahoo.com

Thank you in advance,

ROLOFF

Jan_Henrik1 year ago

Very cool!