Introduction: Plotting Data From Arduino

Arduino doesn't have much in terms of debug and analysis capability built in, so it can be very useful to have a facility to plot data that's sent from Arduino over the Serial Port.

There are several ways to do that including Processing, Python + Matplotlib etc.. but none of these methods work effectively with very little setup and offer expected features such as Zoom, Scroll, Write to File, Save Setup etc.

I want to show you how to produce the kinds of plots illustrated in my Frequency Detection Instructable.

The Software I used to produce those plots is Bridge Control Panel.

It's released as a part of Cypress Semiconductor's PSOC Programming Utilities.

==============
By the way. If you like this Instructable, you might also like to read My Blog covering various projects and Tutorials.

==============

Step 1: Bridge Control Panel

Download and Install the Bridge Control Panel.

You need to write the Arduino Data over the Serial Port one byte at a time. For an int data type that would look as follows:

    // RX8 [h=43] @1Key1 @0Key1
    Serial.print("C");
    Serial.write(data>>8);
    Serial.write(data&0xff);

We Signal that we're sending a data byte then send each byte of the int.

The Syntax for the Bridge Command is shown in the comment and in the Picture of the Bridge Window.

Notice we have successfully connected to Arduino on COM6.

The command to Read Data is:  RX8 [h=43] @1Key1 @0Key1

RX8 is the read command
[h=43] means the next valid byte is "C" in ASCII
then the High Byte of Key1
then the Low Byte of Key1

[Chart -> Variable Settings]   panel is illustrated in the Picture.

In here you need to tell Bridge Key1 is Type:int , signed. The TICK means this is in use.

If you have made any mistakes here the command in the Editor Window will show the Errors in BLUE.

Finally you need to setup the comm's protocol in   [Tools -> Protocol Configuration F7]

Make sure the Baud Rate matches the one specified in Arduino.

To Capture Data press REPEAT in the Window.

Step 2: Plots

That's it.

Enjoy making great plots and enjoy a useful debugging tool.

You can also SAVE data for further processing by MATLAB or EXCEL etc..

Comments

author
mba7 (author)2014-09-21

I made an equivalent tool in python that print real time data from ADXL345 accelerometer.

https://github.com/mba7/SerialPort-RealTime-Data-P...

may be it will be helpful for someone

author
ajuvora69 (author)mba72015-01-08

Thank You!

You're a saviour

author
akellyirl (author)2014-04-22

For multiple values just add bytes. If you want to send two 16 bit words for example:

RX8 [h=43] @1Key1 @0Key1 @1Key2 @0Key2

Remember to select Key 2 as Active in {Chart -> Variable Settings} and set that data as having the appropriate formatting.

In Arduino:

Serial.print("C");

Serial.write(data1>>8);

Serial.write(data1&0xff);

Serial.write(data2>>8);

Serial.write(data2&0xff);

author
srosas5 (author)akellyirl2014-06-27

This software is no longer available. Can you upload it again?

author
akellyirl (author)srosas52014-09-24

I just checked that the software is still available under that link.

author
Christian RayD (author)2017-03-14

sir how to connect arduino to the bridge control?

author
vitold73 (author)2016-10-16

Hello
Im using following Adafruit sketch to read and plot the data from themocouple
based on MAX 31855 device using Bridge Control Panel

I
did receive plot ,set X axis as a time ,and Y axis as temperature readings. but
instead of temperature readings I getting triangle waveform with amplitude vary from 30 to 7710 (see attached images) , values
represented in Bridge Control panel TABLE capture looks okay to me. It is
possible to adjust Y axis temperature readings scale to get scaled temperature
readings ? Or there is something wrong in my data readings ?

Source h and cpp files : https://github.com/adafruit/Adafruit_MAX31856

Thank You

#include <SPI.h>

#include "Adafruit_MAX31855.h"





int maxSO = 5;

int maxCS = 6;

int maxSCK = 7;

int abc;

//Create a MAX31855 reference and tell it what pin does what

Adafruit_MAX31855 kTC(maxSCK, maxCS, maxSO);



void setup() {

Serial.begin(9600);

// The MAX31855 needs a little time to stabilize

delay(500);

}

void loop() {

Serial.print("C = ");

Serial.println(kTC.readCelsius());

abc= int(kTC.readCelsius());



delay(1000);

Serial.print("C");

Serial.write(abc>>8);

Serial.write(abc&0xff);

}

Plot and Table  Images.png
author
remibgs (author)2016-03-08

If you are looking for a general purpose solution, you can also check out my project on Github https://github.com/Overdrivr/Telemetry

I was tired of reinventing the wheel for serial so I figured out why not make something clean once and for all, well tested, etc.

The arduino library is highlevel, allows to write any kind of data (string, numbers, arrays) and is super easy to use. For PC side, I wrote a command-line interface (a terminal where you type commands), where, once connected, you can open as many plot as you want just using a command, selecting the received data by their label (each data you send is attached to a label). You can also write variables from the terminal, display a list of received data, log everything, etc.

This is just scratching the surface, there are many goodies in this library and the list is growing every day :)

author
marknonny (author)2015-11-24

I also am having trouble getting 'Bridge Control Panel' to show output. I want to use it to draw graphs. I have read the complete Help documentation that comes with it.

I have a (cypress psoc based) device connected to Windows COM5, and I know it is streaming my data, with a header of 'C' followed by binary bytes, which I can verify in TeraTerm of other serial emulator. I have set the serial parameters are the same as yours, RX8, 115200,8N1.

Bridge reports 'Syntax: OK' and 'Connected', I have the variables Chart Variables as your example. But nothing shows when I hit 'Repeat' or first highlight the command and hit 'Repeat'

1) to get a real basic hex dump of the serial port in Bridge Control, shouldn't I be able to use a command like: 'RX8 @0Key1' and set the chart variable 'Key1' to Byte. Could you possible post a step by step procedure for a simple hex dump with Bridge Control Panel?

2) Can you explain why only the 'Repeat' and 'ToFile' are enabled, but not 'Send' ?

3) Does the software on the device have to wait to receive a command from Bridge? Or can it just be streaming out the data?

4) Is it possible in RX8 mode to send a command to the device to initiate the stream?

5) Your example does not show any incoming data in the 'Results' window. In my attempts I saw some lines of hex values there 3 times, but cannot consistently get any.

author
ClaudioM3 (author)2015-11-14

I'm using this sketch to read Thermistor data (http://playground.arduino.cc/ComponentLib/Thermist... but I've problems plotting the data with Bridge Control.

I modified a bit the code adding an int Temp_copy and the last two Serial.write lines at the end of the sketch but I don't see nothing in Bridge control.

Please help.

Thanks

#include <math.h>

int Temp_copy;

double Thermistor(int RawADC) {

double Temp;

Temp = log(10000.0*((1024.0/RawADC-1)));

// =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration

Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );

Temp = Temp - 273.15; // Convert Kelvin to Celcius

Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit

return Temp;

}

void setup() {

Serial.begin(115200);

}

void loop() {

//Serial.println(int(Thermistor(analogRead(0)))); // display Fahrenheit

Temp_copy = int(Thermistor(analogRead(0)));

Serial.println(Temp_copy);

delay(100);

Serial.write(Temp_copy>>8);

Serial.write(Temp_copy&0xff);

}

author
akellyirl (author)ClaudioM32015-11-21

I don't think Serial.println(Temp_copy); is the correct thing to do. This will get sent to the Bridge control panel and won't mean anything to it. I think it should be :

Serial.print("C");

Serial.write(Temp_copy>>8);

Serial.write(Temp_copy&0xff);

The C character is improtant because that's what Bridge is lloking for to tell it that a number is coming next.

author
GoonyLex (author)2014-11-11

Hey
Great instructable, very helpfull.
Would you be able to tell me how to send a float data type to Bridge Control Panel? I tryed but no luck :(.

author
raymond.yau.35 (author)GoonyLex2015-05-05

I've tried to send float data type to BCP as well with no luck. Have you managed to figure it out? Cheers.

author
akellyirl (author)raymond.yau.352015-11-21

Send as an INT by multiplying by your required precision e.g. int( float_val*1000)

About This Instructable

55,686views

63favorites

License:

Bio: Technologist, Electronic Engineer, sometime Coderdojo mentor.
More by akellyirl:Arduino Guitar Tuner Using DSP TechniquesSmart Home ThermostatArduino Yun Messager
Add instructable to: