This example demonstrates sending CSV (comma separated values) data from an Arduino. We use MegunoLink’s Message Monitor to cleanly separate the CSV data from all the other messages travelling over the serial port. The Message Monitor lets you create separate ‘channels’ that can be cleanly viewed, copied, or saved for use elsewhere.

Separating Data from Debug

Many microcontroller boards such as the Arduino Uno offer only a single serial connection to a PC. This means all information being output to a PC has to go through the same pipe, where it all gets mixed together.

The MegunoLink Message Monitor and it’s corresponding Message class in the MegunoLink library for Arduino allow specific information to be filtered from the serial stream’s fire-hose. Each separate packet of data is wrapped inside special formatting by the Arduino library. This formatting is picked up by the Message Monitor which displays the data inside while ignoring all other serial traffic. The data can be easily copied or saved from the Message Monitor to a text file for importing into other software. You can even use different message channels to further separate messages.

Full serial stream on left is filtered to only the desired measurements by the Message Monitor on left.

It can be hard to use measurement data sent over serial if debug statements or other non-data text are also sent. The MegunoLink Message Monitor can help by capturing only the data messages, allowing the data to be easily copied or saved.

In this example, the time and measurements of two sensors are sent over serial in Comma-Separated Value (CSV) format within Messages for the Message Monitor. These Messages were intermixed with debugging warnings sent over the same serial port. The MegunoLink Message Monitor was used to display only the CSV measurement data.  From there it is easily copied to the clipboard or saved to a text file using the buttons at the top of the Message Monitor.

CSV data imported into Excel.

CSV-formatted values can be converted from text into proper numerical columns using Excel’s “Text to Columns” feature and selecting “Comma” as the delimiter.

The sensor data copied onto the clipboard was pasted into MS Excel and converted using the “Text to Columns” feature. It was plotted, showing the light reduction and temperature increase measured when a finger was placed on the corresponding sensor. Thus measurements over serial were easily obtained and processed without having to manually trim away debug statements or dedicating the serial port to sending only measurement data.

Additionally, the data in the messages can be nearly any string of characters you desire, not just the CSV formatted values shown here. The messages could also be received and automatically recorded to a text file by the Message Logger visualiser, without having to manually copy or save the data as with the Message Monitor.

Downloads

You can download a ZIP file containing the CSV Message Monitor example Arduino program and matching MegunoLink interface below. This example also requires our Arduino Library.

CSVMessageMonitorExample
CSVMessageMonitorExample
CSVMessageMonitorExample.zip
Version: 1
3 KiB
101 Downloads
Details

Example Code

Recent Posts

Leave a Comment

Start typing and press Enter to search