MegunoLink gets data for plotting from special commands sent by your Arduino. A typical command looks like this: {TIMEPLOT:Battery|data|Voltage|T|12.2}.

Using these special commands means MegunoLink can easily separate the different kind of data you want to send it.

You don’t have to remember the special commands though. We’ve made a library to send them.

An Arduino Sketch to Plot Data

Here’s an Arduino sketch to read a sensor value and send it to MegunoLink for plotting. In this example, the sensor is attached to analogue port 0.

To build this sketch you’ll need to install the MegunoLink library and the Arduino IDE (or the development environment for whatever device you are using).

The first line of the sketch loads in the MegunoLink library, which contains support for easily sending data to MegunoLink.

Next up, we create a TimePlot variable named MyPlot. This represents a plot in MegunoLink. When you send data to this variable, it will take care of sending the right information down the serial link to MegunoLink. Check out the reference material on plotting for sending data to different plots.

The remaining code in the sketch is standard Arduino code to initialize the serial port and read data from an analogue sensor.

The next interesting bit is on line 14, where we use the TimePlot variable.

The SendData function sends the value measured by the analogRead function (SensorValue) to MegunoLink. It uses a series name of "My Sensor".

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

Plotting the data in MegunoLink

When you build and run the analogue plot sketch it will start spitting out serial messages like this:

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. To open a time plot, select Time Plot from the visualizers’ menu on the toolbar, the start page or visualizer dock.
  2. Select the connection you want to use from the source selector. If you don’t have a connection yet, choose Edit sources… and setup a new source with the Connection Manager.
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

In the plot visualizer, you can change 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
  • Connection Manager: connecting to multiple devices, using UDP communication with MegunoLink, preventing reset when connecting to your Arduino sketch.
  • Reporting: save graphs to files periodically
Recent Posts

Leave a Comment

Contact Us

Send us an email and we will get back to you shortly.

Not readable? Change text. captcha txt

Start typing and press Enter to search