Step 1 of 3 step process for plotting demo

Install MegunoLink and our Arduino Library.

MegunoLink initial installer window

Step 2 of 3 step process for plotting demo

Download the plotting example interface and Arduino sketch.

Megunolink Interface beside Arduino IDE

Step 3 of 3 step process for plotting demo

Program your Arduino, create a connection and you’re plotting!

Arduino UNO beside plotting window


MegunoLink has two visualizers for plotting data:

  • Time-Plot: each data point is a single value used for the vertical axis; time is plotted on the horizontal axis
  • XY-Plot: each data point has two values: one for the horizontal (x) axis and one for the vertical (y) axis.

Send data and commands to these visualizers from your Arduino sketch using the TimePlot and XYPlot classes in our Arduino library.

Check out this video for an introduction to plotting with MegunoLink.

Sending Data from an Arduino Sketch for Plotting

In this example, we are plotting the value from a sensor attached to analogue port 0.

The Arduino sketch will read the sensor value and send it to MegunoLink. MegunoLink will plot the data in a time plot visualizer in a series named “My Sensor”.

You’ll need to install our Arduino Library to build this sketch in the Arduino IDE.

The 3 lines required to send the data to MegunoLink are highlighted. The key steps are:

  • Line 1: #include "MegunoLink.h" — loads the MegunoLink library.
  • Line 3: TimePlot MyPlot; — creates a TimePlot variable named MyPlot. This variable represents a plot in MegunoLink. Its methods take care of sending the right messages down the serial link to MegunoLink.
  • Line 13: MyPlot.SendData("My Sensor", SensorValue); — the SendData method value in the SensorValue variable to MegunoLink. MegunoLink will plot the data in a series named My Sensor. SensorValue holds the last sensor measurement, which was made using the analogRead function on the previous line. (SensorValue) to MegunoLink. It uses a series name of "My Sensor".

When you upload the analog plot sketch to your Arduino it will start sending serial messages like this:

The {TIMEPLOT|DATA|My Sensor|123} is is a special message that is recognized by MegunoLink. In this case, with data for plotting.

This sketch uses delay(1); to send a new measurement every millisecond (1000 measurements/second), for simplicity. It is better to use asynchronous delays to schedule events though. Check out our ArduinoTimer for more information.

Plotting the data in MegunoLink

To plot the data being sent from your Arduino sketch in MegunoLink:

  1. Use the connection manager to configure a serial connection,
  2. Add a plot to your project by selecting Time Plot from the visualizers’ menu,
  3. Open the serial connection by clicking the source selector.

MegunoLink will decode the messages sent from the Arduino and plot data on the graph.

By default, the timescale will expand to show all data received. Turn on auto-scroll (Autoscroll) to keep the timescale fixed and have old data scroll off the left edge of the time plot.

Add a time plot

Select Time Plot from the Visualizers menu to add a graph to your project.

Connect time plot

Click the source selector to open the connection.

Plotting data with MegunoLink

The MegunoLink Time Plot visualizer plotting data received from an Arduino

If data isn’t appearing on your graph, make sure the connection you created is selected as the visualizer’s source.

Serial connection selector

Make sure the correct connection is selected if nothing is plotted.

Plot Multiple Series on One Graph

MegunoLink can plot data from many different measurements on one graph. Each one will get drawn with a different color and name. These are called series. So you could plot battery voltage, temperature and humidity all on one graph using:

Sometimes it is better to send different measurements to different graphs, or use both the left and right y-axis. Sending data to multiple plots walks through the first case and using multiple axes describes the second.

Change Plot Appearance

Many of the plot characteristics — including titles, colors and axis limits — can be changed. Changes can be made in MegunoLink or by sending commands to MegunoLink from your Arduino sketch.

Click the Properties button (Properties button) on the plot visualizer’s toolbar to open the Edit Plot Properties window.

Edit plot properties

Change titles, axis limits and background colors in the plot properties editor.

Use the TimePlot variable methods to set plot properties such as titles and axis limits. Refer to the Arduino library reference for a full list of methods.

Change Series Appearance

A series’ marker, line color and style can be changed both from within MegunoLink and by sending serial commands to MegunoLink. Select the series then open the Edit Series Properties window using the button on the plot visualizer toolbar (Edit series properties).

Series properties can be sent from your Arduino sketch with each data point or as a separate command.

Edit series properties

Change symbols and line styles using the edit series properties editor.

Any property you send from the Arduino sketch will override changes the user has made in MegunoLink. So it is often better to send series properties as a separate command unless you are determined to maintain the style.

Refer to the Arduino library reference, series styles page and the series string properties reference for a full list of methods and series styles available.

What's Next?

We’ve just touched the surface of plotting in MegunoLink. From your Arduino sketch you can set many properties including axis labels, the chart title and edit the colours and styles used by each series.

For more information on plotting and serial communication check out:

  • Plotting Reference: plotting multiple series, changing plot properties, sending plot properties from the Arduino, exporting a graph, etc.
  • Exporting plot data: transfer plot data to another program using the clipboard or by saving it to a file.
  • XY Plots: plot two values against each other.
  • Time plot library reference: describes commands and properties you can send to an Time Plot.
  • XY plot library reference: describes commands and properties you can send to an XY Plot.
  • Multiple plots: send different types of data to different plots using channels.
  • Reporting: save graphs to files periodically.
  • Raw message reference: MegunoLink will plot data from any serial source; not just the Arduino. The raw message reference describes the protocol you’ll need for other microcontrollers.

Start typing and press Enter to search