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, establish a connection and you’re plotting!

Arduino UNO beside plotting window

Overview

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 axis; one for the vertical axis.

Send data from your Arduino sketch to MegunoLink using our Arduino Library. Check out our Arduino Integration guide if you haven’t installed it yet.

The library sends data using special serial messages. MegunoLink decodes these messages to plot the data. A typical serial message looks like this: {TIMEPLOT|data|Voltage|T|12.2}.

The Arduino code to send the data would be:

The serial messages are created automatically by the library.

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 on 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, which includes support for easily sending data to MegunoLink.
  • 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 build and upload the analogue plot sketch to your Arduino it will start sending serial messages like this:

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 see this data plotted in MegunoLink, all you need to do is open a Time Plot visualizer and attach it to the serial port your Arduino is connected to:

  1. Select Time Plot from the Visualizers’ menu to add a plot visualizer to your MegunoLink project.
  2. Select Connection Manager from the Visualizer’s menu to configure the serial connection for your Arduino.
  3. Select the connection you want to use from the source selector on the Time Plot’s toolbar.
Get ready for plotting data

Select Time Plot from the visualizers’ menu on the main toolbar, then the connection your Arduino is using to plot data with MegunoLink.

Plotting data with MegunoLink

The MegunoLink Time Plot visualizer plotting data received from an Arduino

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:

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, exporting graph data
  • 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