How to plot real-time signal coming from Arduino via Serial Port

(Last Updated On: March 10, 2018)

Plot a processed signal coming from Arduino COM port in real time is a useful practice when working with sensors. Also this makes a great feature to present or show your proyect to others. Arduino code-debugging is another reason: Many of us only use single delays and Serial.println to figure out what is happening on the board. Here I am going to explain one simple solution without the need of writing a custom script, which could be the smarter solution to work with sensors.

Kst real time plotter

To overcome this, the problem is split into two parts: first, we need to write the incoming data from the COM port into a CSV  file (comma separated value file). Later we plot the data stored in this file on the real time plotter kst.

Write the data from COM port into a CSV File

1. To write the data coming from the COM port into a CSV  you will need to install a software like RealTerm. There are more other programs that allow you to do this, but I used this one. A better and more advanced solution should be to write a script to do it directly, but here I will show how to do it without programming an special script. This program is an alternative to Putty, this serial terminal which came with windows.


Note that you can not have two serial connections opened at the same time. For example, if you are using the Arduino IDE Serial monitor, you are not allowed to open Putty or Realterm and vice-versa. Only one client can be connected at one time. Therefore, if you want to load an Arduino program into the board, you have to deactivate the connection with Realterm and vice-versa.

2. Open Realterm and configure the COM port that you are using with the Arduino. This can be seen at Tools>> Serial Boards. In RealTerm on the tab of “Echo Port”.  We can manage and change the serial port.

Remember that to start reading the data and writing into the selected file, you have to check the box “Monitor” on the “Echo Port” tab. After the change don’t forget to push the button”Change” to save.

3. On the tab “Capture” of RealTerm, now select or create a new file to write the data and check the “Direct capture” box.

4. To start the writing, once your Arduino is already streaming data to the serial port, go to the tab “Capture” and push “Start : “Overwrite” or “append”, depending if you want to overwrite or append the new data.
To print your data “cleanly” print the data without text, for example:

While Realterm is writing to the file, the GUI should appear in red colour.

Plot the data from a CSV file

1.Download the free and open source kst program (available to all the platforms: Windows, Mac and linux). Follow the instructions to complete the instalation .

2. Execute the program. If you are using linux, you have to call the following command to open the GUI:

Also is possible to call kst from a python script. For that use:

If you want to open a saved kst configuration file, which have to be in the root folder:

3. Open the data wizard and go thorugh as it is explained on the pictures.

4. Open the data Wizard and follow the steps. You have to select the source file. Choose the time interval: “change detection” if you are working with local data. If you want to reproduce a saved test, just select “no update”. Important to change the ASCII file configuration.

5. ASCII configuration. Here you have to say to the program how to interpret the file. This configuration depend on your file. The most important parameters are selected with red.

ASCII file configuration

6. Select your which data you want to plot. If your file has a header on the first row with the field names and you have selected “Read field names from line” on the previous step, now you should see the names. If not, you will see “column 1″, Column 2”, etc… Kst always generates an automatic column called INDEX, which is the numbers 0, 1, 2, 3… useful to use on the x-axis.
Select all the columns you want to plot on the correct order and press next.

7. Data range. Usualy, you want to plot real time data, so you want to show the last X samples available in your file. For this you have to choose “count from end” and put range between 200 and 500 depending on the speed you read the data. This can be changed later.
Put on the X-axis the INDEX column.

8. Layout configuration. Leave this as default and later you can change what you like. Here I like to remove the legends of each plot to have a better view. This only makes sense if you plot more than one curve per graph.

The final plot look like:

Another view of kst with more plots:

After changing your visualisation, parameters, etc you can save the configuration as a *.kst file. You will save many time for the next time.

2 thoughts on “How to plot real-time signal coming from Arduino via Serial Port

  1. Reply
    Arnau - April 30, 2018

    Hi! I don’t know the limits about this. The question is that I need to plot signal that its coming at 400 samples per second or 200 samples per second if its need it. So this is going to be fast enough. Other project I try with matlab was to slow for this. Also the data send it it sendit by bytes so it would get together again. So to sum up, this project could be adapt for this conditions, in this case I would try it. Sorry for my english Greetings from Spain.

    1. Reply
      Alberto L. - April 30, 2018

      Hello Arnau, In this case you mention, should work fine. The KST is able to plot even faster (depend on the machine… but yes). Just in case set the serial communicacion of the Arduino to the maximum possible. Maybe 115200 kps is enough. You can use Realterm or oder program to write the data into a file.

      Saludos desde Murcia!

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top