Make Beautiful Plots From Live Arduino Data (and Save the Data to Excel)
by ChemistGoneRogue in Circuits > Arduino
4040 Views, 7 Favorites, 0 Comments
Make Beautiful Plots From Live Arduino Data (and Save the Data to Excel)
We all like playing with our P...lotter function in the Arduino IDE.
However, while it can be useful for basic applications, the data gets erased as more points are added and it's not particularly pleasant to the eyes. The Arduino IDE plotter doesn't save your data for future viewing.
This is why in this Instructable I am attempting to correct our common problem. We want, no...NEED an Arduino data plotter that:
-Looks good
-Does NOT delete data points after a certain number of points have been drawn
-Saves all of the data to Excel without any fancy code
In the next steps, we'll learn how to write an easy Arduino program such that it can communicate with the plotter, accurately display data and save it to an Excel file.
While it is not needed to watch any of the videos included in this Instructable to follow along, it might be a good idea if you're a visual learner so you can follow along. They can be found HERE:
https://www.youtube.com/watch?v=LvNulqGuhlU&list=PL3Y_L-Yx1pgAtdG8DY_7qOHbbWfO4qomX&index=1
What You'll Need
For this, you'll need any Arduino or Arduino clone. In this example, I am using an Arduino UNO.
You also need to download the .exe file that contains the plotter HERE:
https://sourceforge.net/projects/arduinoexcelplotter/
Here's a video showing how to download it safely: https://youtu.be/9AXWtvbpcIo
More details on how to use it can be found in the last step of this Instructable.
Writing the Arduino Code
The Arduino code is pretty similar to the one you'd normally use to print to your Serial monitor or Serial plotter in the IDE.
Since Instructables tends to somehow mess up the code, I have also included the code in a file as well as a link HERE to my GitHub, where you can download all of the files from this Instructable in one place.
void setup() {<br>Serial.begin(9600); //Any baudrate is fine } void loop() { //Not actually reading analog values //Just plotting 0-19 and starting over for (int i = 0; i < 20; i++) { Serial.println(i); //the Serial.println() is the part needed to send data to the plotter delay(500); //delay so the plotter has time to plot (can be way less than 500) } }
Upload the code to your Arduino and pay attention to which Port you're using. You'll need this info later. In my case it's COM11.
Downloads
Running the Plotter Program
Since Instructables won't allow me to upload a ZIP or EXE file, you may get the ArduinoPlotter program from my SourceForge HERE:
https://sourceforge.net/projects/arduinoexcelplotter/
Because this is an unknown .exe file, when trying to run it Windows might warn you that the file could be unsafe, disregard it and run it anyway.
Instructions on how to use the plotter:
-Make an Excel document somewhere to write your data to. Make sure the first sheet is named Sheet1
-Simply run the plotter.exe by double-clicking on it. A window will open.
-Type in the baud rate you uploaded to your Arduino in the IDE (in my example it was 9600)
-Type in the com port your Arduino is connected to (same as in the Arduino IDE used for uploading the code) Don't type COM11, just type the number 11.
-Copy and paste in the path to your Excel file with Name.xlsx at the end. You need to fix the path so it uses \\ instead of just one \, for example:
C:\Users\ChemistGoneRogue\Desktop\test.xlsx - WRONG
C:\\Users\\ChemistGoneRogue\\Desktop\\test.xlsx - RIGHT
-If you haven't done so before, plug in your Arduino now
-Click "Save Settings" and close the program.
-A new window will open that is going to plot your values (Y axis) in series (X axis) and save them to the specified Excel document.
While the data is being saved as fast as your Arduino is sending it, the plot ads a point every 10ms.
IF YOU FOUND THIS INSTRUCTABLE HELPFUL, CONSIDER VOTING FOR IT BELOW (Arduino contest)