Introduction: Plotting Arduino (Microcontroller) Data

Some times while working with different sensors you need to be able to plot the result. It lets you see historical data allowing you to identify strange behavior like random transients and long term drift.

This instructable uses an Arduino UNO with a temperature sensor hooked up to the analog input pin. Every second it takes a reading and sends the data value over the serial channel where a software tool called MegunoLink plots the data.

Step 1: Set Up the Arduino Program

MegunoLink Pro uses a special message to detect data and plot it automatically. This message format is as follows:

{TIMEPLOT:ChannelName|data|SeriesName|2013/04/23 14:00|25.6}

I'll start by describing the top line, each packet needs to have a {} pair to indicate a special message. Following the first { is the keyword TIMEPLOT this tells MegunoLink that you want to plot using the Time Plot visualiser (time on the xaxis and data value on the yaxis). Following this is some text, in this case ChannelName. You would use this to separate out different plots. In this case if we are plotting a bunch of temperatures throughout a house you could call the channel "Temperatures". After the channel name there is a data key word, MegunoLink uses this to decode the message properly. Following this is some more text naming the series. This would be what room you are monitoring, for example "Kitchen". Then in this top example another key word T, this indicates to MegunoLink that you want to use the computer time as a timestamp. Alternatively if you have a real time clock you could send your own time. This is demonstrated in the bottom example (second line above).

So in Arduino world you could simply use this code:
and it would plot 25.6 continuously using the computer time on the x-axis.

Generally you would want to do more than just send a single value so a simple function is the way to go. Below is a function that takes a float (25.6) and send it with the same format above.
void PlotKitchenTemperature(float data)<br>{

So putting all of this together here is an Arduino program which reads an analog channel connected to a temperature sensor and sends the temperature to MegunoLink.
const byte TempSensorPin = 0;<br>float CurrentTemperature = 0;
unsigned long LastPlotTime = 0;

void setup() 

void loop() 
    LastPlotTime = millis(); //Save time for 1s logging

    //reads 0-1023V -> 0-40degC
    CurrentTemperature = analogRead(TempSensorPin)*(float)40/(float)1023; 


void PlotKitchenTemperature(float data)
Now simply program your Arduino with this and we are ready to look at the MegunoLink side of things.

Step 2: Set Up MegunoLink Pro

MegunoLink Pro can be found at There is a free trial to make sure it does what you want it to. Download and install the program on any Windows based machine (XP or higher, Windows 7 or higher for the Visual Studio Features).

Open up MegunoLink Pro and you will be greeted with the welcome screen shown above. On the right is the selection tool for all of the different visualisers. As well as plotting there is:

  • Logging and monitoring tools
  • A way to display tabular data
  • A way to separate out messages for the general serial stream (debug stream for example)
  • A way to program some Arduino devices
  • A tool to plot points on a map from GPS coordinates
  • A way to create user interfaces which send and receive serial commands
  • And a tool to plot arbitrary x-y data

For this instructable we only want three visualisers. Click each one to open it up. First the Connection Manager, next the standard Monitor, and finally the Time Plot visualiser. They will open on top of each other however MegunoLink has a nifty docked interface. Just drag each tab to where you want it. The next step shows the layout I used.

Step 3: Plotting Data

Note that I have arranged MegunoLink with the Connection Manager at the top, the Monitor in the middle, and the Time Plot visualiser at the bottom. Lets start by configuring the Connection Manager.

The main things to consider here are the COM port and the baud rate. Set the COM port to match your Arduino and select the baud rate to match your program. If you have been following along the baud rate for this example is 9600. When that's done hit connect. (Currently it says disconnect in the screenshot because its already connected).

Next I draw your attention to the green boxes in the screenshot above. Here you need to select the connection you just set up. In the screenshot the connection was called "RS232 4" so this is selected on the Monitor and Time Plot visualisers. Data should start to arrive in the monitor from your Arduino formatted in say way we discussed earlier.

The final step is to select the plotting channel. On the Time Plot select the drop down (orange box in the screenshot) and select Temperatures. The plot should jump in to life and start plotting the temperature value as it comes in.

That wraps up this instructable. Hope its helpful!

Download MegunoLink Pro here.

Download the attached Arduino program and the MegunoLink save file to get started right away.