PlatformIO Community

Plotting using platformio


#1

I recently started using platformio and I have an issue. I downloaded the Plotter library through the library manager on platformio on VSC and used the example from the library to plot a graph. After uploading the graph to my TinyDuino board and open the serial monitor, it prints out chunks of characters and no plot.
Am I missing something here?


#2

Does the baudrate of the sketch match the baudrate used by the sketch? (you can set the baud rate used by the serial monitor by e.g. writing monitor_baud = 115200 in the platformio.ini.


#3

I added Serial.begin(9600); to the example that I used, and now it printing numbers that looks like coordinates. Still no plot


#4

You’re supposed to use the listener application written in Processing to view the graphs. The miniterm console will only ever display the text, not interpret it as graph lines.

See https://github.com/devinaconley/arduino-plotter, especially the listener Processing and Java code and the Processing tool itself.


#5

PlatformIO doesn’t have the “Serial Plotter” tool/viewer present in the Arduino IDE (assuming that the Plotter library gives compatible output) - so as @maxgerhardt pointed out, you’ll need to look at tools like the accompanying Processing-powered listener app to get that functionality.


#6

In the Arduino IDE, I can use the Serial Plotter to see a live display of the variables values as the program runs. I also use Veusz graph plotting software to graph the data after the run is over. Veusz is much better at graphing than the Arduino IDE. Veusz also has a feature to collect data from a file every 0.1 sec (and other). I would like to be able to do the same thing in PlatformIO. Is this possible? I can use an external Terminal program. But how do I get a live plot.

platformio lib install 850 (Arduino Plotter)
Does not work.


#7

So you’ve tried installing the listener app (you need both the listener app and the Processing tool that it is based on) that Max linked above?

The only other real-time plotting I use is that included in the Arduino IDE… mainly because it’s cross-platform, so doesn’t matter if I’m on Windows or Linux.

SerialPlot might be worth trying… there are linux and windows builds for it, and the interface seems pretty straightforward. Links to downloads are partway down on the left sidebar.


#8

Processing 3.5.3 is installed.
Arduino-plotter 2.3.3 is installed. Plotter 2.3.3 is installed.
SerialPlot v0.10.0 is installed

However, when I try to run the arduino-plotter example I get the message

src\main.cpp:2:21: fatal error: Plotter.h: No such file or directory

The following commands do not work.

platformio lib install 850

platformio lib install "Plotter"

pio lib install "Plotter"

This sounds like three paragraphs and three apps.

  1. Processing and Listener

  2. Arduino IDE

  3. SerialPlot

I am not sure this is correct.

Can you please elaborate?

I am using this setup

[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
lib_deps =
Plotter

The sample program seems to be working but I can not find the plot window.


#9

Right, so you have three suggested options for real-time graphing:

  1. Processing and Listener (Arduino plotter library v2.3.3)
  2. Arduino IDE (Serial Plotter)
  3. SerialPlot

Note: I’m using a Arduino Uno as that is what I had handy, but this should work just fine with a Mega also.

For 1, you need to have downloaded processing, the listener app, and the library. lib_deps = 850 worked fine for me, so you should have it installed anyway if you did platformio lib install 850.

I tried the quick_start.ino listed on the library page, and added the requisite #include <Arduino.h> that was missing.

quick_start.ino code
#include <Arduino.h>

/*
  ===========================================================================================
  Example used in Quick-Start
  -------------------------------------------------------------------------------------------
  Plotter
  v2.3.0
  https://github.com/devinaconley/arduino-plotter
  by Devin Conley
  ===========================================================================================
*/

#include "Plotter.h"

double x;

Plotter p;

void setup()
{
    p.Begin();

    p.AddTimeGraph( "Some title of a graph", 1500, "label for x", x );
}

void loop() {
    x = 10*sin( 2.0*PI*( millis() / 5000.0 ) );

    p.Plot(); // usually called within loop()
}

I then ran up the processing ide (v3.5.3), opened the listener.pde, pressed the run button near the top left, and waited for it to start. It then scanned the serial ports, detected the device running graphing code, and started plotting the graph. So it does still seem to work.

For 2, I am referring to the Serial Plotter available from the Tools menu of the Arduino IDE, which works with simple Serial.println() statements

Code
#include <Arduino.h>

void setup()
{
  Serial.begin(9600);
}
void loop()
{
  for (int i = 0; i < 1023; i+=10)
  {
    Serial.println(i);
    delay(10);
  }
  for (int i = 1023; i > 0; i-=10)
  {
    Serial.println(i);
    delay(10);
  }
}

For 3, the exact same sort of ‘simple’ serial print data logging works with SerialPlot, once you choose the ‘ASCII’ (text) data format.


#10

THINK YOU

I was getting nowhere and extremely frustrated. Then I fixed my broken wire.

Let’s start with the easiest one.

  1. Formaly 2: Arduino IDE (Serial Plotter) - I did not know that the Arduino IDE Serial Plotter keyed off of Serial.println() and the serial stream. I did not know that it would work on another program’s serial stream. That works. Thank you!

  2. Formaly 3: SerialPlot - I got it to work. Thank you!

  3. Formaly 1: I did not know that the listener was a Processing IDE program written in Java. The PlatformIO command line library install of ’ “Plotter” ’ did not work. When I put “Plotter” into the Platform.ini, the install happened during compile. It seems that the Processing program needs a library to be installed. But the literature does not mention the necessity of any library

image


#11

Fantastic! :smiley:

I do like SerialPlot, as it is a nice simple standalone program, and can be taught to decode serial output and make in into a graph, as well as being able to record/log that data to file whilst building the graph. But the Arduino Serial Plotter is just there if you have the IDE installed already.

For the processing app, did you download both files? i.e. the contents of the listener folder - you need both the Graph.java and listener.pde files. Other than those, I didn’t install anything else, and this was a new install of Processing v3.5.3 as the last time I ran it was when it was v2.2.1…


#12

I had done a manual copy/paste of the one listener file. Since that did not work, I installed Desktop and did a clone. Now the sample works. Time to actually learn them and get productive. Perhaps only the Graph file is in Java.


#13

No, not quite… the listener processing ‘app’ is in two parts… listener.pde is the main program code, and Graph.java is the graphing code.

Just note if you copy and paste stuff, make sure that you are looking at the ‘raw’ file, so that you’re not copying stuff that was ‘prettied’ up for online display… i.e. ‘smart quotes’ instead of ‘real quotes’, &lt; instead of <, etc, etc. by clicking on the ‘Raw’ button, and then you can usually right click and ‘save as’ then to get the file ‘as is’ .

Shouldn’t be a problem now though if you’ve got the github desktop :wink:

Also, you can download the repo instead of clone it, meaning you can get the files without needing the github desktop client, but using the client allows you to easily update stuff in the future if you want to…

Happy graphing! :smiley:


#14
  1. Arduino IDE (Serial Plotter) - Thank You!:neutral_face:
  2. SerialPlot - Thank You!:slightly_smiling_face:
  3. Processing IDE Plotter - Thank You!:heart_eyes:

But my balancing robot program still needs more diagnostics. The plots are a big help. But a plot is different from a text log. A log can be helpful too. Both a log and a plot provide useful information, but they are different and the information that each provides is unique. So, I am trying to do both. My goal is to be able to look at a graph to find a point to inspect and check the log to see what happened. The problem is that all of this is coming through one serial port. I can run one terminal program or one plotting program. But if I use a terminal program, there no plot. If I use a plotting program, it is text intolerant. If my program uses Println, SerialPlot shuts down. The Processing Listener is more robust in that it does not shutdown. But it also refuses to make the plot. If I had both the log and a plot, I could sync them with the program time [millis()].

Is there any way to do this?